diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/speculation-rules/prefetch/initiators-window-open.sub.https.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/speculation-rules/prefetch/initiators-window-open.sub.https.html')
-rw-r--r-- | testing/web-platform/tests/speculation-rules/prefetch/initiators-window-open.sub.https.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/web-platform/tests/speculation-rules/prefetch/initiators-window-open.sub.https.html b/testing/web-platform/tests/speculation-rules/prefetch/initiators-window-open.sub.https.html new file mode 100644 index 0000000000..6923d44dfb --- /dev/null +++ b/testing/web-platform/tests/speculation-rules/prefetch/initiators-window-open.sub.https.html @@ -0,0 +1,69 @@ +<!DOCTYPE html> +<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/utils.js"></script> +<script src="../resources/utils.js"></script> +<script src="resources/utils.sub.js"></script> + +<meta name="variant" content="?cross-site"> +<meta name="variant" content="?same-site"> + +<script> + setup(() => assertSpeculationRulesIsSupported()); + + // In https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate, + // `sourceDocument` (instead of `navigable`'s active document) should be + // used as the referring document for prefetch. + promise_test(async t => { + const win = await spawnWindow(t, { protocol: 'https' }); + + const hostname = + location.search === '?cross-site' ? '{{hosts[alt][www]}}' : undefined; + const nextUrl = win.getExecutorURL({ protocol: 'https', hostname, page: 2 }); + + await win.forceSinglePrefetch(nextUrl); + + await win.execute_script((url) => { + window.executor.suspend(() => { + window.open(url, "_blank"); + }); + }, [nextUrl]); + + // Below, the scripts given to `win.execute_script()` are executed on the + // `nextUrl` page in the new window, because `window.executor.suspend()` + // above made `win`'s original page stop processing `execute_script()`, + // while the new page of `nextUrl` in the new window starts processing + // `execute_script()` for the same ID. Same for below. + assert_equals( + await win.execute_script(() => location.href), + nextUrl.toString(), + "expected navigation to reach destination URL"); + + assert_prefetched(await win.getRequestHeaders()); + }, `window.open()`); + + promise_test(async t => { + const win = await spawnWindow(t, { protocol: 'https' }); + + const hostname = + location.search === '?cross-site' ? '{{hosts[alt][www]}}' : undefined; + const nextUrl = win.getExecutorURL({ protocol: 'https', hostname, page: 2 }); + + await win.forceSinglePrefetch(nextUrl); + + await win.execute_script((url) => { + window.executor.suspend(() => { + window.open(url, "_blank", "noopener"); + }); + }, [nextUrl]); + + assert_equals( + await win.execute_script(() => location.href), + nextUrl.toString(), + "expected navigation to reach destination URL"); + + assert_prefetched(await win.getRequestHeaders()); + }, `window.open(noopener)`); +</script> |