Automatic update from web-platform-tests [SAA] Fix test failures due to default cookie availability This fixes the tests such that they no longer assume that third-party cookies are blocked by default (or that test_driver.set_storage_access does anything; see https://github.com/privacycg/storage-access/issues/162 for discussion). Fixed: b:446148374 Change-Id: I11c1e4fee88cbde810d31445357b233fcebc566b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6973284 Commit-Queue: Chris Fredrickson <cfredric@chromium.org> Auto-Submit: Chris Fredrickson <cfredric@chromium.org> Reviewed-by: Dylan Cutler <dylancutler@google.com> Cr-Commit-Position: refs/heads/main@{#1519499} -- Remove new assertion -- wpt-commits: c3f887e7f1f9ff410de609304f95e550d4a37570, 8539bf6cb4b87d36ceef4cee1b951f203cfda2e8 wpt-pr: 55018
85 lines
3.7 KiB
JavaScript
85 lines
3.7 KiB
JavaScript
// META: script=helpers.js
|
|
// META: script=/cookies/resources/cookie-helper.sub.js
|
|
// META: script=/resources/testdriver.js
|
|
// META: script=/resources/testdriver-vendor.js
|
|
'use strict';
|
|
|
|
(function() {
|
|
const altRoot = "https://{{hosts[alt][]}}:{{ports[https][0]}}";
|
|
|
|
const responderPath = "/storage-access-api/resources/script-with-cookie-header.py?script=embedded_responder.js";
|
|
const echoCookiesPath = `/storage-access-api/resources/echo-cookie-header.py`;
|
|
|
|
const altRootResponder = `${altRoot}${responderPath}`;
|
|
const altRootEchoCookies = `${altRoot}${echoCookiesPath}`;
|
|
|
|
async function SetUpResponderFrame(t, url) {
|
|
const frame = await CreateFrame(url);
|
|
|
|
await SetPermissionInFrame(frame, [{ name: 'storage-access' }, 'granted']);
|
|
t.add_cleanup(async () => {
|
|
await test_driver.delete_all_cookies();
|
|
await SetPermissionInFrame(frame, [{ name: 'storage-access' }, 'prompt']);
|
|
await MaybeSetStorageAccess("*", "*", "allowed");
|
|
});
|
|
|
|
return frame;
|
|
}
|
|
|
|
promise_test(async (t) => {
|
|
await MaybeSetStorageAccess("*", "*", "blocked");
|
|
await SetFirstPartyCookie(altRoot);
|
|
|
|
const frame = await SetUpResponderFrame(t, altRootResponder);
|
|
if (CanAccessCookiesViaJS()) {
|
|
// Nothing to test here, as cookies are not blocked in cross-site frames.
|
|
// See https://github.com/privacycg/storage-access/issues/162.
|
|
return;
|
|
}
|
|
assert_true(await RequestStorageAccessInFrame(frame), "requestStorageAccess resolves without requiring a gesture.");
|
|
assert_true(await FrameHasStorageAccess(frame), "frame has storage access after request.");
|
|
assert_true(await HasUnpartitionedCookie(frame), "frame has access to cookies after request.");
|
|
|
|
await StartDedicatedWorker(frame);
|
|
|
|
assert_true(cookieStringHasCookie("cookie", "unpartitioned",
|
|
await MessageWorker(frame, {command: "load"})),
|
|
"Worker's load was credentialed.");
|
|
assert_false(cookieStringHasCookie("cookie", "unpartitioned",
|
|
await MessageWorker(frame, {command: "fetch", url: altRootEchoCookies})),
|
|
"Worker's fetch is uncredentialed.");
|
|
}, "Workers don't inherit storage access");
|
|
|
|
promise_test(async (t) => {
|
|
await MaybeSetStorageAccess("*", "*", "blocked");
|
|
await SetFirstPartyCookie(altRoot);
|
|
|
|
const frame = await SetUpResponderFrame(t, altRootResponder);
|
|
if (CanAccessCookiesViaJS()) {
|
|
// Nothing to test here, as cookies are not blocked in cross-site frames.
|
|
return;
|
|
}
|
|
assert_false(await FrameHasStorageAccess(frame), "frame lacks storage access before request.");
|
|
assert_false(await HasUnpartitionedCookie(frame), "frame lacks access to cookies before request.");
|
|
|
|
await StartDedicatedWorker(frame);
|
|
assert_false(cookieStringHasCookie("cookie", "unpartitioned",
|
|
await MessageWorker(frame, {command: "load"})),
|
|
"Worker's load was uncredentialed.");
|
|
assert_false(cookieStringHasCookie("cookie", "unpartitioned",
|
|
await MessageWorker(frame, {command: "fetch", url: altRootEchoCookies})),
|
|
"Worker's first fetch is uncredentialed.");
|
|
|
|
// Since the parent document obtains storage access *after* having created
|
|
// the worker, this should have no effect on the worker.
|
|
assert_true(await RequestStorageAccessInFrame(frame), "requestStorageAccess resolves without requiring a gesture.");
|
|
assert_true(await FrameHasStorageAccess(frame), "frame has storage access after request.");
|
|
assert_true(await HasUnpartitionedCookie(frame), "frame has access to cookies after request.");
|
|
|
|
assert_false(cookieStringHasCookie("cookie", "unpartitioned",
|
|
await MessageWorker(frame, {command: "fetch", url: altRootEchoCookies})),
|
|
"Worker's second fetch is uncredentialed.");
|
|
}, "Workers don't observe parent's storage access");
|
|
|
|
}());
|