Closed Bug 2002721 Opened 1 month ago Closed 1 month ago

Missing script.realmCreated event for new browsing contexts

Categories

(Remote Protocol :: WebDriver BiDi, defect, P2)

defect
Points:
3

Tracking

(firefox147 fixed)

RESOLVED FIXED
147 Branch
Tracking Status
firefox147 --- fixed

People

(Reporter: hbenl, Assigned: Sasha)

References

(Blocks 1 open bug)

Details

(Whiteboard: [webdriver:m18][wptsync upstream][webdriver:relnote])

Attachments

(2 files)

Some Playwright tests (like this one) recently regressed because Firefox is no longer sending the script.realmCreated event for all new BrowsingContexts (I haven't yet figured out the exact circumstances when this happens). Due to that, evaluations for those BrowsingContexts hang in Playwright and console messages from them are ignored.
Since the regression started on 2025-11-25, I suspect Bug 543435 to be the cause.

Do we not run any of those tests in CI? If not, could we?

Assignee: nobody → aborovova
Status: NEW → ASSIGNED

I've created the wdspec test to illustrate the issue.

It looks like the problem is that DOMWindowCreated event now gets dispatched for window.open very early, and this event leads to an attempt to send script.realmCreated event. But when we try to send the event, we can not do it because the browser element is not attached yet to the browsing context, and we need it to get the browsing context id. And because we can not get the browsing context id, we can not send the event.

So shortly, DOMWindowCreated event is sent before browser element gets attached to browsing context and that's an issue for us at the moment.

So we probably should wait until the browsing context has been created. Also we need to keep in mind that we should first send browsingContext.contextCreated before script.realmCreated because a realm cannot exist without a browsing context (window).

Status: ASSIGNED → NEW
Assignee: aborovova → nobody
Points: --- → 3
Priority: -- → P2
Whiteboard: [webdriver:m18]
Assignee: nobody → aborovova
Status: NEW → ASSIGNED

FWIW I just noticed (looking at this passing Playwright test) that Firefox sends the script.realmCreated event if the BrowsingContext was opened using window.open(url, null, 'noopener') but not when it was opened with window.open(url).
Likewise, clicking <a target=_blank rel=noopener href="..."> will send that event but clicking <a target=_blank rel=opener href="..."> won't.

Pushed by aborovova@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/47a9b982fe0f https://hg.mozilla.org/integration/autoland/rev/7c2b2271280c [webdriver-bidi] Make sure that "script.realmCreated" event is sent after a browser element is attached to a browser context. r=jdescottes https://github.com/mozilla-firefox/firefox/commit/b40460c1fc66 https://hg.mozilla.org/integration/autoland/rev/f1daec7ab2cd [wdspec] Add a test for "script.realmCreated" event for window.open. r=jdescottes
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 147 Branch
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/56529 for changes under testing/web-platform/tests
Whiteboard: [webdriver:m18] → [webdriver:m18], [wptsync upstream]
Upstream PR merged by moz-wptsync-bot
Severity: -- → S3
Whiteboard: [webdriver:m18], [wptsync upstream] → [webdriver:m18][wptsync upstream][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: