-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiple tests for prefetch behavior #35707
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
preload/prefetch-load-event.html
Outdated
@@ -0,0 +1,14 @@ | |||
<!DOCTYPE html> | |||
<title>Ensures that prefetch respects cache headers</title> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
preload/prefetch-document.html
Outdated
return await get_prefetch_info(href); | ||
} | ||
|
||
async function test_prefetch_document({origin, as}, expected) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this helper is more confusing than helpful. I'd suggest inlining it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...
preload/prefetch-document.html
Outdated
return await get_prefetch_info(href); | ||
} | ||
|
||
async function test_prefetch_document({origin, as}, expected) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <d@domenic.me>
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 <annevk@annevk.nl>
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-Purpose
andSec-Destination
are 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.