diff options
Diffstat (limited to 'testing/web-platform/tests/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html')
-rw-r--r-- | testing/web-platform/tests/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/testing/web-platform/tests/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html b/testing/web-platform/tests/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html index 8c30973416..a9247a0002 100644 --- a/testing/web-platform/tests/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html +++ b/testing/web-platform/tests/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html @@ -5,7 +5,10 @@ <script src="/storage-access-api/helpers.js"></script> <body> <script> -(async function() { +window.addEventListener("message", async (e) => { + if (e.data != "blessed") { + return; + } test_driver.set_test_context(window.top); const type = (new URLSearchParams(window.location.search)).get("type"); const id = (new URLSearchParams(window.location.search)).get("id"); @@ -14,14 +17,18 @@ try { await MaybeSetStorageAccess("*", "*", "blocked"); await test_driver.set_permission({ name: 'storage-access' }, 'granted'); - let hasUnpartitionedCookieAccess = await document.hasUnpartitionedCookieAccess(); - if (hasUnpartitionedCookieAccess) { - message = "First-party cookies should not be readable before handle is loaded."; + if (type == "cookies") { + let hasUnpartitionedCookieAccess = await document.hasUnpartitionedCookieAccess(); + if (hasUnpartitionedCookieAccess) { + message = "First-party cookies should not be readable before handle is loaded."; + } } - const handle = await document.requestStorageAccess({all: true}); - hasUnpartitionedCookieAccess = await document.hasUnpartitionedCookieAccess(); - if (!hasUnpartitionedCookieAccess) { - message = "First-party cookies should be readable after handle is loaded."; + const handle = await test_driver.bless("fake user interaction", () => document.requestStorageAccess({all: true})); + if (type == "cookies") { + hasUnpartitionedCookieAccess = await document.hasUnpartitionedCookieAccess(); + if (!hasUnpartitionedCookieAccess) { + message = "First-party cookies should be readable after handle is loaded."; + } } switch (type) { case "none": { @@ -108,6 +115,12 @@ channel.close(); break; } + case "SharedWorker": { + const shared_worker = handle.SharedWorker("/storage-access-api/resources/shared-worker-relay.js", id); + shared_worker.port.start(); + shared_worker.port.postMessage("Cross-origin handle access"); + break; + } default: { message = "Unexpected type " + type; break; @@ -119,13 +132,14 @@ await MaybeSetStorageAccess("*", "*", "allowed"); await test_driver.set_permission({ name: 'storage-access' }, 'prompt'); if (message) { - window.top.postMessage(message, "*"); + window.top.postMessage({type: "result", message: message}, "*"); return; } // Step 5 (storage-access-api/storage-access-beyond-cookies.{}.tentative.sub.https.html) let iframe = document.createElement("iframe"); iframe.src = "https://{{hosts[][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe-iframe.html?type=" + type + "&id=" + id; document.body.appendChild(iframe); -})(); +}); +window.open("https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/bless_cross_site_permissions.html"); </script> </body> |