Closed Bug 2095256 Opened 10 days ago Closed 8 days ago

[wpt-sync] Sync PR 65071 - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=331066

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
163 Branch
Tracking Status
firefox163 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 65071 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/65071
Details from upstream follow.

Ahmad Saleem <ahmad.saleem792+github@gmail.com> wrote:

WebKit export of https://bugs.webkit.org/show_bug.cgi?id=331066

WebKit export from bug: MessagePort.<!---->postMessage(<!---->)<!----> throws DataCloneError when transferring its own entangled port

<pre>
MessagePort.postMessage() throws DataCloneError when transferring its own entangled port

Per <a href="https://html.spec.whatwg.org/multipage/web-messaging.html#message-port-post-message-steps">https://html.spec.whatwg.org/multipage/web-messaging.html#message-port-post-message-steps</a>:

  1. If transfer contains sourcePort, then throw a "DataCloneError" DOMException.
  2. Let doomed be false.
  3. If targetPort is not null and transfer contains targetPort, then set doomed
    to true and optionally report to a developer console that the target port
    was posted to itself, causing the communication channel to be lost.
  4. Let serializeWithTransferResult be StructuredSerializeWithTransfer(message,
    transfer). Rethrow any exceptions.
  5. If targetPort is null, or if doomed is true, then return.

WebKit threw a "DataCloneError" both when transfer contained sourcePort and
when it contained targetPort. Chrome and Firefox follow the spec. They don't
throw for targetPort; they detach it and drop the message.

This patch makes MessagePort::postMessage() follow the spec steps in order.
The check for sourcePort (step 2) now happens before serialization. A
transfer list containing targetPort sets doomed (step 4) and logs a console
warning. After serialization detaches the transferred ports (step 5), a
doomed message is not posted (step 6). The ports it carried are closed so
the MessagePortChannelProvider doesn't keep them as in transit.

WebKit-Bug: <a href="https://bugs.webkit.org/show_bug.cgi?id=331066">https://bugs.webkit.org/show_bug.cgi?id=331066</a>
WebKit-Canonical-Link: <a href="https://commits.webkit.org/326479@main">https://commits.webkit.org/326479@main</a>
</pre>

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

Ran 0 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 2 tests and 3 subtests

Status Summary

Firefox

OK : 2
PASS: 6

Chrome

OK : 2
PASS: 6

Safari

OK : 2
FAIL: 6

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Status: NEW → RESOLVED
Closed: 8 days ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch
You need to log in before you can comment on or make changes to this bug.