diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /testing/web-platform/tests/speculation-rules | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/speculation-rules')
4 files changed, 47 insertions, 10 deletions
diff --git a/testing/web-platform/tests/speculation-rules/prefetch/referrer-policy-from-rules.https.html b/testing/web-platform/tests/speculation-rules/prefetch/referrer-policy-from-rules.https.html index d4828fca51..5024052eb4 100644 --- a/testing/web-platform/tests/speculation-rules/prefetch/referrer-policy-from-rules.https.html +++ b/testing/web-platform/tests/speculation-rules/prefetch/referrer-policy-from-rules.https.html @@ -15,7 +15,8 @@ <meta name="variant" content="?4-4"> <meta name="variant" content="?5-5"> <meta name="variant" content="?6-6"> -<meta name="variant" content="?7-last"> +<meta name="variant" content="?7-7"> +<meta name="variant" content="?8-last"> <script> "use strict"; @@ -58,8 +59,7 @@ subsetTest(promise_test, async t => { await agent.setReferrerPolicy("unsafe-url"); const nextURL = agent.getExecutorURL({ hostname: PREFETCH_PROXY_BYPASS_HOST, page: 2 }); - await agent.forceSinglePrefetch( - nextURL, { referrer_policy: "no-referrer", requires: ["anonymous-client-ip-when-cross-origin"] }); + await agent.forceSinglePrefetch(nextURL, { referrer_policy: "no-referrer" }); await agent.navigate(nextURL); // This referring page's referrer policy would not be eligible for @@ -84,6 +84,25 @@ subsetTest(promise_test, async t => { subsetTest(promise_test, async t => { const agent = await spawnWindow(t); + await agent.setReferrerPolicy("strict-origin"); + const expectedReferrer = agent.getExecutorURL().origin + "/"; + + const nextURL = agent.getExecutorURL({ page: 2 }); + await agent.execute_script((url) => { + const a = addLink(url); + a.referrerPolicy = 'no-referrrrrrrer'; + insertDocumentRule(); + }, [nextURL]); + await new Promise(resolve => t.step_timeout(resolve, 2000)); + await agent.navigate(nextURL); + + const headers = await agent.getRequestHeaders(); + assert_prefetched(headers, "must be prefetched"); + assert_equals(headers.referer, expectedReferrer, "must send the origin as the referrer"); +}, 'unrecognized policies in link referrerpolicy attribute are ignored'); + +subsetTest(promise_test, async t => { + const agent = await spawnWindow(t); await agent.setReferrerPolicy("strict-origin-when-cross-origin"); const nextURL = agent.getExecutorURL({ page: 2 }); @@ -100,8 +119,7 @@ subsetTest(promise_test, async t => { const expectedReferrer = agent.getExecutorURL().origin + "/"; const nextURL = agent.getExecutorURL({ hostname: PREFETCH_PROXY_BYPASS_HOST, page: 2 }); - await agent.forceSinglePrefetch( - nextURL, { referrer_policy: "unsafe-url", requires: ["anonymous-client-ip-when-cross-origin"] }); + await agent.forceSinglePrefetch(nextURL, { referrer_policy: "unsafe-url" }); await agent.navigate(nextURL); // This referring page's referrer policy would normally make it eligible for diff --git a/testing/web-platform/tests/speculation-rules/prefetch/referrer-policy-not-accepted.https.html b/testing/web-platform/tests/speculation-rules/prefetch/referrer-policy-not-accepted.https.html index d8c2bea87a..8cb7388479 100644 --- a/testing/web-platform/tests/speculation-rules/prefetch/referrer-policy-not-accepted.https.html +++ b/testing/web-platform/tests/speculation-rules/prefetch/referrer-policy-not-accepted.https.html @@ -10,7 +10,8 @@ <!--Split test cases due to the use of timeouts in speculation rules test utilities.--> <meta name="variant" content="?1-1"> -<meta name="variant" content="?2-last"> +<meta name="variant" content="?2-2"> +<meta name="variant" content="?3-last"> <script> "use strict"; @@ -39,12 +40,30 @@ subsetTest(promise_test, async t => { const nextURL = agent.getExecutorURL({ hostname: PREFETCH_PROXY_BYPASS_HOST, page: 2 }); // This prefetch attempt should be ignored. - await agent.forceSinglePrefetch( - nextURL, { requires: ["anonymous-client-ip-when-cross-origin"] }); + await agent.forceSinglePrefetch(nextURL); await agent.navigate(nextURL); const headers = await agent.getRequestHeaders(); assert_not_prefetched(headers, "must not be prefetched"); assert_equals(headers.referer, expectedReferrer, "must send the full URL as the referrer"); }, 'with "unsafe-url" referrer policy on cross-site referring page'); + +subsetTest(promise_test, async t => { + const agent = await spawnWindow(t); + await agent.setReferrerPolicy("unsafe-url"); + const expectedReferrer = agent.getExecutorURL().href; + + const nextURL = agent.getExecutorURL({ hostname: PREFETCH_PROXY_BYPASS_HOST, page: 2 }); + // This prefetch attempt should be ignored. + await agent.execute_script((url) => { + addLink(url); + insertDocumentRule(); + }, [nextURL]); + await new Promise(resolve => t.step_timeout(resolve, 2000)); + await agent.navigate(nextURL); + + const headers = await agent.getRequestHeaders(); + assert_not_prefetched(headers, "must not be prefetched"); + assert_equals(headers.referer, expectedReferrer, "must send the full URL as the referrer"); +}, 'with "unsafe-url" referrer policy on cross-site referring page with document rule'); </script> diff --git a/testing/web-platform/tests/speculation-rules/prefetch/resources/ruleset.py b/testing/web-platform/tests/speculation-rules/prefetch/resources/ruleset.py index 97de1cc1a0..5b6ac87aed 100644 --- a/testing/web-platform/tests/speculation-rules/prefetch/resources/ruleset.py +++ b/testing/web-platform/tests/speculation-rules/prefetch/resources/ruleset.py @@ -28,8 +28,7 @@ def main(request, response): "prefetch": [ {{ "source":"list", - "urls":["{url}?uuid={uuid}&page={page}&str={strparam}"], - "requires":["anonymous-client-ip-when-cross-origin"] + "urls":["{url}?uuid={uuid}&page={page}&str={strparam}"] }} ] }} diff --git a/testing/web-platform/tests/speculation-rules/prerender/resources/utils.js b/testing/web-platform/tests/speculation-rules/prerender/resources/utils.js index 940edcc0ca..bc1bc5911e 100644 --- a/testing/web-platform/tests/speculation-rules/prerender/resources/utils.js +++ b/testing/web-platform/tests/speculation-rules/prerender/resources/utils.js @@ -15,6 +15,7 @@ function startPrerendering(url, rule_extras = {}) { script.text = JSON.stringify( {prerender: [{source: 'list', urls: [url], ...rule_extras}]}); document.head.appendChild(script); + return script; } class PrerenderChannel extends EventTarget { |