summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webmessaging/multi-globals/broadcastchannel-current.sub.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/webmessaging/multi-globals/broadcastchannel-current.sub.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webmessaging/multi-globals/broadcastchannel-current.sub.html')
-rw-r--r--testing/web-platform/tests/webmessaging/multi-globals/broadcastchannel-current.sub.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webmessaging/multi-globals/broadcastchannel-current.sub.html b/testing/web-platform/tests/webmessaging/multi-globals/broadcastchannel-current.sub.html
new file mode 100644
index 0000000000..ae2369394e
--- /dev/null
+++ b/testing/web-platform/tests/webmessaging/multi-globals/broadcastchannel-current.sub.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>The current page being cross-origin must prevent the BroadcastChannel message from being seen</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<!-- This is the entry global -->
+
+<iframe src="support/incumbent-document-domain.sub.html" id="incumbent"></iframe>
+<iframe src="http://{{hosts[][www]}}:{{ports[http][0]}}/webmessaging/multi-globals/support/current-document-domain.sub.html" id="current"></iframe>
+
+<script>
+"use strict";
+document.domain = "{{hosts[][]}}";
+
+setup({ explicit_done: true });
+
+const incumbentIframe = document.querySelector("#incumbent");
+const currentIframe = document.querySelector("#current");
+
+window.onload = () => {
+ promise_test(async t => {
+ const createdCrossOrigin = frames[0].createBroadcastChannel("current");
+ const createdSameOrigin = new BroadcastChannel("current");
+
+ createdSameOrigin.onmessage = t.unreached_func("message event fired");
+ createdSameOrigin.onmessageerror = t.unreached_func("messageerror event fired");
+
+ createdCrossOrigin.postMessage("the message");
+
+ // BroadcastChannel messages are guaranteed to be ordered within an event loop, as they all use
+ // the DOM manipulation task source. So, any messages from the "current" channel, if they are
+ // going to be erroneously delivered, would have to be delivered before those from this
+ // channel. I.e., if we recieve a message from this channel without first recieving one from
+ // the "current" channel, then the test passes.
+ const testEnder = new BroadcastChannel("current / test-ender");
+ const testEnder2 = new BroadcastChannel("current / test-ender");
+
+ testEnder.postMessage("end test");
+ await new Promise(resolve => testEnder2.onmessage = resolve);
+ });
+
+ done();
+};
+</script>