Files
sousa-gecko/testing/web-platform/tests/storage-access-api/storage-access-beyond-cookies.SharedWorker.sub.https.window.js
T
Ari Chivukula 3af6b0f929 Bug 1948970 [wpt PR 50771] - [SAA] Fix beyond-cookies test, a=testonly
Automatic update from web-platform-tests
[SAA] Fix beyond-cookies test

There seems to be an issue where SameSite=None cookies aren't included
on fetches in the shared workers, but this is inconsistent depending
on which shell is used. For now, let's just clean up the expectation so
we test the core elements of the API at least.

Change-Id: I856a1dc142f3ba23f305f1866eee787f98a42d23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6270140
Reviewed-by: Chris Fredrickson <cfredric@chromium.org>
Auto-Submit: Ari Chivukula <arichiv@chromium.org>
Commit-Queue: Ari Chivukula <arichiv@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1421419}

--

wpt-commits: ce49a422e539164e3dd660137763c6f01bc4dae1
wpt-pr: 50771
2025-02-26 08:46:04 +00:00

46 lines
2.3 KiB
JavaScript

// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
'use strict';
// Here's the set-up for this test:
// Step 1 (top-frame) Set up fallback failure listener for if the handle cannot be used.
// Step 2 (top-frame) Set up relay worker to expect "Same-origin handle access".
// Step 3 (top-frame) Set cookies and embed an iframe that's cross-site with top-frame.
// Step 4 (sub-frame) Try to use storage access API to access shared worker.
// Step 5 (sub-frame) Embed an iframe that's same-origin with top-frame.
// Step 6 (sub-sub-frame) Try to use storage access API to access first-party shared worker.
// Step 7 (sub-sub-frame) Send "HasAccess for SharedWorker" message to top-frame.
// Step 8 (top-frame) Set up cookie worker to expect it's already opened.
async_test(t => {
// Step 1
window.addEventListener("message", t.step_func(e => {
if (e.data.type != "result") {
return;
}
assert_equals(e.data.message, "HasAccess for SharedWorker", "Storage Access API should be accessible and return first-party data");
}));
// Step 2
const id = Date.now();
const relay_worker = new SharedWorker("/storage-access-api/resources/shared-worker-relay.js", {name: id, sameSiteCookies: 'none'});
relay_worker.port.onmessage = t.step_func(e => {
assert_equals(e.data, "Same-origin handle access", "Relay worker should divert messages here");
// Step 8
const cookie_worker = new SharedWorker("/storage-access-api/resources/shared-worker-cookies.py", {name: id, sameSiteCookies: 'none'});
cookie_worker.port.onmessage = t.step_func((e) => {
assert_equals(e.data, "ReadOnLoad:None,ReadOnFetch:None,ConnectionsMade:2", "Worker should already have been opened and only see SameSite=None cookies");
test_driver.delete_all_cookies().then(() => t.done());
});
});
// Step 3
const cookie_set_window = window.open("/storage-access-api/resources/set_cookies.py");
cookie_set_window.onload = t.step_func(_ => {
let iframe = document.createElement("iframe");
iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/storage-access-api/resources/storage-access-beyond-cookies-iframe.sub.html?type=SharedWorker&id="+id;
document.body.appendChild(iframe);
});
}, "Verify StorageAccessAPIBeyondCookies for Shared Worker");