Bug 272967 - messageerror event doesn't fire on ServiceWorkerGlobalScope
Summary: messageerror event doesn't fire on ServiceWorkerGlobalScope
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar, WPTImpact
Depends on:
Blocks:
 
Reported: 2024-04-19 02:30 PDT by Philip Jägenstedt
Modified: 2024-05-06 10:02 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Jägenstedt 2024-04-19 02:30:07 PDT
Disclaimer: I'm not totally sure about the root cause here, but something needs fixing either in WebKit, WPT, or BCD.

In BCD, the messageerror event for ServiceWorkerGlobalScope is marked as partially supported in Safari, because the event never fires:
https://github.com/mdn/browser-compat-data/blob/7752b0a038a04ee47f112e696706bd53a589b0c6/api/ServiceWorkerGlobalScope.json#L617

That refers to https://bugs.webkit.org/show_bug.cgi?id=171216, which is closed as fixed. But from the patch it's not easy to tell if the event actually fires now or not.

Turning to WPT, this test failure suggests that the event doesn't fire:
https://wpt.fyi/results/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-serviceworker-failure.https.html?run_id=5176510071177216&run_id=5153332145946624&run_id=5195972581261312&run_id=5076778648862720

The failure message points to this line of the test being reached:
https://github.com/web-platform-tests/wpt/blob/1cafd038c989f47a1e136844d09ca85a06f85ce0/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/serviceworker-failure.js#L16C27-L16C55

So my best guess is that WebKit doesn't fire the messageerror event on ServiceWorkerGlobalScope, and instead fires a message event with data being set to null.
Comment 1 Radar WebKit Bug Importer 2024-04-26 02:31:17 PDT
<rdar://problem/127104436>
Comment 2 Ahmad Saleem 2024-04-26 03:02:14 PDT
We do have following FIXME:

FIXME: Add support for messageerror event when message deserialization fails.

https://searchfox.org/wubkat/rev/53d24706292c592556c5991a08e75e3066495105/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp#149
Comment 3 youenn fablet 2024-05-01 01:48:48 PDT
Pull request: https://github.com/WebKit/WebKit/pull/27974
Comment 4 youenn fablet 2024-05-01 01:49:23 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/46003
Comment 5 EWS 2024-05-06 10:02:51 PDT
Committed 278408@main (fddda893fc92): <https://commits.webkit.org/278408@main>

Reviewed commits have been landed. Closing PR #27974 and removing active labels.