Closed Bug 2079905 Opened 1 month ago Closed 1 month ago

[WebDriver BiDi] preload scripts channel messages from a window.open popup have no context

Categories

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

Firefox 159
defect
Points:
2

Tracking

(firefox160 fixed)

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: james.h.evans.jr, Assigned: Sasha)

References

Details

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

Attachments

(2 external files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:157.0) Gecko/20100101 Firefox/157.0

Steps to reproduce

Environment: Firefox Nightly 159.0a1, started with firefox --remote-debugging-port 0 --profile <new profile> --headless

Steps to reproduce

  1. Set up a web server to listen on port <port>, and respond to the following paths with the corresponding HTML documents:
  • /before: <!DOCTYPE html><title>Before</title><p>Before</p>
  • /recorded: <!DOCTYPE html><title>Recorded</title><button id="open" onclick="window.open('/popup')" style="width:200px;height:50px">Open</button><iframe src="/frame"></iframe>
  • /frame: <!DOCTYPE html><title>Frame</title><p>Frame</p>
  • /popup: <!DOCTYPE html><title>Popup</title><p>Popup</p>
  1. Let <function> be the following JavaScript function: (send) => { document.addEventListener('click', (event) => send({ kind: 'click', target: event.target.id, trusted: event.isTrusted }), true); send({ kind: 'installed', url: location.href, top: window === window.top }); }

  2. Issue the WebDriver BiDi command session.new with parameters {"capabilities":{}}

  3. Issue the WebDriver BiDi command browsingContext.getTree with parameters {} and extract the browsing context (<context-1> from the response

  4. Issue the WebDriver BiDi command session.subscribe with parameters {"events":["script.message","browsingContext.contextCreated","browsingContext.load"]}

  5. Issue the WebDriver BiDi command browsingContext.navigate with parameters {"context":"<context-1>","url":"http://127.0.0.1:<port>/before","wait":"complete"}

  6. Issue the WebDriver BiDi command script.callFunction with parameters {"functionDeclaration": "<function>", "arguments":[{"type":"channel","value":{"channel":"recorder"}}], "target":{"context":"<context-1>","sandbox":"probe"}}, and verify that one "installed" message arrives.

  7. Issue the WebDriver BiDi command script.addPreloadScript with parameters {"functionDeclaration": "<function>", "arguments":[{"type":"channel","value":{"channel":"recorder"}}], "target":{"context":"<context-1>","sandbox":"probe"}}

  8. Issue the WebDriver BiDi command browsingContext.navigate with parameters {"context":"<context-1>","url":"http://127.0.0.1:<port>/recorded","wait":"complete"}, and verify that "installed" messages arrive from the page and its iframe

  9. Issue the WebDriver BiDi command script.evaluate with parameters {"expression":"document.getElementById('open')","target":{"context":"<context-1>"},"awaitPromise":false} and extract the element shared ID (<sharedId-1>) from the response

  10. Issue the WebDriver BiDi command input.performActions with parameters {"context":"<context-1>","actions":[{"type":"pointer","id":"mouse","actions":[{"type":"pointerMove","x":0,"y":0,"origin":{"type":"element","element":{"sharedId":"<sharedId-1>"}}},{"type":"pointerDown","button":0},{"type":"pointerUp","button":0}]}]} and capture the popup context (<context-2>) from the browsingContext.contextCreated event data

  11. After the popup's browsingContext.load for /popup, issue the WebDriver BiDi command script.evaluate with parameters {"expression":"document.body.id = 'popup-body'; document.body.click()","target":{"context":"<context-2>"},"awaitPromise":false}

Actual results

two messages from the popup's initial documents arrive before its browsingContext.contextCreated, with source.context: null. Nothing arrives from the loaded /popup document, although step 11 succeeds. The same happens with the preload script in the main realm instead of a sandbox.

Expected results

script.message from the popup's documents with source.context set to the popup's browsing context, including the click in its loaded document, as the messages from the opener page and its iframe do.

Assignee: nobody → aborovova
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Severity: -- → S3
Points: --- → 2
Priority: -- → P3
Whiteboard: [webdriver:m22]
Pushed by aborovova@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/948fabd8def9 https://hg.mozilla.org/integration/autoland/rev/1589d32b83dd [webdriver-bidi] Delay sending the "script.message" event until a navigable id is created. r=webdriver-reviewers,jdescottes https://github.com/mozilla-firefox/firefox/commit/9867dd9284ed https://hg.mozilla.org/integration/autoland/rev/a2e7b6e54d7e [wdspec] Add a test for the "script.message" event send from a preload script with a "channel" argument and "window.open". r=webdriver-reviewers,jdescottes
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch

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

Whiteboard: [webdriver:m22] → [webdriver:m22], [wptsync upstream]

Upstream PR merged by moz-wptsync-bot

Whiteboard: [webdriver:m22], [wptsync upstream] → [webdriver:m22], [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: