Files
tubestation/testing/web-platform/tests/preload/prefetch-accept.html
Noam Rosenthal f5bfca8db9 Bug 1805352 [wpt PR 37469] - Use the frame Accept header for prefetches., a=testonly
Automatic update from web-platform-tests
Use the frame `Accept` header for prefetches.

Special-casing prefetches makes it so that `Vary: Accept`
makes the browser erroneously reject the prefetched response.

Also changed the SXG ?q= value for the frame accept header, as it was
done for prefetch (and should have been done for the frame accept
header).

For now CORS prefetches remain untouched, as changing them to the
>128bytes frame accept headers would cause incompatibility due to a
CORS-preflight requirement.

This was previously unspecified,
See https://github.com/whatwg/fetch/pull/1485

Bug: 626081
Change-Id: I2c99f4f1abd2556fdf456d877588b346a22fd677
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4069726
Reviewed-by: Matt Menke <mmenke@chromium.org>
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Auto-Submit: Noam Rosenthal <nrosenthal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1083806}

--

wpt-commits: 9eb3b189dae1f06fed09df71442227527b860c6b
wpt-pr: 37469
2022-12-21 19:34:10 +00:00

27 lines
974 B
HTML

<!DOCTYPE html>
<title>Ensures that prefetch works with documents</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="resources/prefetch-helper.js"></script>
<body>
<script>
promise_test(async t => {
const {href, uid} = await prefetch({
file: "prefetch-exec.html",
type: "text/html",
origin: document.origin});
const popup = window.open(href + "&cache_bust=" + token());
const remoteContext = new RemoteContext(uid);
t.add_cleanup(() => popup.close());
await remoteContext.execute_script(() => "OK");
const results = await get_prefetch_info(href);
assert_equals(results.length, 2);
assert_equals(results[0].headers.accept, results[1].headers.accept);
}, "Document prefetch should send the exact Accept header as navigation")
</script>
</body>