Skip to content

Commit 5e2beb5

Browse files
committed
Implement messageerror event
https://bugs.webkit.org/show_bug.cgi?id=171216 rdar://96467919 Reviewed by Darin Adler. Implement messageerror event: - whatwg/html#2530 Previously, WebKit would fire a `message` event with its `data` being null, whenever data deserialization would fail. This wasn't as per specification and did not match other browser engines. We're supposed to fire a `messageerror` event instead. This patch addresses the issue. * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-body-window-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-windowless-body-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/wasm/serialization/module/broadcastchannel-success-and-failure-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/wasm/serialization/module/window-sharedworker-failure-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/webmessaging/messageerror-expected.txt: * Source/WebCore/bindings/js/SerializedScriptValue.cpp: (WebCore::SerializedScriptValue::deserialize): * Source/WebCore/bindings/js/SerializedScriptValue.h: * Source/WebCore/dom/BroadcastChannel.cpp: (WebCore::BroadcastChannel::dispatchMessage): * Source/WebCore/dom/MessageEvent.cpp: (WebCore::MessageEvent::create): * Source/WebCore/dom/MessageEvent.h: * Source/WebCore/dom/MessagePort.cpp: (WebCore::MessagePort::dispatchMessages): * Source/WebCore/dom/MessagePort.idl: * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/page/DOMWindow.cpp: (WebCore::DOMWindow::postMessage): * Source/WebCore/page/WindowEventHandlers.idl: * Source/WebCore/workers/DedicatedWorkerGlobalScope.idl: * Source/WebCore/workers/Worker.idl: * Source/WebCore/workers/WorkerMessagingProxy.cpp: (WebCore::WorkerMessagingProxy::postMessageToWorkerObject): (WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope): * Source/WebCore/workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::startMessages): (WebCore::ServiceWorkerContainer::postMessage): * Source/WebCore/workers/service/ServiceWorkerContainer.h: * Source/WebCore/workers/service/context/ServiceWorkerThread.cpp: (WebCore::fireMessageEvent): Canonical link: https://commits.webkit.org/256896@main
1 parent e5968bc commit 5e2beb5

25 files changed

+138
-71
lines changed

LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ PASS HTMLBodyElement interface: attribute onbeforeunload
585585
PASS HTMLBodyElement interface: attribute onhashchange
586586
PASS HTMLBodyElement interface: attribute onlanguagechange
587587
PASS HTMLBodyElement interface: attribute onmessage
588-
FAIL HTMLBodyElement interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
588+
PASS HTMLBodyElement interface: attribute onmessageerror
589589
PASS HTMLBodyElement interface: attribute onoffline
590590
PASS HTMLBodyElement interface: attribute ononline
591591
PASS HTMLBodyElement interface: attribute onpagehide
@@ -609,7 +609,7 @@ PASS HTMLBodyElement interface: document.createElement("body") must inherit prop
609609
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onhashchange" with the proper type
610610
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onlanguagechange" with the proper type
611611
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onmessage" with the proper type
612-
FAIL HTMLBodyElement interface: document.createElement("body") must inherit property "onmessageerror" with the proper type assert_inherits: property "onmessageerror" not found in prototype chain
612+
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onmessageerror" with the proper type
613613
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onoffline" with the proper type
614614
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "ononline" with the proper type
615615
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onpagehide" with the proper type
@@ -4526,7 +4526,7 @@ PASS Window interface: attribute onbeforeunload
45264526
PASS Window interface: attribute onhashchange
45274527
PASS Window interface: attribute onlanguagechange
45284528
PASS Window interface: attribute onmessage
4529-
FAIL Window interface: attribute onmessageerror assert_own_property: The global object must have a property "onmessageerror" expected property "onmessageerror" missing
4529+
PASS Window interface: attribute onmessageerror
45304530
PASS Window interface: attribute onoffline
45314531
PASS Window interface: attribute ononline
45324532
PASS Window interface: attribute onpagehide
@@ -4681,7 +4681,7 @@ PASS Window interface: window must inherit property "onbeforeunload" with the pr
46814681
PASS Window interface: window must inherit property "onhashchange" with the proper type
46824682
PASS Window interface: window must inherit property "onlanguagechange" with the proper type
46834683
PASS Window interface: window must inherit property "onmessage" with the proper type
4684-
FAIL Window interface: window must inherit property "onmessageerror" with the proper type assert_own_property: expected property "onmessageerror" missing
4684+
PASS Window interface: window must inherit property "onmessageerror" with the proper type
46854685
PASS Window interface: window must inherit property "onoffline" with the proper type
46864686
PASS Window interface: window must inherit property "ononline" with the proper type
46874687
PASS Window interface: window must inherit property "onpagehide" with the proper type
@@ -5055,7 +5055,7 @@ PASS MessagePort interface: operation postMessage(any, optional StructuredSerial
50555055
PASS MessagePort interface: operation start()
50565056
PASS MessagePort interface: operation close()
50575057
PASS MessagePort interface: attribute onmessage
5058-
FAIL MessagePort interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
5058+
PASS MessagePort interface: attribute onmessageerror
50595059
PASS BroadcastChannel interface: existence and properties of interface object
50605060
PASS BroadcastChannel interface object length
50615061
PASS BroadcastChannel interface object name
@@ -5080,7 +5080,7 @@ PASS Worker interface: operation terminate()
50805080
PASS Worker interface: operation postMessage(any, sequence<object>)
50815081
PASS Worker interface: operation postMessage(any, optional StructuredSerializeOptions)
50825082
PASS Worker interface: attribute onmessage
5083-
FAIL Worker interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
5083+
PASS Worker interface: attribute onmessageerror
50845084
PASS Worker interface: attribute onerror
50855085
PASS SharedWorker interface: existence and properties of interface object
50865086
PASS SharedWorker interface object length
@@ -5205,7 +5205,7 @@ PASS HTMLFrameSetElement interface: attribute onbeforeunload
52055205
PASS HTMLFrameSetElement interface: attribute onhashchange
52065206
PASS HTMLFrameSetElement interface: attribute onlanguagechange
52075207
PASS HTMLFrameSetElement interface: attribute onmessage
5208-
FAIL HTMLFrameSetElement interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
5208+
PASS HTMLFrameSetElement interface: attribute onmessageerror
52095209
PASS HTMLFrameSetElement interface: attribute onoffline
52105210
PASS HTMLFrameSetElement interface: attribute ononline
52115211
PASS HTMLFrameSetElement interface: attribute onpagehide
@@ -5225,7 +5225,7 @@ PASS HTMLFrameSetElement interface: document.createElement("frameset") must inhe
52255225
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onhashchange" with the proper type
52265226
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onlanguagechange" with the proper type
52275227
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onmessage" with the proper type
5228-
FAIL HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onmessageerror" with the proper type assert_inherits: property "onmessageerror" not found in prototype chain
5228+
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onmessageerror" with the proper type
52295229
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onoffline" with the proper type
52305230
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "ononline" with the proper type
52315231
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onpagehide" with the proper type

LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.worker-expected.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ PASS MessagePort interface: operation postMessage(any, optional StructuredSerial
584584
PASS MessagePort interface: operation start()
585585
PASS MessagePort interface: operation close()
586586
PASS MessagePort interface: attribute onmessage
587-
FAIL MessagePort interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
587+
PASS MessagePort interface: attribute onmessageerror
588588
PASS BroadcastChannel interface: existence and properties of interface object
589589
PASS BroadcastChannel interface object length
590590
PASS BroadcastChannel interface object name
@@ -643,7 +643,7 @@ PASS DedicatedWorkerGlobalScope interface: operation postMessage(any, sequence<o
643643
PASS DedicatedWorkerGlobalScope interface: operation postMessage(any, optional StructuredSerializeOptions)
644644
PASS DedicatedWorkerGlobalScope interface: operation close()
645645
PASS DedicatedWorkerGlobalScope interface: attribute onmessage
646-
FAIL DedicatedWorkerGlobalScope interface: attribute onmessageerror assert_own_property: The global object must have a property "onmessageerror" expected property "onmessageerror" missing
646+
PASS DedicatedWorkerGlobalScope interface: attribute onmessageerror
647647
FAIL DedicatedWorkerGlobalScope interface: operation requestAnimationFrame(FrameRequestCallback) assert_own_property: global object missing non-static operation expected property "requestAnimationFrame" missing
648648
FAIL DedicatedWorkerGlobalScope interface: operation cancelAnimationFrame(unsigned long) assert_own_property: global object missing non-static operation expected property "cancelAnimationFrame" missing
649649
PASS DedicatedWorkerGlobalScope interface: internal [[SetPrototypeOf]] method of global platform object - setting to a new value via Object.setPrototypeOf should throw a TypeError
@@ -661,7 +661,7 @@ PASS DedicatedWorkerGlobalScope interface: self must inherit property "postMessa
661661
PASS DedicatedWorkerGlobalScope interface: calling postMessage(any, optional StructuredSerializeOptions) on self with too few arguments must throw TypeError
662662
PASS DedicatedWorkerGlobalScope interface: self must inherit property "close()" with the proper type
663663
PASS DedicatedWorkerGlobalScope interface: self must inherit property "onmessage" with the proper type
664-
FAIL DedicatedWorkerGlobalScope interface: self must inherit property "onmessageerror" with the proper type assert_own_property: expected property "onmessageerror" missing
664+
PASS DedicatedWorkerGlobalScope interface: self must inherit property "onmessageerror" with the proper type
665665
FAIL DedicatedWorkerGlobalScope interface: self must inherit property "requestAnimationFrame(FrameRequestCallback)" with the proper type assert_own_property: expected property "requestAnimationFrame" missing
666666
FAIL DedicatedWorkerGlobalScope interface: calling requestAnimationFrame(FrameRequestCallback) on self with too few arguments must throw TypeError assert_own_property: expected property "requestAnimationFrame" missing
667667
FAIL DedicatedWorkerGlobalScope interface: self must inherit property "cancelAnimationFrame(unsigned long)" with the proper type assert_own_property: expected property "cancelAnimationFrame" missing
@@ -713,7 +713,7 @@ PASS Worker interface: operation terminate()
713713
PASS Worker interface: operation postMessage(any, sequence<object>)
714714
PASS Worker interface: operation postMessage(any, optional StructuredSerializeOptions)
715715
PASS Worker interface: attribute onmessage
716-
FAIL Worker interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
716+
PASS Worker interface: attribute onmessageerror
717717
PASS Worker interface: attribute onerror
718718
PASS SharedWorker interface: existence and properties of interface object
719719
PASS WorkerNavigator interface: existence and properties of interface object

LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-body-window-expected.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PASS shadowed beforeunload (document.body)
1111
PASS shadowed hashchange (document.body)
1212
PASS shadowed languagechange (document.body)
1313
PASS shadowed message (document.body)
14-
FAIL shadowed messageerror (document.body) assert_equals: alternative body should reflect expected (function) function "() => 0" but got (undefined) undefined
14+
PASS shadowed messageerror (document.body)
1515
PASS shadowed offline (document.body)
1616
PASS shadowed online (document.body)
1717
PASS shadowed pagehide (document.body)
@@ -98,7 +98,7 @@ PASS shadowed beforeunload removal (document.body)
9898
PASS shadowed hashchange removal (document.body)
9999
PASS shadowed languagechange removal (document.body)
100100
PASS shadowed message removal (document.body)
101-
FAIL shadowed messageerror removal (document.body) assert_equals: body should reflect changes to itself expected (object) null but got (undefined) undefined
101+
PASS shadowed messageerror removal (document.body)
102102
PASS shadowed offline removal (document.body)
103103
PASS shadowed online removal (document.body)
104104
PASS shadowed pagehide removal (document.body)
@@ -120,7 +120,7 @@ PASS shadowed beforeunload (document.createElement("body"))
120120
PASS shadowed hashchange (document.createElement("body"))
121121
PASS shadowed languagechange (document.createElement("body"))
122122
PASS shadowed message (document.createElement("body"))
123-
FAIL shadowed messageerror (document.createElement("body")) assert_equals: body should reflect expected (function) function "() => 0" but got (undefined) undefined
123+
PASS shadowed messageerror (document.createElement("body"))
124124
PASS shadowed offline (document.createElement("body"))
125125
PASS shadowed online (document.createElement("body"))
126126
PASS shadowed pagehide (document.createElement("body"))
@@ -207,7 +207,7 @@ PASS shadowed beforeunload removal (document.createElement("body"))
207207
PASS shadowed hashchange removal (document.createElement("body"))
208208
PASS shadowed languagechange removal (document.createElement("body"))
209209
PASS shadowed message removal (document.createElement("body"))
210-
FAIL shadowed messageerror removal (document.createElement("body")) assert_equals: alternative body should reflect changes to itself expected (object) null but got (undefined) undefined
210+
PASS shadowed messageerror removal (document.createElement("body"))
211211
PASS shadowed offline removal (document.createElement("body"))
212212
PASS shadowed online removal (document.createElement("body"))
213213
PASS shadowed pagehide removal (document.createElement("body"))
@@ -229,7 +229,7 @@ PASS shadowed beforeunload (window)
229229
PASS shadowed hashchange (window)
230230
PASS shadowed languagechange (window)
231231
PASS shadowed message (window)
232-
FAIL shadowed messageerror (window) assert_equals: body should reflect expected (function) function "() => 0" but got (undefined) undefined
232+
PASS shadowed messageerror (window)
233233
PASS shadowed offline (window)
234234
PASS shadowed online (window)
235235
PASS shadowed pagehide (window)
@@ -316,7 +316,7 @@ PASS shadowed beforeunload removal (window)
316316
PASS shadowed hashchange removal (window)
317317
PASS shadowed languagechange removal (window)
318318
PASS shadowed message removal (window)
319-
FAIL shadowed messageerror removal (window) assert_equals: window should reflect changes to itself expected (object) null but got (undefined) undefined
319+
PASS shadowed messageerror removal (window)
320320
PASS shadowed offline removal (window)
321321
PASS shadowed online removal (window)
322322
PASS shadowed pagehide removal (window)

LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/event-handler-attributes-windowless-body-expected.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ PASS Return null when getting the languagechange event handler of a windowless b
2323
PASS Ignore setting of languagechange window event handlers on windowless body
2424
PASS Return null when getting the message event handler of a windowless body
2525
PASS Ignore setting of message window event handlers on windowless body
26-
FAIL Return null when getting the messageerror event handler of a windowless body assert_equals: expected (object) null but got (undefined) undefined
27-
FAIL Ignore setting of messageerror window event handlers on windowless body assert_equals: expected (object) null but got (function) function "function () { return "Handler attached to windowless element"; }"
26+
PASS Return null when getting the messageerror event handler of a windowless body
27+
PASS Ignore setting of messageerror window event handlers on windowless body
2828
PASS Return null when getting the offline event handler of a windowless body
2929
PASS Ignore setting of offline window event handlers on windowless body
3030
PASS Return null when getting the online event handler of a windowless body
@@ -132,8 +132,8 @@ PASS Return null when getting the languagechange event handler of a windowless f
132132
PASS Ignore setting of languagechange window event handlers on windowless frameset
133133
PASS Return null when getting the message event handler of a windowless frameset
134134
PASS Ignore setting of message window event handlers on windowless frameset
135-
FAIL Return null when getting the messageerror event handler of a windowless frameset assert_equals: expected (object) null but got (undefined) undefined
136-
FAIL Ignore setting of messageerror window event handlers on windowless frameset assert_equals: expected (object) null but got (function) function "function () { return "Handler attached to windowless element"; }"
135+
PASS Return null when getting the messageerror event handler of a windowless frameset
136+
PASS Ignore setting of messageerror window event handlers on windowless frameset
137137
PASS Return null when getting the offline event handler of a windowless frameset
138138
PASS Ignore setting of offline window event handlers on windowless frameset
139139
PASS Return null when getting the online event handler of a windowless frameset
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11

2-
Harness Error (TIMEOUT), message = null
3-
4-
TIMEOUT WebAssembly.Module cannot cross agent clusters, BroadcastChannel edition Test timed out
2+
PASS WebAssembly.Module cannot cross agent clusters, BroadcastChannel edition
53

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
FAIL WebAssembly.Modules cannot cross agent clusters, shared worker edition assert_unreached: Reached unreachable code
2+
PASS WebAssembly.Modules cannot cross agent clusters, shared worker edition
33

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
FAIL The default value of onmessageerror is null assert_equals: body expected (object) null but got (undefined) undefined
3-
FAIL The onmessageerror content attribute must be compiled into the onmessageerror property assert_equals: The onmessageerror property must be a function expected "function" but got "undefined"
4-
FAIL The onmessageerror content attribute must execute when an event is dispatched on the window assert_true: Dispatching the event must run the code expected true got false
2+
PASS The default value of onmessageerror is null
3+
PASS The onmessageerror content attribute must be compiled into the onmessageerror property
4+
PASS The onmessageerror content attribute must execute when an event is dispatched on the window
55

0 commit comments

Comments
 (0)