Repository navigation
Add multiple tests for prefetch behavior - #35707
Conversation
domenic
left a comment
There was a problem hiding this comment.
Really great stuff.
Can we also test (or maybe tests already exist?) the behavior for empty string href="" and unparseable URL href=""?
Can we test that these never fire load/error events on the <link> element?
| @@ -0,0 +1,14 @@ | |||
| <!DOCTYPE html> | |||
| <title>Ensures that prefetch respects cache headers</title> | |||
There was a problem hiding this comment.
Wrong title. You can omit the <title> if there's only a single test, to avoid these sorts of mismatches.
Seems like they are fired. Will amend the spec PR |
|
We still need tests that |
Oh I think |
I changed the spec, prefetch overrides the options destination instead of the request destination, so |
| return await get_prefetch_info(href); | ||
| } | ||
|
|
||
| async function test_prefetch_document({origin, as}, expected) { |
There was a problem hiding this comment.
I think this helper is more confusing than helpful. I'd suggest inlining it.
There was a problem hiding this comment.
Hmm, I meant the test_prefetch_document helper being confusing... the prefetch_document helper is fine.
| @@ -0,0 +1,29 @@ | |||
| <!DOCTYPE html> | |||
There was a problem hiding this comment.
I wonder if all these files should go in https://github.com/web-platform-tests/wpt/tree/master/html/semantics/links/linktypes instead? Not sure, and I guess it's OK either way...
| return await get_prefetch_info(href); | ||
| } | ||
|
|
||
| async function test_prefetch_document({origin, as}, expected) { |
There was a problem hiding this comment.
Hmm, I meant the test_prefetch_document helper being confusing... the prefetch_document helper is fine.
See whatwg/html#8111 (comment) 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 Whether any additional headers (Sec-Purpose, Purpose, X-moz, X-Purpose) are sent (depending on what we put in the spec) * preload/prefetch-types.html Always uses prefetch destination, and ignores as=""
Co-authored-by: Domenic Denicola <[email protected]>
This replaces the existing `Purpose: prefetch` and `x-moz: prefetch` headers. Tests: web-platform-tests/wpt#35707. Part of whatwg/html#8111. Closes w3c/webappsec-fetch-metadata#84 and w3c/resource-hints#74. Co-authored-by: Anne van Kesteren <[email protected]>
|
I guess |
It's not the reason for the flakiness. The test waits until the prefetch is performed. |
|
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. |
See whatwg/html#8111 (comment)
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 correctpreload/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.