summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webmessaging/Channel_postMessage_transfer_xsite_incoming_messages.window.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/webmessaging/Channel_postMessage_transfer_xsite_incoming_messages.window.js
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webmessaging/Channel_postMessage_transfer_xsite_incoming_messages.window.js')
-rw-r--r--testing/web-platform/tests/webmessaging/Channel_postMessage_transfer_xsite_incoming_messages.window.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webmessaging/Channel_postMessage_transfer_xsite_incoming_messages.window.js b/testing/web-platform/tests/webmessaging/Channel_postMessage_transfer_xsite_incoming_messages.window.js
new file mode 100644
index 0000000000..23237ae155
--- /dev/null
+++ b/testing/web-platform/tests/webmessaging/Channel_postMessage_transfer_xsite_incoming_messages.window.js
@@ -0,0 +1,32 @@
+// META: script=/common/get-host-info.sub.js
+
+async_test(function(t) {
+ var channel1 = new MessageChannel();
+ var host = get_host_info();
+ let iframe = document.createElement('iframe');
+ iframe.src = host.HTTP_NOTSAMESITE_ORIGIN + "/webmessaging/support/ChildWindowPostMessage.htm";
+ document.body.appendChild(iframe);
+ var TARGET = document.querySelector("iframe").contentWindow;
+ iframe.onload = t.step_func(function() {
+ // Enable the port.
+ channel1.port1.onmessage = t.step_func(function (evt) {
+ assert_equals(Number(evt.data), 0);
+
+ // Send a message, expecting it to be received in the iframe.
+ channel1.port2.postMessage(1)
+
+ // Transfer the port.
+ TARGET.postMessage("ports", "*", [channel1.port1]);
+ });
+
+ // Send a message, expecting it to be received here.
+ channel1.port2.postMessage(0)
+
+ channel1.port2.onmessage = t.step_func(function (evt) {
+ assert_equals(Number(evt.data), 1);
+ t.done();
+ });
+ });
+}, `Tasks enqueued on the port-message-queue of an enabled port,
+ are transferred along with the port, when the transfer happens in the same task
+ during which postMessage is called`);