From f014d5654c5a389537712ec27d42f7e01c6ff2f6 Mon Sep 17 00:00:00 2001 From: Ari Chivukula Date: Thu, 22 Aug 2024 22:20:01 +0000 Subject: [PATCH] Bug 1914237 [wpt PR 47719] - [Partitioned Popins] (6) Add permissions policy for popin, a=testonly Automatic update from web-platform-tests [Partitioned Popins] (6) Add permissions policy for popin This CL adds a permissions policy to control access to the partitioned popin feature and sets the default to 'self'. This series of CLs implement core components of the Partitioned Popin system, significant additional effort will be needed to align with the explainer and I2P, but all of that will depend on this work: (1) Implement `popin` window feature (2) `popin` feature triggers tab modal popup (3) `popin` feature triggers third-party storage partitioning (4) Renderer awareness of popin top-origin (5) Limit window.opener access for popin (6) Add permissions policy for popin Explainer: https://explainers-by-googlers.github.io/partitioned-popins/ I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/ApU_zUmpQ2g/ Bug: 340606651 Change-Id: Ifde9f8e3529d794b5242df561603df7739a1f892 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5802591 Auto-Submit: Ari Chivukula Reviewed-by: Daniel Cheng Commit-Queue: Ari Chivukula Cr-Commit-Position: refs/heads/main@{#1344862} -- wpt-commits: 2fd0573aaf9f954bd96a001c2b2030b20802a126 wpt-pr: 47719 --- ...rmission-all.tentative.sub.https.window.js | 32 +++++++++++++++++++ ...-all.tentative.sub.https.window.js.headers | 1 + ...sion-default.tentative.sub.https.window.js | 31 ++++++++++++++++++ ...mission-self.tentative.sub.https.window.js | 32 +++++++++++++++++++ ...self.tentative.sub.https.window.js.headers | 1 + ...partitioned-popins.permissions-iframe.html | 20 ++++++++++++ .../partitioned-popins.permissions-popin.html | 12 +++++++ 7 files changed, 129 insertions(+) create mode 100644 testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-all.tentative.sub.https.window.js create mode 100644 testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-all.tentative.sub.https.window.js.headers create mode 100644 testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-default.tentative.sub.https.window.js create mode 100644 testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-self.tentative.sub.https.window.js create mode 100644 testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-self.tentative.sub.https.window.js.headers create mode 100644 testing/web-platform/tests/partitioned-popins/resources/partitioned-popins.permissions-iframe.html create mode 100644 testing/web-platform/tests/partitioned-popins/resources/partitioned-popins.permissions-popin.html diff --git a/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-all.tentative.sub.https.window.js b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-all.tentative.sub.https.window.js new file mode 100644 index 0000000000000..83eb092905c61 --- /dev/null +++ b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-all.tentative.sub.https.window.js @@ -0,0 +1,32 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +'use strict'; + +// Spec: https://explainers-by-googlers.github.io/partitioned-popins/ +// Step 1 (window) Set up listener to resolve messages as they come in. +// Step 2 (window) Open iframe for other origin. +// Step 3 (iframe) Open partitioned popin. +// Step 4 (popin) Cleanup. +// Step 5 (iframe) Report success. +// Step 6 (window) Cleanup. + +async_test(t => { + const id = String(Date.now()); + // Step 1 + window.addEventListener("message", t.step_func(e => { + switch (e.data.type) { + case 'popin': + // Step 6 + assert_equals(e.data.message, "Success"); + t.done(); + break; + } + })); + + // Step 2 + const iframe = document.createElement("iframe"); + iframe.allow = "popins"; + iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/partitioned-popins/resources/partitioned-popins.permissions-iframe.html"; + document.body.appendChild(iframe); +}, "Verify Partitioned Popins in an iframe work when the policy is *"); diff --git a/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-all.tentative.sub.https.window.js.headers b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-all.tentative.sub.https.window.js.headers new file mode 100644 index 0000000000000..36ba34ecd5346 --- /dev/null +++ b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-all.tentative.sub.https.window.js.headers @@ -0,0 +1 @@ +Permissions-Policy: popins=* diff --git a/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-default.tentative.sub.https.window.js b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-default.tentative.sub.https.window.js new file mode 100644 index 0000000000000..613d8dbb5f2da --- /dev/null +++ b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-default.tentative.sub.https.window.js @@ -0,0 +1,31 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +'use strict'; + +// Spec: https://explainers-by-googlers.github.io/partitioned-popins/ +// Step 1 (window) Set up listener to resolve messages as they come in. +// Step 2 (window) Open iframe for other origin. +// Step 3 (iframe) Open partitioned popin. +// Step 4 (popin) Cleanup. +// Step 5 (iframe) Report failure. +// Step 6 (window) Cleanup. + +async_test(t => { + const id = String(Date.now()); + // Step 1 + window.addEventListener("message", t.step_func(e => { + switch (e.data.type) { + case 'popin': + // Step 6 + assert_equals(e.data.message, "Failure"); + t.done(); + break; + } + })); + + // Step 2 + const iframe = document.createElement("iframe"); + iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/partitioned-popins/resources/partitioned-popins.permissions-iframe.html"; + document.body.appendChild(iframe); +}, "Verify Partitioned Popins in an iframe fails when the policy isn't set"); diff --git a/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-self.tentative.sub.https.window.js b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-self.tentative.sub.https.window.js new file mode 100644 index 0000000000000..5930442aa872d --- /dev/null +++ b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-self.tentative.sub.https.window.js @@ -0,0 +1,32 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +'use strict'; + +// Spec: https://explainers-by-googlers.github.io/partitioned-popins/ +// Step 1 (window) Set up listener to resolve messages as they come in. +// Step 2 (window) Open iframe for other origin. +// Step 3 (iframe) Open partitioned popin. +// Step 4 (popin) Cleanup. +// Step 5 (iframe) Report failure. +// Step 6 (window) Cleanup. + +async_test(t => { + const id = String(Date.now()); + // Step 1 + window.addEventListener("message", t.step_func(e => { + switch (e.data.type) { + case 'popin': + // Step 6 + assert_equals(e.data.message, "Failure"); + t.done(); + break; + } + })); + + // Step 2 + const iframe = document.createElement("iframe"); + iframe.allow = "popins"; + iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/partitioned-popins/resources/partitioned-popins.permissions-iframe.html"; + document.body.appendChild(iframe); +}, "Verify Partitioned Popins in an iframe fail when the policy is 'self'"); diff --git a/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-self.tentative.sub.https.window.js.headers b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-self.tentative.sub.https.window.js.headers new file mode 100644 index 0000000000000..0d61ec4d3e4c5 --- /dev/null +++ b/testing/web-platform/tests/partitioned-popins/partitioned-popins.permission-self.tentative.sub.https.window.js.headers @@ -0,0 +1 @@ +Permissions-Policy: popins=self diff --git a/testing/web-platform/tests/partitioned-popins/resources/partitioned-popins.permissions-iframe.html b/testing/web-platform/tests/partitioned-popins/resources/partitioned-popins.permissions-iframe.html new file mode 100644 index 0000000000000..fe41057b7bb16 --- /dev/null +++ b/testing/web-platform/tests/partitioned-popins/resources/partitioned-popins.permissions-iframe.html @@ -0,0 +1,20 @@ + + + + + diff --git a/testing/web-platform/tests/partitioned-popins/resources/partitioned-popins.permissions-popin.html b/testing/web-platform/tests/partitioned-popins/resources/partitioned-popins.permissions-popin.html new file mode 100644 index 0000000000000..1009ee687a29a --- /dev/null +++ b/testing/web-platform/tests/partitioned-popins/resources/partitioned-popins.permissions-popin.html @@ -0,0 +1,12 @@ + + + + +