diff --git a/tests/WebPlatformSubset/upstream-files.json b/tests/WebPlatformSubset/upstream-files.json index 145216840..9026f2c9a 100644 --- a/tests/WebPlatformSubset/upstream-files.json +++ b/tests/WebPlatformSubset/upstream-files.json @@ -106,6 +106,9 @@ "shadow-dom/Element-interface-shadowRoot-attribute.html": "d4e740808bfd51ae76593b05159943595baa127f7fa205054736c2e8aeef151a", "shadow-dom/HTMLSlotElement-interface.html": "5e15195914e8800dcc6fa6de88aaa184316c42d85fa31eea0190a3eeabb00d60", "shadow-dom/ShadowRoot-interface.html": "2332d49d844c3ac679ba3c4748bfee5d2a508d04763b9813e15666b05a323cf4", - "uievents/order-of-events/focus-events/focus-automated-blink-webkit.html": "8630aec2d53c1b890c205f40e49059b010fae1d729f0b721239f391395b169c1" + "uievents/order-of-events/focus-events/focus-automated-blink-webkit.html": "8630aec2d53c1b890c205f40e49059b010fae1d729f0b721239f391395b169c1", + "webmessaging/Channel_postMessage_clone_port_error.any.js": "48957061b1b6810b1c229c92e66b5dcdd829a8904c14b4460abb406dd75360de", + "webmessaging/message-channels/basics.any.js": "d5d60f5efbc3eb9a026ba44763fb19c2564f6a02a717ff28982e22d52143c69e", + "webmessaging/message-channels/close.any.js": "1ebab07ef56a6fd88b61b4a3af9c4c77d604a2ed950b5bd53d6334c5461895d9" } } diff --git a/tests/WebPlatformSubset/upstream/webmessaging/Channel_postMessage_clone_port_error.any.js b/tests/WebPlatformSubset/upstream/webmessaging/Channel_postMessage_clone_port_error.any.js new file mode 100644 index 000000000..cbee47270 --- /dev/null +++ b/tests/WebPlatformSubset/upstream/webmessaging/Channel_postMessage_clone_port_error.any.js @@ -0,0 +1,14 @@ +// META: title=postMessage() DataCloneError: cloning source port + + var description = "Test Description: Throw a DataCloneError if transfer array in postMessage contains source port."; + + test(function() + { + var channel = new MessageChannel(); + channel.port1.start(); + + assert_throws_dom("DATA_CLONE_ERR", function() + { + channel.port1.postMessage("ports", [channel.port1]); + }); + }, description); diff --git a/tests/WebPlatformSubset/upstream/webmessaging/message-channels/basics.any.js b/tests/WebPlatformSubset/upstream/webmessaging/message-channels/basics.any.js new file mode 100644 index 000000000..5732fb268 --- /dev/null +++ b/tests/WebPlatformSubset/upstream/webmessaging/message-channels/basics.any.js @@ -0,0 +1,12 @@ +// META: title=basic messagechannel test + +async_test(function(t) { + var channel = new MessageChannel(); + channel.port1.postMessage(1); + channel.port2.onmessage = t.step_func( + function(e) { + assert_equals(e.data, 1); + t.done(); + }); + channel.port2.start(); +}); diff --git a/tests/WebPlatformSubset/upstream/webmessaging/message-channels/close.any.js b/tests/WebPlatformSubset/upstream/webmessaging/message-channels/close.any.js new file mode 100644 index 000000000..8741d894b --- /dev/null +++ b/tests/WebPlatformSubset/upstream/webmessaging/message-channels/close.any.js @@ -0,0 +1,62 @@ +// How long (in ms) these tests should wait before deciding no further messages +// will be received. +const time_to_wait_for_messages = 100; + +async_test(t => { + const c = new MessageChannel(); + c.port1.onmessage = t.unreached_func('Should not have delivered message'); + c.port1.close(); + c.port2.postMessage('TEST'); + setTimeout(t.step_func_done(), time_to_wait_for_messages); + }, 'Message sent to closed port should not arrive.'); + +async_test(t => { + const c = new MessageChannel(); + c.port1.onmessage = t.unreached_func('Should not have delivered message'); + c.port2.close(); + c.port2.postMessage('TEST'); + setTimeout(t.step_func_done(), time_to_wait_for_messages); + }, 'Message sent from closed port should not arrive.'); + +async_test(t => { + const c = new MessageChannel(); + c.port1.onmessage = t.unreached_func('Should not have delivered message'); + c.port1.close(); + const c2 = new MessageChannel(); + c2.port1.onmessage = t.step_func(e => { + e.ports[0].postMessage('TESTMSG'); + setTimeout(t.step_func_done(), time_to_wait_for_messages); + }); + c2.port2.postMessage('TEST', [c.port2]); + }, 'Message sent to closed port from transferred port should not arrive.'); + +async_test(t => { + const c = new MessageChannel(); + let isClosed = false; + c.port1.onmessage = t.step_func_done(e => { + assert_true(isClosed); + assert_equals(e.data, 'TEST'); + }); + c.port2.postMessage('TEST'); + c.port2.close(); + isClosed = true; + }, 'Inflight messages should be delivered even when sending port is closed afterwards.'); + +async_test(t => { + const c = new MessageChannel(); + c.port1.onmessage = t.step_func_done(e => { + if (e.data == 'DONE') t.done(); + assert_equals(e.data, 'TEST'); + c.port1.close(); + }); + c.port2.postMessage('TEST'); + c.port2.postMessage('DONE'); + }, 'Close in onmessage should not cancel inflight messages.'); + +test(() => { + const c1 = new MessageChannel(); + const c2 = new MessageChannel(); + c1.port1.close(); + assert_throws_dom("DataCloneError", () => c2.port1.postMessage(null, [c1.port1])); + c2.port1.postMessage(null, [c1.port2]); +}, "close() detaches a MessagePort (but not the one its entangled with)"); diff --git a/tests/WebPlatformSubset/webscene-aureon-runtime-profile.json b/tests/WebPlatformSubset/webscene-aureon-runtime-profile.json index c04ec0854..96a634e91 100644 --- a/tests/WebPlatformSubset/webscene-aureon-runtime-profile.json +++ b/tests/WebPlatformSubset/webscene-aureon-runtime-profile.json @@ -9,6 +9,40 @@ }, "required": [], "candidate": [ + { + "path": "webmessaging/message-channels/basics.any.js", + "type": "testharness", + "capabilities": [ + "window-any-js-harness", + "message-channel", + "message-port-start" + ], + "evidence": ["unchanged-pinned-wpt-messagechannel-basics"], + "reason": "Unchanged pinned WPT proving queued MessageChannel delivery after explicit MessagePort.start()." + }, + { + "path": "webmessaging/Channel_postMessage_clone_port_error.any.js", + "type": "testharness", + "capabilities": [ + "window-any-js-harness", + "messageport-transfer", + "structured-clone-error" + ], + "evidence": ["unchanged-pinned-wpt-messageport-transfer-error"], + "reason": "Unchanged pinned WPT requiring DataCloneError when a MessagePort attempts to transfer itself." + }, + { + "path": "webmessaging/message-channels/close.any.js", + "type": "testharness", + "capabilities": [ + "window-any-js-harness", + "message-port-close", + "messageport-transfer", + "inflight-message-delivery" + ], + "evidence": ["unchanged-pinned-wpt-messageport-close"], + "reason": "Unchanged pinned WPT covering closed-port suppression, transfer rejection, and delivery of messages queued before close()." + }, { "path": "contracts/module-worker-clone.html", "type": "contract",