Closed Bug 1798655 Opened 1 year ago Closed 1 year ago

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

Categories

(Remote Protocol :: Marionette, defect, P1)

Default
defect
Points:
2

Tracking

(firefox109 fixed)

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: whimboo, Assigned: whimboo)

References

(Blocks 1 open bug)

Details

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

Attachments

(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 window.open() 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
Status: NEW → ASSIGNED

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 window.open(). 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 hskupin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/032cab48a165
[marionette] "WebDriver:SwitchToWindow" has to focus content browser if present. r=webdriver-reviewers,jgraham,jdescottes
https://hg.mozilla.org/integration/autoland/rev/2781784fdc50
[wdspec] Add tests for "New Window" command to ensure that focus is set to content. r=webdriver-reviewers,jdescottes
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/37192 for changes under testing/web-platform/tests
Whiteboard: [webdriver:m5] → [webdriver:m5], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch
Upstream PR merged by moz-wptsync-bot
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.

Attachment

General

Created:
Updated:
Size: