WICG / nav-speculation

Proposal to enable privacy-enhanced preloading
https://wicg.github.io/nav-speculation/
Other
154 stars 35 forks source link

Speculation rules prefetch results are not used for prerendering #261

Open hiroshige-g opened 1 year ago

hiroshige-g commented 1 year ago

Problem

In a scenario like:

  1. Speculation rules prefetch to a URL is added to Document A
  2. Speculation rules prerender to the same URL is added to Document A

The prefetched results from Step 1 isn't used for the prerendering navigation request in Step 2.

This is because prefetch records is Document-scoped (assciated with navigable’s active document in https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate):

Let prefetchRecord be the result of finding a matching prefetch record given navigable’s active document, entry’s URL, and targetSnapshotParams’s sandboxing flags.

but start user-agent initiated prerendering and start referrer-initiated prerendering uses a newly created navigable and thus no prefetch records are there.

Possible Solution

Check sourceDocument of https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate instead of navigable’s active document in the case of prerendering. This would make start referrer-initiated prerendering to use the prefetched results in the scenario above.

tunetheweb commented 7 hours ago

This has been fixed in Chrome so can this issue be closed now? Or is there spec updates to be done to make it clear this should be done?