From aeb01ec4220531d5f7e7b281f3f707e051e464dc Mon Sep 17 00:00:00 2001 From: Ari Chivukula Date: Tue, 4 Mar 2025 17:03:31 -0800 Subject: [PATCH] [Partitioned Popins] Test RSA localStorage via WPTs We need to run these in the chrome shell to see any changes due to calling requestStorageAccess. Bug: 340606651 Change-Id: Id23f342c76e8f62533a181f90c55a3f900d7a24d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6316335 Commit-Queue: Ari Chivukula Auto-Submit: Ari Chivukula Reviewed-by: Chris Fredrickson Cr-Commit-Position: refs/heads/main@{#1428048} --- ...ned-popins.localStorage.tentative.sub.https.window.js | 9 ++++++--- .../resources/partitioned-popins.localStorage-popin.html | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/partitioned-popins/partitioned-popins.localStorage.tentative.sub.https.window.js b/partitioned-popins/partitioned-popins.localStorage.tentative.sub.https.window.js index 06fe2239fd38a2..84b7af431074e9 100644 --- a/partitioned-popins/partitioned-popins.localStorage.tentative.sub.https.window.js +++ b/partitioned-popins/partitioned-popins.localStorage.tentative.sub.https.window.js @@ -1,5 +1,6 @@ // META: script=/resources/testdriver.js // META: script=/resources/testdriver-vendor.js +// META: script=/storage-access-api/helpers.js 'use strict'; @@ -32,12 +33,14 @@ async_test(t => { break; case 'popin-read': // Step 8 - assert_equals(e.data.message, "Found:ThirdParty-"); + assert_equals(e.data.message, "Found:ThirdParty-FirstPartyRSA-"); t.done(); break; } })); - // Step 2 - window.open("https://{{hosts[alt][]}}:{{ports[https][0]}}/partitioned-popins/resources/partitioned-popins.localStorage-window.html?id="+id, '_blank', 'popup'); + MaybeSetStorageAccess("*", "*", "blocked").then(() => { + // Step 2 + window.open("https://{{hosts[alt][]}}:{{ports[https][0]}}/partitioned-popins/resources/partitioned-popins.localStorage-window.html?id="+id, '_blank', 'popup'); + }); }, "Verify Partitioned Popins only have access to third-party localStorage"); diff --git a/partitioned-popins/resources/partitioned-popins.localStorage-popin.html b/partitioned-popins/resources/partitioned-popins.localStorage-popin.html index 4ab2d4a5ff2266..bd06309b3d9f82 100644 --- a/partitioned-popins/resources/partitioned-popins.localStorage-popin.html +++ b/partitioned-popins/resources/partitioned-popins.localStorage-popin.html @@ -14,6 +14,11 @@ } else if (window.localStorage.getItem("third-party") == id) { message += "ThirdParty-"; } + await test_driver.set_permission({ name: 'storage-access' }, 'granted'); + let handle = await document.requestStorageAccess({localStorage: true}); + if (handle && handle.localStorage.getItem("first-party") == id) { + message += "FirstPartyRSA-"; + } window.opener.postMessage({type: "popin-read", message: message}, "*"); window.close(); })();