summaryrefslogtreecommitdiffstats
path: root/dom/tests/browser/browser_data_document_crossOriginIsolated.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/tests/browser/browser_data_document_crossOriginIsolated.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/tests/browser/browser_data_document_crossOriginIsolated.js')
-rw-r--r--dom/tests/browser/browser_data_document_crossOriginIsolated.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/tests/browser/browser_data_document_crossOriginIsolated.js b/dom/tests/browser/browser_data_document_crossOriginIsolated.js
new file mode 100644
index 0000000000..d38eda3f0a
--- /dev/null
+++ b/dom/tests/browser/browser_data_document_crossOriginIsolated.js
@@ -0,0 +1,68 @@
+"use strict";
+
+const DIRPATH = getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content/",
+ ""
+);
+const PATH = DIRPATH + "file_coop_coep.html";
+
+const ORIGIN = "https://test1.example.com";
+const URL = `${ORIGIN}/${PATH}`;
+
+add_task(async function () {
+ await BrowserTestUtils.withNewTab(URL, async function (browser) {
+ BrowserTestUtils.loadURIString(browser, URL);
+ await BrowserTestUtils.browserLoaded(browser);
+
+ await SpecialPowers.spawn(browser, [ORIGIN], async origin => {
+ is(
+ content.window.origin,
+ origin,
+ `Opened a tab and navigated to ${origin}`
+ );
+
+ ok(
+ content.window.crossOriginIsolated,
+ `Should have been cross-origin-isolated env`
+ );
+
+ let hostIds = [];
+ function createShadowDOMAndTriggerSlotChange(host) {
+ var shadow = host.attachShadow({ mode: "closed" });
+
+ let promise = new Promise(resolve => {
+ shadow.addEventListener("slotchange", function () {
+ hostIds.push(host.id);
+ resolve();
+ });
+ });
+
+ shadow.innerHTML = "<slot></slot>";
+
+ host.appendChild(host.ownerDocument.createElement("span"));
+
+ return promise;
+ }
+
+ let host1 = content.document.getElementById("host1");
+
+ let dataDoc = content.document.implementation.createHTMLDocument();
+ dataDoc.body.innerHTML = "<div id='host2'></div>";
+ let host2 = dataDoc.body.firstChild;
+
+ let host3 = content.document.getElementById("host3");
+
+ let promises = [];
+ promises.push(createShadowDOMAndTriggerSlotChange(host1));
+ promises.push(createShadowDOMAndTriggerSlotChange(host2));
+ promises.push(createShadowDOMAndTriggerSlotChange(host3));
+
+ await Promise.all(promises);
+
+ is(hostIds.length, 3, `Got 3 slot change events`);
+ is(hostIds[0], "host1", `The first one was host1`);
+ is(hostIds[1], "host2", `The second one was host2`);
+ is(hostIds[2], "host3", `The third one was host3`);
+ });
+ });
+});