-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add some testing for ancestor bit behavior #56147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bvandersloot-mozilla
wants to merge
3
commits into
web-platform-tests:master
Choose a base branch
from
bvandersloot-mozilla:ancestor-partitioning
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
html/partitioning/ancestor-chain-partitioning.sub.https.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| <!doctype html> | ||
| <meta charset=utf-8> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <script src="/resources/testdriver.js"></script> | ||
| <script src="/resources/testdriver-vendor.js"></script> | ||
| <body> | ||
| <script> | ||
| async function getResultPromise(key) { | ||
| return new Promise((resolve) => { | ||
| window.addEventListener("message", (event) => { | ||
| if (event.data?.type != "result" || event.data?.key != key) { | ||
| return; | ||
| } | ||
| resolve(event.data.value); | ||
| }); | ||
| }); | ||
| } | ||
| localStorage.setItem("aba", "unpartitioned"); | ||
| localStorage.setItem("aaa", "unpartitioned"); | ||
| localStorage.setItem("aa-sw-redir", "unpartitioned"); | ||
| let resultDataABA = getResultPromise("aba"); | ||
| let resultDataAAA = getResultPromise("aaa"); | ||
| let resultDataAASW = getResultPromise("aa-sw-redir"); | ||
| let resultDataPopup = getResultPromise("popup"); | ||
| </script> | ||
| <iframe src="//{{hosts[alt][www]}}:{{ports[https][0]}}{{location[path]}}/../resources/middle-frame.sub.html?key=aba"></iframe> | ||
| <iframe src="//{{hosts[][]}}:{{ports[https][0]}}{{location[path]}}/../resources/middle-frame.sub.html?key=aaa"></iframe> | ||
| <iframe id="aa-sw-redir"></iframe> | ||
| <script> | ||
| promise_test(async function() { | ||
| document.cookie = "unpartitioned=true; Secure; SameSite=None"; | ||
| let win = window.open("//{{hosts[][]}}:{{ports[https][0]}}{{location[path]}}/../resources/popup.sub.html?key=popup&cookie"); | ||
| let value = await resultDataPopup; | ||
| assert_equals(value, "", "Expected partitioned data in sandboxA(B) iframe"); | ||
| win?.close(); | ||
| this.add_cleanup(test_driver.delete_all_cookies); | ||
| }, "Expected partitioned data in sandboxA(B) iframe") | ||
|
|
||
| promise_test(async function() { | ||
| let value = await resultDataABA; | ||
| assert_equals(value, null, "Expected partitioned data in A(B(A)) nested frame"); | ||
| localStorage.removeItem("aba"); | ||
| }, "Expected partitioned data in A(B(A)) nested frame") | ||
|
|
||
| promise_test(async function() { | ||
| let value = await resultDataAAA; | ||
| assert_equals(value, "unpartitioned", "Expected unpartitioned data in A(A(A)) nested frame"); | ||
| localStorage.removeItem("aaa"); | ||
| }, "Expected unpartitioned data in A(A(A)) nested frame") | ||
|
|
||
| promise_test(async function() { | ||
| let registration = await navigator.serviceWorker.register("./resources/intercepting-worker.sub.js"); | ||
| this.add_cleanup(async function() { | ||
| await registration.unregister(); | ||
| }); | ||
|
|
||
| let innerFrame = document.getElementById("aa-sw-redir"); | ||
| innerFrame.src ="//{{hosts[][]}}:{{ports[https][0]}}{{location[path]}}/../resources/post-storage.sub.html?key=aa-sw-redir&intercept"; | ||
|
|
||
| let value = await resultDataAASW; | ||
| assert_equals(value, "unpartitioned", "Expected unpartitioned data in same-origin subframe redirected by service worker"); | ||
|
|
||
| localStorage.removeItem("aa-sw-redir"); | ||
| }, "Expected unpartitioned data in same-origin subframe redirected by service worker") | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| self.addEventListener("fetch", (event) => { | ||
| let url = new URL(event.request.url); | ||
| if (url.searchParams.has("intercept")) { | ||
| if (url.hostname == "{{hosts[][]}}") { | ||
| url.hostname = "{{hosts[alt][www]}}" | ||
| } else { | ||
| url.hostname = "{{hosts[][]}}"; | ||
| } | ||
| return event.respondWith(fetch(url)); | ||
| } | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <!doctype html> | ||
| <meta charset=utf-8> | ||
| <body> | ||
| <iframe id="innerFrame"></iframe> | ||
| <script> | ||
| window.addEventListener("message", (event) => { | ||
| if (event.data?.type != "result") { | ||
| return; | ||
| } | ||
| parent.postMessage(event.data, "*"); | ||
| }); | ||
| let innerFrame = document.getElementById("innerFrame"); | ||
| innerFrame.src ="//{{hosts[][]}}:{{ports[https][0]}}{{location[path]}}/../../resources/post-storage.sub.html{{location[query]}}"; | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <!doctype html> | ||
| <meta charset=utf-8> | ||
| <body> | ||
| <iframe id="innerFrame"></iframe> | ||
| <script> | ||
| window.addEventListener("message", (event) => { | ||
| if (event.data?.type != "result") { | ||
| return; | ||
| } | ||
| window.opener.postMessage(event.data, "*"); | ||
| }); | ||
| let innerFrame = document.getElementById("innerFrame"); | ||
| let queryParams = "{{location[query]}}".replace("&", "&"); // un-escape the templated string. | ||
| innerFrame.src ="//{{hosts[alt][www]}}:{{ports[https][0]}}{{location[path]}}/../../resources/post-storage.sub.html" + queryParams; | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Content-Security-Policy: sandbox allow-scripts; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <!doctype html> | ||
| <meta charset=utf-8> | ||
| <body> | ||
| <script> | ||
| const urlParams = new URLSearchParams(window.location.search); | ||
| let key = urlParams.get("key"); | ||
| let result = localStorage.getItem(key); | ||
| if (urlParams.has("store")) { | ||
| localStorage.setItem(key, urlParams.get("store")); | ||
| } | ||
| parent.postMessage({ | ||
| type: "result", | ||
| value: result, | ||
| key, | ||
| }, "*"); | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Access-Control-Allow-Origin: {{header_or_default(Origin, *)}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <!doctype html> | ||
| <meta charset=utf-8> | ||
| <body> | ||
| <script> | ||
| const urlParams = new URLSearchParams(window.location.search); | ||
| let key = urlParams.get("key"); | ||
| let result; | ||
| if (urlParams.has("cookie")) { | ||
| result = "{{header_or_default(cookie, )}}"; | ||
| } else { | ||
| result = localStorage.getItem(key); | ||
| if (urlParams.has("store")) { | ||
| localStorage.setItem(key, urlParams.get("store")); | ||
| } | ||
| } | ||
| parent.postMessage({ | ||
| type: "result", | ||
| value: result, | ||
| key, | ||
| }, "*"); | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Access-Control-Allow-Origin: {{header_or_default(Origin, *)}} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this is doing the CORS thing whatwg/html#11540 (comment) discusses. Or is this testing something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was trying to validate that the request vs response partition behavior. I was going to do it with top-level sandboxing, but the sandbox blocks localStorage, so I went this way. I can do a cookie-lookup in a sandboxed-partitioned context if that helps.
Adding the CORS headers here though.