Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/storage-access-api/helpers.js
'use strict';
// Step 1 (main-window) Set up listener to resolve messages as they come in.
// Step 2 (main-window) Open window for other origin.
// Step 3 (other-window) Write first-party cookies and report success.
// Step 4 (main-window) Embed iframe for other origin.
// Step 5 (main-iframe) Write third-party cookies and report success.
// Step 6 (main-window) Open partitioned popin for other origin.
// Step 7 (popin) Check for first-/third-party cookies.
// Step 8 (popin-iframe) Check for first-/third-party cookies and report success.
// Step 9 (popin) Report success.
// Step 10 (main-window) Cleanup.
async_test(t => {
const id = String(Math.random());
document.cookie = "FirstPartyStrict=" + id + "; SameSite=Strict; Secure";
document.cookie = "FirstPartyLax=" + id + "; SameSite=Lax; Secure";
document.cookie = "FirstPartyNone=" + id + "; SameSite=None; Secure";
// Step 1
window.addEventListener("message", t.step_func(e => {
switch (e.data.type) {
case 'window-set':
// Step 4
assert_equals(e.data.message, "Set first-party data");
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
break;
case 'iframe-set':
// Step 6
assert_equals(e.data.message, "Set third-party data");
break;
case 'popin-read':
// Step 10
// We want to see the same behavior a cross-site iframe would have, only SameSite=None available, with the ability to set additional cookies in the popin.
// TODO(crbug.com/340606651): Once RSA is implemented we should see first-party cookies after the call.
assert_equals(e.data.message, "ReadOnLoad:ThirdPartyNone-,ReadOnFetch:ThirdPartyNone-ThirdPartyNonePopin-,ReadOnDocument:ThirdPartyNone-ThirdPartyNonePopin-,ReadOnFetchAfterRSA:ThirdPartyNone-ThirdPartyNonePopin-ThirdPartyNonePopinAfterRSA-,ReadOnDocumentAfterRSA:ThirdPartyNone-ThirdPartyNonePopin-ThirdPartyNonePopinAfterRSA-,ReadInPopinIframe:ThirdPartyNone-,ReadInPopinIframeAfterRSA:FirstPartyNone-ThirdPartyNone-FirstPartyNoneAfterRSA-ThirdPartyNoneAfterRSA-");
t.done();
break;
}
}));
MaybeSetStorageAccess("*", "*", "blocked").then(() => {
// Step 2
});
}, "Verify Partitioned Popins cookie access when third-party cookie access blocked");