wpt icon indicating copy to clipboard operation
wpt copied to clipboard

Add multiple tests for prefetch behavior

Open noamr opened this issue 3 years ago • 4 comments

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-Purpose and Sec-Destination are 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.

noamr avatar Aug 30 '22 17:08 noamr

Can we test that these never fire load/error events on the <link> element?

Seems like they are fired. Will amend the spec PR

noamr avatar Sep 05 '22 14:09 noamr

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).

domenic avatar Sep 06 '22 01:09 domenic

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.

noamr avatar Sep 06 '22 05:09 noamr

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.

I changed the spec, prefetch overrides the options destination instead of the request destination, so as is practically ignored.

noamr avatar Sep 06 '22 06:09 noamr

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?

domenic avatar Jan 17 '23 12:01 domenic

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?

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

noamr avatar Jan 17 '23 12:01 noamr

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.

domenic avatar Jan 17 '23 12:01 domenic

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...

noamr avatar Jan 18 '23 05:01 noamr

/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.

domenic avatar Jan 18 '23 05:01 domenic