Add multiple tests for prefetch behavior
See https://github.com/whatwg/html/pull/8111#issuecomment-1229907894
Tests that:
-
preload/prefetch-cache.html No 5 minute rule (cache headers must be respected)
-
preload/prefetch-document.html No special treatment of as=document Whether Accept is left as its default value. Storage partitioning is applied, including for documents
-
preload/prefetch-load-event.html Does not block the load event
-
preload/prefetch-headers.html
Sec-PurposeandSec-Destinationare correct -
preload/prefetch-types.html Always uses prefetch destination, and ignores as=""
-
preload/prefetch-events.html Load & error events are fired, and invalid/empty hrefs are ignored.
Can we test that these never fire load/error events on the
<link>element?
Seems like they are fired. Will amend the spec PR
We still need tests that as="asdf" causes the fetch to not go through (since it leads to https://whatpr.org/html/8111/links.html#link-type-prefetch step 3 setting request to null and thus step 4 returning early).
We still need tests that
as="asdf"causes the fetch to not go through (since it leads to https://whatpr.org/html/8111/links.html#link-type-prefetch step 3 setting request to null and thus step 4 returning early).
Oh I think as is completely ignored. I'll amend it in the spec and add a test.
We still need tests that
as="asdf"causes the fetch to not go through (since it leads to https://whatpr.org/html/8111/links.html#link-type-prefetch step 3 setting request to null and thus step 4 returning early).Oh I think
asis completely ignored. I'll amend it in the spec and add a test.
I changed the spec, prefetch overrides the options destination instead of the request destination, so as is practically ignored.
I guess prefetch-cache.html is flaky in Firefox, maybe because Firefox prioritizes prefetches low and so sometimes it does the prefetch, sometimes it doesn't? Is there any easy fix for this to make it fail deterministically in Firefox, or should we ask for an admin-merge?
I guess
prefetch-cache.htmlis flaky in Firefox, maybe because Firefox prioritizes prefetches low and so sometimes it does the prefetch, sometimes it doesn't? Is there any easy fix for this to make it fail deterministically in Firefox, or should we ask for an admin-merge?
It's not the reason for the flakiness. The test waits until the prefetch is performed. What's flaky is the reliance on particular behavior of the HTTP cache, which can decide to empty at any moment :( Perhaps I can run it in a loop 10 times and even a single success is good enough
Eh, I doubt Firefox is clearing the HTTP cache more aggressively. More likely is that it has some bug where it doesn't actually make the value available until the next page load, or something like that... It's especially suspicious that we had exactly 5/10.
Eh, I doubt Firefox is clearing the HTTP cache more aggressively. More likely is that it has some bug where it doesn't actually make the value available until the next page load, or something like that... It's especially suspicious that we had exactly 5/10.
Ok perhaps we should admin merge this and let Mozilla deal with prefetch flakiness in their implementation...
/cc @web-platform-tests/admins for help admin-merging this. Firefox's flakiness seems to be due to genuinely inconsistent implementation; Noam has tried several workarounds with no luck.