Closed Bug 1335085 Opened 7 years ago Closed 4 years ago

"WebDriver:SwitchToWindow" has to wait for the "activate" and "focus" events before returning


(Remote Protocol :: Marionette, defect, P1)

Version 3


(firefox68 fixed, firefox69 fixed)

Tracking Status
firefox68 --- fixed
firefox69 --- fixed


(Reporter: whimboo, Assigned: whimboo)


(Depends on 1 open bug, Blocks 1 open bug)



(3 files)

While writing the patch for 1124604 I noticed a case where Marionette fails to correctly focus a window/tab. While the current handles are updated correctly, the focus doesn't change. Which means we operate with the tab in the background.

The steps for the test are:
* Open a new tab
* Switch to this tab
* Open a new window
* Switch to the tab in the new window
* Switch back to the second tab in the first window

With the last step the focus doesn't change.

For now I will exclude this specific test from my patch on bug 1124604.
Priority: -- → P3
This is actually a race because the command doesn't wait until the target window has focus and is activated. My patch on bug 1504756 will add a couple of helpers which will make those checks easier to perform.
Blocks: webdriver
Depends on: 1504756
Summary: Under some conditions switch_to_window() does not focus the window/tab even requested so → "WebDriver:SwitchToWindow" has to wait for the "activate" and "focus" events before returning
Blocks: 1504201
Blocks: 1511875
Blocks: 1214191
Blocks: 1305822
Blocks: 1499082

To remove the race condition which can result in intermittent failures we should get this bug fixed. Also because it has visibility through geckodriver.

Assignee: nobody → hskupin
Priority: P3 → P1

Selecting a different tab is asynchronous, and as such Marionette has
to wait for the "TabSelect" event to be emitted. Further the chrome
window also needs to be focused.

Depends on D33689

Pushed by
[marionette] Make use of "WebDriver:NewWindow" in firefox-puppeteer. r=webdriver-reviewers,ato
[marionette] Fix "WebDriver:SwitchToWindow" for tab and window focus switching. r=webdriver-reviewers,ato
[marionette] Simplify focus handling for window classes in firefox-puppeteer. r=webdriver-reviewers,ato

I would like to keep it on the radar for the Firefox 68 release, given that it massively improves the stability and reduces the risk of race conditions. If there are no regressions in the next couple of days, lets get it uplifted to beta.

Blocks: 1330560
Blocks: 1511970
No longer blocks: 1511970
Depends on: 1557232
Blocks: 1535598
Whiteboard: [

I haven't seen any regressions from landing this patch on mozilla-central. To improve the reliability of Marionette and external tools like Selenium using geckodriver I would like to see this test-only patch uplifted to beta for the ESR release. Thanks.

Whiteboard: [ → [checkin-needed-beta]
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.