Skip to content

Commit

Permalink
Implement messageerror event
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cdumez committed Nov 20, 2022
1 parent e5968bc commit 5e2beb5
Show file tree
Hide file tree
Showing 25 changed files with 138 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ PASS HTMLBodyElement interface: attribute onbeforeunload
PASS HTMLBodyElement interface: attribute onhashchange
PASS HTMLBodyElement interface: attribute onlanguagechange
PASS HTMLBodyElement interface: attribute onmessage
FAIL HTMLBodyElement interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
PASS HTMLBodyElement interface: attribute onmessageerror
PASS HTMLBodyElement interface: attribute onoffline
PASS HTMLBodyElement interface: attribute ononline
PASS HTMLBodyElement interface: attribute onpagehide
Expand All @@ -609,7 +609,7 @@ PASS HTMLBodyElement interface: document.createElement("body") must inherit prop
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onhashchange" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onlanguagechange" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onmessage" with the proper type
FAIL HTMLBodyElement interface: document.createElement("body") must inherit property "onmessageerror" with the proper type assert_inherits: property "onmessageerror" not found in prototype chain
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onmessageerror" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onoffline" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "ononline" with the proper type
PASS HTMLBodyElement interface: document.createElement("body") must inherit property "onpagehide" with the proper type
Expand Down Expand Up @@ -4526,7 +4526,7 @@ PASS Window interface: attribute onbeforeunload
PASS Window interface: attribute onhashchange
PASS Window interface: attribute onlanguagechange
PASS Window interface: attribute onmessage
FAIL Window interface: attribute onmessageerror assert_own_property: The global object must have a property "onmessageerror" expected property "onmessageerror" missing
PASS Window interface: attribute onmessageerror
PASS Window interface: attribute onoffline
PASS Window interface: attribute ononline
PASS Window interface: attribute onpagehide
Expand Down Expand Up @@ -4681,7 +4681,7 @@ PASS Window interface: window must inherit property "onbeforeunload" with the pr
PASS Window interface: window must inherit property "onhashchange" with the proper type
PASS Window interface: window must inherit property "onlanguagechange" with the proper type
PASS Window interface: window must inherit property "onmessage" with the proper type
FAIL Window interface: window must inherit property "onmessageerror" with the proper type assert_own_property: expected property "onmessageerror" missing
PASS Window interface: window must inherit property "onmessageerror" with the proper type
PASS Window interface: window must inherit property "onoffline" with the proper type
PASS Window interface: window must inherit property "ononline" with the proper type
PASS Window interface: window must inherit property "onpagehide" with the proper type
Expand Down Expand Up @@ -5055,7 +5055,7 @@ PASS MessagePort interface: operation postMessage(any, optional StructuredSerial
PASS MessagePort interface: operation start()
PASS MessagePort interface: operation close()
PASS MessagePort interface: attribute onmessage
FAIL MessagePort interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
PASS MessagePort interface: attribute onmessageerror
PASS BroadcastChannel interface: existence and properties of interface object
PASS BroadcastChannel interface object length
PASS BroadcastChannel interface object name
Expand All @@ -5080,7 +5080,7 @@ PASS Worker interface: operation terminate()
PASS Worker interface: operation postMessage(any, sequence<object>)
PASS Worker interface: operation postMessage(any, optional StructuredSerializeOptions)
PASS Worker interface: attribute onmessage
FAIL Worker interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
PASS Worker interface: attribute onmessageerror
PASS Worker interface: attribute onerror
PASS SharedWorker interface: existence and properties of interface object
PASS SharedWorker interface object length
Expand Down Expand Up @@ -5205,7 +5205,7 @@ PASS HTMLFrameSetElement interface: attribute onbeforeunload
PASS HTMLFrameSetElement interface: attribute onhashchange
PASS HTMLFrameSetElement interface: attribute onlanguagechange
PASS HTMLFrameSetElement interface: attribute onmessage
FAIL HTMLFrameSetElement interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
PASS HTMLFrameSetElement interface: attribute onmessageerror
PASS HTMLFrameSetElement interface: attribute onoffline
PASS HTMLFrameSetElement interface: attribute ononline
PASS HTMLFrameSetElement interface: attribute onpagehide
Expand All @@ -5225,7 +5225,7 @@ PASS HTMLFrameSetElement interface: document.createElement("frameset") must inhe
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onhashchange" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onlanguagechange" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onmessage" with the proper type
FAIL HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onmessageerror" with the proper type assert_inherits: property "onmessageerror" not found in prototype chain
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onmessageerror" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onoffline" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "ononline" with the proper type
PASS HTMLFrameSetElement interface: document.createElement("frameset") must inherit property "onpagehide" with the proper type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ PASS MessagePort interface: operation postMessage(any, optional StructuredSerial
PASS MessagePort interface: operation start()
PASS MessagePort interface: operation close()
PASS MessagePort interface: attribute onmessage
FAIL MessagePort interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
PASS MessagePort interface: attribute onmessageerror
PASS BroadcastChannel interface: existence and properties of interface object
PASS BroadcastChannel interface object length
PASS BroadcastChannel interface object name
Expand Down Expand Up @@ -643,7 +643,7 @@ PASS DedicatedWorkerGlobalScope interface: operation postMessage(any, sequence<o
PASS DedicatedWorkerGlobalScope interface: operation postMessage(any, optional StructuredSerializeOptions)
PASS DedicatedWorkerGlobalScope interface: operation close()
PASS DedicatedWorkerGlobalScope interface: attribute onmessage
FAIL DedicatedWorkerGlobalScope interface: attribute onmessageerror assert_own_property: The global object must have a property "onmessageerror" expected property "onmessageerror" missing
PASS DedicatedWorkerGlobalScope interface: attribute onmessageerror
FAIL DedicatedWorkerGlobalScope interface: operation requestAnimationFrame(FrameRequestCallback) assert_own_property: global object missing non-static operation expected property "requestAnimationFrame" missing
FAIL DedicatedWorkerGlobalScope interface: operation cancelAnimationFrame(unsigned long) assert_own_property: global object missing non-static operation expected property "cancelAnimationFrame" missing
PASS DedicatedWorkerGlobalScope interface: internal [[SetPrototypeOf]] method of global platform object - setting to a new value via Object.setPrototypeOf should throw a TypeError
Expand All @@ -661,7 +661,7 @@ PASS DedicatedWorkerGlobalScope interface: self must inherit property "postMessa
PASS DedicatedWorkerGlobalScope interface: calling postMessage(any, optional StructuredSerializeOptions) on self with too few arguments must throw TypeError
PASS DedicatedWorkerGlobalScope interface: self must inherit property "close()" with the proper type
PASS DedicatedWorkerGlobalScope interface: self must inherit property "onmessage" with the proper type
FAIL DedicatedWorkerGlobalScope interface: self must inherit property "onmessageerror" with the proper type assert_own_property: expected property "onmessageerror" missing
PASS DedicatedWorkerGlobalScope interface: self must inherit property "onmessageerror" with the proper type
FAIL DedicatedWorkerGlobalScope interface: self must inherit property "requestAnimationFrame(FrameRequestCallback)" with the proper type assert_own_property: expected property "requestAnimationFrame" missing
FAIL DedicatedWorkerGlobalScope interface: calling requestAnimationFrame(FrameRequestCallback) on self with too few arguments must throw TypeError assert_own_property: expected property "requestAnimationFrame" missing
FAIL DedicatedWorkerGlobalScope interface: self must inherit property "cancelAnimationFrame(unsigned long)" with the proper type assert_own_property: expected property "cancelAnimationFrame" missing
Expand Down Expand Up @@ -713,7 +713,7 @@ PASS Worker interface: operation terminate()
PASS Worker interface: operation postMessage(any, sequence<object>)
PASS Worker interface: operation postMessage(any, optional StructuredSerializeOptions)
PASS Worker interface: attribute onmessage
FAIL Worker interface: attribute onmessageerror assert_true: The prototype object must have a property "onmessageerror" expected true got false
PASS Worker interface: attribute onmessageerror
PASS Worker interface: attribute onerror
PASS SharedWorker interface: existence and properties of interface object
PASS WorkerNavigator interface: existence and properties of interface object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PASS shadowed beforeunload (document.body)
PASS shadowed hashchange (document.body)
PASS shadowed languagechange (document.body)
PASS shadowed message (document.body)
FAIL shadowed messageerror (document.body) assert_equals: alternative body should reflect expected (function) function "() => 0" but got (undefined) undefined
PASS shadowed messageerror (document.body)
PASS shadowed offline (document.body)
PASS shadowed online (document.body)
PASS shadowed pagehide (document.body)
Expand Down Expand Up @@ -98,7 +98,7 @@ PASS shadowed beforeunload removal (document.body)
PASS shadowed hashchange removal (document.body)
PASS shadowed languagechange removal (document.body)
PASS shadowed message removal (document.body)
FAIL shadowed messageerror removal (document.body) assert_equals: body should reflect changes to itself expected (object) null but got (undefined) undefined
PASS shadowed messageerror removal (document.body)
PASS shadowed offline removal (document.body)
PASS shadowed online removal (document.body)
PASS shadowed pagehide removal (document.body)
Expand All @@ -120,7 +120,7 @@ PASS shadowed beforeunload (document.createElement("body"))
PASS shadowed hashchange (document.createElement("body"))
PASS shadowed languagechange (document.createElement("body"))
PASS shadowed message (document.createElement("body"))
FAIL shadowed messageerror (document.createElement("body")) assert_equals: body should reflect expected (function) function "() => 0" but got (undefined) undefined
PASS shadowed messageerror (document.createElement("body"))
PASS shadowed offline (document.createElement("body"))
PASS shadowed online (document.createElement("body"))
PASS shadowed pagehide (document.createElement("body"))
Expand Down Expand Up @@ -207,7 +207,7 @@ PASS shadowed beforeunload removal (document.createElement("body"))
PASS shadowed hashchange removal (document.createElement("body"))
PASS shadowed languagechange removal (document.createElement("body"))
PASS shadowed message removal (document.createElement("body"))
FAIL shadowed messageerror removal (document.createElement("body")) assert_equals: alternative body should reflect changes to itself expected (object) null but got (undefined) undefined
PASS shadowed messageerror removal (document.createElement("body"))
PASS shadowed offline removal (document.createElement("body"))
PASS shadowed online removal (document.createElement("body"))
PASS shadowed pagehide removal (document.createElement("body"))
Expand All @@ -229,7 +229,7 @@ PASS shadowed beforeunload (window)
PASS shadowed hashchange (window)
PASS shadowed languagechange (window)
PASS shadowed message (window)
FAIL shadowed messageerror (window) assert_equals: body should reflect expected (function) function "() => 0" but got (undefined) undefined
PASS shadowed messageerror (window)
PASS shadowed offline (window)
PASS shadowed online (window)
PASS shadowed pagehide (window)
Expand Down Expand Up @@ -316,7 +316,7 @@ PASS shadowed beforeunload removal (window)
PASS shadowed hashchange removal (window)
PASS shadowed languagechange removal (window)
PASS shadowed message removal (window)
FAIL shadowed messageerror removal (window) assert_equals: window should reflect changes to itself expected (object) null but got (undefined) undefined
PASS shadowed messageerror removal (window)
PASS shadowed offline removal (window)
PASS shadowed online removal (window)
PASS shadowed pagehide removal (window)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ PASS Return null when getting the languagechange event handler of a windowless b
PASS Ignore setting of languagechange window event handlers on windowless body
PASS Return null when getting the message event handler of a windowless body
PASS Ignore setting of message window event handlers on windowless body
FAIL Return null when getting the messageerror event handler of a windowless body assert_equals: expected (object) null but got (undefined) undefined
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"; }"
PASS Return null when getting the messageerror event handler of a windowless body
PASS Ignore setting of messageerror window event handlers on windowless body
PASS Return null when getting the offline event handler of a windowless body
PASS Ignore setting of offline window event handlers on windowless body
PASS Return null when getting the online event handler of a windowless body
Expand Down Expand Up @@ -132,8 +132,8 @@ PASS Return null when getting the languagechange event handler of a windowless f
PASS Ignore setting of languagechange window event handlers on windowless frameset
PASS Return null when getting the message event handler of a windowless frameset
PASS Ignore setting of message window event handlers on windowless frameset
FAIL Return null when getting the messageerror event handler of a windowless frameset assert_equals: expected (object) null but got (undefined) undefined
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"; }"
PASS Return null when getting the messageerror event handler of a windowless frameset
PASS Ignore setting of messageerror window event handlers on windowless frameset
PASS Return null when getting the offline event handler of a windowless frameset
PASS Ignore setting of offline window event handlers on windowless frameset
PASS Return null when getting the online event handler of a windowless frameset
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

Harness Error (TIMEOUT), message = null

TIMEOUT WebAssembly.Module cannot cross agent clusters, BroadcastChannel edition Test timed out
PASS WebAssembly.Module cannot cross agent clusters, BroadcastChannel edition

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

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

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

FAIL The default value of onmessageerror is null assert_equals: body expected (object) null but got (undefined) undefined
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"
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
PASS The default value of onmessageerror is null
PASS The onmessageerror content attribute must be compiled into the onmessageerror property
PASS The onmessageerror content attribute must execute when an event is dispatched on the window

Loading

0 comments on commit 5e2beb5

Please sign in to comment.