diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/speculation-rules/prefetch/initiators-a-element.sub.https.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/speculation-rules/prefetch/initiators-a-element.sub.https.html')
-rw-r--r-- | testing/web-platform/tests/speculation-rules/prefetch/initiators-a-element.sub.https.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/testing/web-platform/tests/speculation-rules/prefetch/initiators-a-element.sub.https.html b/testing/web-platform/tests/speculation-rules/prefetch/initiators-a-element.sub.https.html new file mode 100644 index 0000000000..bac5eb7cb7 --- /dev/null +++ b/testing/web-platform/tests/speculation-rules/prefetch/initiators-a-element.sub.https.html @@ -0,0 +1,79 @@ +<!DOCTYPE html> +<meta name="variant" content="?cross-site"> +<meta name="variant" content="?same-site"> +<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.sub.js"></script> +<script> + // 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 => { + assert_implements(HTMLScriptElement.supports('speculationrules'), "Speculation Rules not supported"); + + 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); + + // sourceDocument == `win`'s Document == active document of window being + // navigated. + await win.execute_script((url) => { + window.executor.suspend(() => { + const a = document.createElement('a'); + a.setAttribute('href', url); + document.body.appendChild(a); + a.click(); + }); + }, [nextUrl]); + + assert_equals( + await win.execute_script(() => location.href), + nextUrl.toString(), + "expected navigation to reach destination URL"); + + assert_prefetched(await win.getRequestHeaders()); + }, `<a>`); + + promise_test(async t => { + assert_implements(HTMLScriptElement.supports('speculationrules'), "Speculation Rules not supported"); + + 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); + + // sourceDocument == `win`'s Document != active document of window being + // navigated, since the window being navigated is a new window. + await win.execute_script((url) => { + window.executor.suspend(() => { + const a = document.createElement('a'); + a.setAttribute('href', url); + a.setAttribute('target', '_blank'); + document.body.appendChild(a); + a.click(); + }); + }, [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. + assert_equals( + await win.execute_script(() => location.href), + nextUrl.toString(), + "expected navigation to reach destination URL"); + + assert_prefetched(await win.getRequestHeaders()); + }, `<a target="blank">`); +</script> |