Bug 259362

Summary: window.postMessage with OffscreenCanvas is broken with isolated world message listener
Product: WebKit Reporter: Ali Juma <ajuma>
Component: WebKit APIAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, cdumez, ggaren, mattwoodrow, michaeldo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=254777
Attachments:
Description Flags
Test app none

Ali Juma
Reported 2023-07-20 10:42:39 PDT
Created attachment 467080 [details] Test app Using postMessage with an OffscreenCanvas breaks when there is a `message` event listener in an isolated world, even for main-world event listeners. In practice, this bug causes web-exposed breakage on Chrome for iOS, which injects a `message` event listener into an isolated world as part of implementing browser features. Steps to reproduce (also see the attached test app): 1) In an isolated world (e.g., WKContentWorld.defaultClientWorld) add a trivial `message` event listener that does anything at all with message.data. 2) In the page world, in an iframe, add a `message` event listener 3) In the page world, in the main frame, using a handle to the iframe's contentWindow, call postMessage with an OffscreenCanvas object. Expect result: The iframe's page world event listener successfully receives the message sent in (3). Actual result: The iframe's page world event listener receives `null`. The attached test app demonstrates this bug, using four different message types to better illustrate the expected behavior, showing that postMessage works with Object, ArrayBuffer, and MessagePort, but not with OffscreenCanvas. Bug 254777 fixed the MessagePort case.
Attachments
Test app (93.29 KB, application/zip)
2023-07-20 10:42 PDT, Ali Juma
no flags
Radar WebKit Bug Importer
Comment 1 2023-07-20 13:45:45 PDT
Chris Dumez
Comment 2 2023-07-21 16:10:03 PDT
EWS
Comment 3 2023-07-31 22:22:27 PDT
Committed 266465@main (acece69bd261): <https://commits.webkit.org/266465@main> Reviewed commits have been landed. Closing PR #16003 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.