Skip to content

Commit

Permalink
Bug 1804075 [wpt PR 37234] - prefetch: Add WPT showing that prefetch …
Browse files Browse the repository at this point in the history
…can match traverse and reload navigations., a=testonly

Automatic update from web-platform-tests
prefetch: Add WPT showing that prefetch can match traverse and reload navigations.

This came up during a spec PR review:
  WICG/nav-speculation#212

Change-Id: Ia8fb3d6c9b164fa35b196b99f1feb5750ec359f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4062248
Reviewed-by: Adithya Srinivasan <adithyas@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Auto-Submit: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1077079}

--

wpt-commits: 611dc0411c43984c7ab2abfa1810d97d065f7c71
wpt-pr: 37234
  • Loading branch information
jeremyroman authored and moz-wptsync-bot committed Dec 11, 2022
1 parent 47c1e28 commit 639a583
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<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="/websockets/constants.sub.js"></script>
<script src="resources/utils.sub.js"></script>
<script>
promise_test(async t => {
assert_implements(HTMLScriptElement.supports('speculationrules'), "Speculation Rules not supported");

let agent = await spawnWindow(t, { protocol: 'https', pipe: 'header(Cache-Control, no-store)' });
let previousUrl = await agent.execute_script(() => location.href);
await agent.execute_script(async () => {
window.preventBfcache = new WebSocket('wss://{{ports[wss][0]}}/echo');
});

let nextUrl = agent.getExecutorURL({ protocol: 'https', page: 2 });
await agent.navigate(nextUrl);

await agent.forceSinglePrefetch(previousUrl);
await agent.execute_script(() => {
window.executor.suspend(() => history.go(-1));
});

assert_equals(previousUrl, await agent.execute_script(() => location.href));
assert_prefetched(await agent.getRequestHeaders(), "traversal should use prefetch");
}, "prefetches can be used for traversal navigations");

promise_test(async t => {
assert_implements(HTMLScriptElement.supports('speculationrules'), "Speculation Rules not supported");

let agent = await spawnWindow(t, { protocol: 'https', pipe: 'header(Cache-Control, no-store)' });
let previousUrl = await agent.execute_script(() => location.href);
await agent.forceSinglePrefetch(previousUrl);
await agent.execute_script(() => {
window.executor.suspend(() => location.reload());
});

assert_equals(previousUrl, await agent.execute_script(() => location.href));
assert_prefetched(await agent.getRequestHeaders(), "reload should use prefetch");
}, "prefetches can be used for reload navigations");
</script>

0 comments on commit 639a583

Please sign in to comment.