Closed Bug 1798655 Opened 7 months ago Closed 6 months ago

A new tab opened with "WebDriver:NewWindow" doesn't get focus when switched to


(Remote Protocol :: Marionette, defect, P1)



(firefox109 fixed)

109 Branch
Tracking Status
firefox109 --- fixed


(Reporter: whimboo, Assigned: whimboo)


(Blocks 1 open bug)


(Whiteboard: [webdriver:m5], [wptsync upstream], [webdriver:relnote] )


(2 files, 1 obsolete file)

With bug 1533058 we are able to create a new tab with about:blank now. But as discovered in bug 1522790 the focus isn't correctly set to for the content browser when using this.window.BrowserOpenTab(). This is most likely the case because it operates on a chrome scope level compared to that runs in content.

As such we should make sure to explicitly focus the content browser in Switch To Window if one is present.

Assignee: nobody → hskupin

The fix here has actually to be located in WebDriver:SwitchToWindow given that with WebDriver:NewWindow we will get a new window but by default it's not the selected one by the driver. Only switching to that new window can actually perform a focus.

Summary: "WebDriver:NewWindow" doesn't focus the content browser when a new tab gets opened → A new tab opened with "WebDriver:NewWindow" doesn't get focus when switched to
Attachment #9301507 - Attachment is obsolete: true

The severity field is not set for this bug.
:whimboo, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(hskupin)

The underlying problem here is actually a race condition which is related to the call to focus() for an element. The affected tests do not actually wait for the focus to be on the element and as such if the window isn't focused yet will fail. Reason is that focus() doesn't await the focus of the window. Mochitests specifically have a promiseFocus helper to make it easier for tests.

Nevertheless I assume that when a new tab gets opened in the foreground the content should get the focus similar to We can put a workaround for now and hope that with bug 1795841 this will be fixed when we will use gBrowser.addTab() directly.

I'll attach a wdspec test for New Window for both type tab and window.

Flags: needinfo?(hskupin)
Blocks: webdriver:m5
Points: --- → 2
Priority: -- → P1
Whiteboard: [webdriver:m5]
Pushed by
[marionette] "WebDriver:SwitchToWindow" has to focus content browser if present. r=webdriver-reviewers,jgraham,jdescottes
[wdspec] Add tests for "New Window" command to ensure that focus is set to content. r=webdriver-reviewers,jdescottes
Created web-platform-tests PR for changes under testing/web-platform/tests
Whiteboard: [webdriver:m5] → [webdriver:m5], [wptsync upstream]
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch
Upstream PR merged by moz-wptsync-bot
Blocks: 1807868
Whiteboard: [webdriver:m5], [wptsync upstream] → [webdriver:m5], [wptsync upstream], [webdriver:relnote]
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.