Skip to content

Commit

Permalink
Add WPTs for COOP: restrict-properties 1/*
Browse files Browse the repository at this point in the history
This is the first patch adding WPT support for COOP: restrict-properties. It does a couple of things:

- Add support for a "restricted" state in popup tests.
- Add a few popup tests, from COOP:RP to others COOP values. Add them as tentatives in a new dedicated folder.
- Add expectations for these tests.
- Add a virtual test suite running these tests with the COOP: restrict-properties flag enabled. Currently no-effect.

Bug: 1330586
Change-Id: Iccda420e58e787a35667baec3925e998b84a179b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3680118
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Arthur Hemery <ahemery@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1021150}
  • Loading branch information
hemeryar authored and chromium-wpt-export-bot committed Jul 6, 2022
1 parent ed013f7 commit 98439fb
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 0 deletions.
12 changes: 12 additions & 0 deletions html/cross-origin-opener-policy/resources/popup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ async function popup_test(description, origin, headers, expected_opener_state) {
'Main page has cross origin access to the popup?');
break;
}
case 'restricted': {
assert_false(popup.closed, 'Popup is closed from opener?');
assert_true(await getPopupHasOpener(popup_token) === "true",
'Popup has nulled opener?');
assert_false(canAccessProperty(popup, "document"),
'Main page has dom access to the popup?');
assert_false(canAccessProperty(popup, "frames"),
'Main page has cross origin access to the popup?');
assert_true(canAccessProperty(popup, "closed"),
'Main page has limited cross origin access to the popup?');
break;
}
case 'severed': {
assert_true(popup.closed, 'Popup is closed from opener?');
assert_false(await getPopupHasOpener(popup_token) === "true",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/utils.js"></script>
<script src="../../resources/common.js"></script>
<script src="../../resources/popup-test.js"></script>
<script>

[
{
"title": "popup with empty coop",
"coop": "",
"opener": "restricted"
},
{
"title": "popup with coop unsafe-none",
"coop": "unsafe-none",
"opener": "restricted"
},
{
"title": "popup with coop same-origin",
"coop": "same-origin",
"opener": "severed"
},
{
"title": "popup with coop same-origin-allow-popups",
"coop": "same-origin-allow-popups",
"opener": "severed"
},
{
"title": "popup with coop restrict-properties",
"coop": "restrict-properties",
"opener": "restricted"
}
].forEach(variant => {
popup_test(`Cross-origin ${variant.title}`, CROSS_ORIGIN,
{ coop: variant.coop }, variant.opener);
});

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cross-Origin-Opener-Policy: restrict-properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/utils.js"></script>
<script src="../../resources/common.js"></script>
<script src="../../resources/popup-test.js"></script>
<script>

[
{
"title": "popup with empty coop",
"coop": "",
"opener": "restricted"
},
{
"title": "popup with coop unsafe-none",
"coop": "unsafe-none",
"opener": "restricted"
},
{
"title": "popup with coop same-origin",
"coop": "same-origin",
"opener": "severed"
},
{
"title": "popup with coop same-origin-allow-popups",
"coop": "same-origin-allow-popups",
"opener": "severed"
},
{
"title": "popup with coop restrict-properties",
"coop": "restrict-properties",
"opener": "restricted"
}
].forEach(variant => {
popup_test(`Same-origin ${variant.title}`, SAME_ORIGIN,
{ coop: variant.coop }, variant.opener);
});

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cross-Origin-Opener-Policy: restrict-properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/utils.js"></script>
<script src="../../resources/common.js"></script>
<script src="../../resources/popup-test.js"></script>
<script>

[
{
"title": "popup with empty coop",
"coop": "",
"opener": "restricted"
},
{
"title": "popup with coop unsafe-none",
"coop": "unsafe-none",
"opener": "restricted"
},
{
"title": "popup with coop same-origin",
"coop": "same-origin",
"opener": "severed"
},
{
"title": "popup with coop same-origin-allow-popups",
"coop": "same-origin-allow-popups",
"opener": "severed"
},
{
"title": "popup with coop restrict-properties",
"coop": "restrict-properties",
"opener": "restricted"
}
].forEach(variant => {
popup_test(`Same-site ${variant.title}`, SAME_SITE,
{ coop: variant.coop }, variant.opener);
});

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cross-Origin-Opener-Policy: restrict-properties

0 comments on commit 98439fb

Please sign in to comment.