Closed Bug 1305822 Opened 8 years ago Closed 4 years ago

WebDriver:SwitchToWindow should switch back to the top-level browsing context

Categories

(Remote Protocol :: Marionette, defect, P1)

defect

Tracking

(firefox84 fixed)

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: juangj, Assigned: whimboo)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [marionette-fission-mvp][simple], [wptsync upstream])

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36

Steps to reproduce:

When "Switch to Window" is called with the handle of the current top-level browsing context (i.e., "switching" to the current window), the current browsing context should be reset to be equal to the top level.

== WebDriver (Python) code ==
  def testFrameSwitching(self):
    self.driver.get('http://localhost/frames.html')

    window = self.driver.current_window_handle
    self.assertEqual('outside', self.driver.find_element_by_id('x').text,
                     'Should start at top level after navigation')

    iframe = self.driver.find_element_by_tag_name('iframe')
    self.driver.switch_to.frame(iframe)
    self.assertEqual('inside', self.driver.find_element_by_id('x').text,
                     'Should switch to <iframe>')

    self.driver.switch_to.window(window)
    self.assertEqual('outside', self.driver.find_element_by_id('x').text,
                     'Should reset to top level after switching windows')

== frames.html ==
<html>
<body>
  <div id="x">outside</div>
  <iframe src="frames1.html" />
</body>
</html>

== frames1.html ==
<div id="x">inside</div>


Actual results:

In Marionette, the last assertion fails; it still considers the iframe to be the current context, instead of the top-level context associated with the window handle.


Expected results:

After switching windows, further commands should go to the top-level context.
Component: General → Marionette
Priority: -- → P3
Blocks conformance.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: P3 → P2
Summary: Marionette should switch back to the top-level context when switching windows → WebDriver:SwitchToWindow should switch back to the top-level browsing context

First we should make switch to window free of the race condition which I will cover soon on bug 1335085.

Depends on: 1335085
Assignee: nobody → hskupin
Status: NEW → ASSIGNED

Actually this failure can no longer seen with the actor implementation given that the driver directly calls into the right instance. But for the framescript we do not update the currently selected frame yet. This is easy to fix. Patch attached.

Priority: P2 → P1
Whiteboard: [marionette-fission-mvp][simple]
Pushed by hskupin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fac1844bb15b
[marionette] WebDriver:SwitchToWindow should switch back to the top-level browsing context. r=marionette-reviewers,webdriver-reviewers,maja_zf
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/26288 for changes under testing/web-platform/tests
Whiteboard: [marionette-fission-mvp][simple] → [marionette-fission-mvp][simple], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch

(In reply to Web Platform Test Sync Bot (Matrix: #interop:mozilla.org) from comment #7)

Created web-platform-tests PR
https://github.com/web-platform-tests/wpt/pull/26288 for changes under
testing/web-platform/tests

The requirements sections on the PR still mentions that the patch hasn't been landed on mozilla-central yet. Does it need some kind of trigger?

Flags: needinfo?(james)
Upstream PR merged by moz-wptsync-bot

Maybe that was just a little delay. Merge happened just now.

Flags: needinfo?(james)
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: