diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.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/webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative.html')
-rw-r--r-- | testing/web-platform/tests/webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative.html | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative.html b/testing/web-platform/tests/webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative.html new file mode 100644 index 0000000000..de94fb2cf4 --- /dev/null +++ b/testing/web-platform/tests/webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative.html @@ -0,0 +1,75 @@ +<!doctype html> +<meta charset=utf-8> +<title>localStorage: about:blank partitioning</title> +<meta name=help href="https://privacycg.github.io/storage-partitioning/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<script src="/webstorage/resources/partitioning-utils.js"></script> +<body> +<script> +const path = + "webstorage/resources/localstorage-about-blank-partitioned-win-open.html"; +const crossSiteURL = `${get_host_info().HTTP_NOTSAMESITE_ORIGIN}/${path}`; +const sameSiteURL = `${get_host_info().HTTP_ORIGIN}/${path}`; +let firstPartyID = getOrCreateID("userID3"); +let crossSiteIframeID; +let sameSiteIframeID; +let crossSiteIframe; +let crossSiteIframeAboutBlankID; +let frameMessageCount = 0; + +promise_test(async t => { + localStorage.clear(); + + // Step 1. Add a cross-site iframe + return addIframePromise(crossSiteURL).then(async crossSiteIframe => { + return new Promise(resolve => { + window.addEventListener("message", async e => { + const payload = { + command: "open about:blank window" + } + + if (e.data.message === "window loaded") { + // Step 2. cross-site iframe is loaded, capture reference to its ID + crossSiteIframeID = e.data.userID; + // Step 3. Ask the cross-site iframe to create an about:blank window + crossSiteIframe.contentWindow.postMessage(payload, e.origin); + } + + if (e.data.message === "about:blank frame ID") { + // Step 4. capture reference to 3P iframe's about:blank window ID + crossSiteIframeAboutBlankID = e.data.userID; + crossSiteIframe.contentWindow.postMessage( + {command: "close about:blank window"}, "*"); + } + + if (e.data.message === "about:blank window closed") { + resolve({crossSiteIframeID, crossSiteIframeAboutBlankID}); + } + }); + }).then(ids => { + const { + crossSiteIframeID, + crossSiteIframeAboutBlankID + } = ids; + // Step 5. Assert some things + for (let id in ids) { + assert_true(id !== undefined, "id is not undefined"); + } + // Note: we use assert_true, rather than assert_equals becuase we're + // setting random numbers as IDs - this would mean expectations + // files wouldn't work as intended. + assert_true(crossSiteIframeAboutBlankID !== crossSiteIframeID, + "about:blank window opened by 3P iframe does not inherit 3P iframe's StorageKey"); + assert_true(firstPartyID !== crossSiteIframeAboutBlankID, + "about:blank window open by 3P iframe does not inherit 1P StorageKey"); + + localStorage.clear(); + }) + }); + + +}, "StorageKey: test 3P about:blank window opened from a 3P iframe"); +</script> +</body> |