Skip to content

Commit 2a00a68

Browse files
committed
Prevent speculative loads in child navigables
These are not implemented anywhere, and due to complexities about initiators (seen, e.g., in #384) it is probably not wise to pretend it's possible.
1 parent b226d1f commit 2a00a68

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

prefetch.bs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ Modify the [=snapshot source snapshot params=] algorithm to set the return value
556556
1. Let |request| be the result of [=creating a navigation request=] given <var ignore>entry</var>, <var ignore>sourceSnapshotParams</var>'s [=source snapshot params/fetch client=], <var ignore>navigable</var>'s [=navigable/container=], and <var ignore>sourceSnapshotParams</var>'s [=source snapshot params/has transient activation=].
557557
1. Set |request|'s [=request/replaces client id=] to <var ignore>navigable</var>'s [=navigable/active document=]'s [=relevant settings object=]'s [=environment/id=].
558558
1. Let |prefetched| be false.
559-
1. If <var ignore>documentResource</var> is null:
559+
1. If <var ignore>documentResource</var> is null and <var ignore>navigable</var> is a [=top-level traversable=]:
560560
1. Let |prefetchRecord| be the result of [=waiting for a matching prefetch record=] given <var ignore>navigable</var>, <var ignore>sourceSnapshotParams</var>, <var ignore>entry</var>'s [=session history entry/URL=], and <var ignore>sourceSnapshotParams</var>'s [=source snapshot params/sandboxing flags=].
561561
1. If |prefetchRecord| is not null:
562562
1. Set <var ignore>navigationParams</var> to the result of [=creating navigation params from a prefetch record=] given <var ignore>navigable</var>, <var ignore>entry</var>'s [=session history entry/document state=], <var ignore>navigationId</var>, <var ignore>navTimingType</var>, <var ignore>request</var>, |prefetchRecord|, <var ignore>targetSnapshotParams</var>, and <var ignore>sourceSnapshotParams</var>.
@@ -565,7 +565,7 @@ Modify the [=snapshot source snapshot params=] algorithm to set the return value
565565
<div class="note">This copy is complete before continuing, in the sense that subresource fetches, {{Document/cookie|document.cookie}}, etc. can observe the cookies. If the prefetch never reached a cross-site URL, there will be no cookies to copy.</div>
566566
1. Set |prefetched| to true.
567567

568-
<p class="note">This means that prefetches are only ever used to fulfill \``GET`\` requests.</p>
568+
<p class="note">This means that prefetches are only ever used to fulfill \``GET`\` requests, and only ever activated into [=top-level traversables=].</p>
569569
1. If |prefetched| is false:
570570
1. Let |coopEnforcementResult| be the result of [=creating a cross-origin opener policy enforcement result for navigation=] given <var ignore>navigable</var>'s [=navigable/active document=] and <var ignore>entry</var>'s [=session history entry/document state=]'s [=document state/initiator origin=].
571571
1. Set <var ignore>navigationParams</var> to the result of [=creating navigation params by fetching=] given |request|, <var ignore>entry</var>, |coopEnforcementResult|, <var ignore>navigable</var>, <var ignore>sourceSnapshotParams</var>, <var ignore>targetSnapshotParams</var>, <var ignore>cspNavigationType</var>, <var ignore>navigationId</var>, and <var ignore>navTimingType</var>.
@@ -794,6 +794,9 @@ The <dfn>list of sufficiently strict speculative navigation referrer policies</d
794794
<div algorithm>
795795
To <dfn export>prefetch</dfn> given a {{Document}} |document| and a [=prefetch record=] |prefetchRecord|, perform the following steps.
796796

797+
1. [=Assert=]: |document|'s [=node navigable=] is a [=top-level traversable=].
798+
799+
<p class="note" id="note-prefetch-top-level">Supporting prefetches in [=child navigables=] has some complexities and is not currently defined. It might be possible to define in the future.</p>
797800
1. If |document| [=has a matching prefetch record=] given |prefetchRecord|, then return.
798801
1. Let |sourceSnapshotParams| be the result of [=snapshotting source snapshot params=] given |document|.
799802
1. Let |targetSnapshotParams| be the result of [=snapshotting target snapshot params=] given |document|'s [=node navigable=].

speculation-rules.bs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ spec: nav-speculation; urlPrefix: prefetch.html
8686
spec: nav-speculation; urlPrefix: prerendering.html
8787
type: dfn
8888
text: start referrer-initiated prerendering; url: start-referrer-initiated-prerendering
89+
text: prerendering navigable; url: prerendering-navigable
8990
text: prerendering traversable; url: prerendering-traversable
9091
text: activate; for: prerendering traversable; url: prerendering-traversable-activate
9192
spec: no-vary-search; urlPrefix: https://httpwg.org/http-extensions/draft-ietf-httpbis-no-vary-search.html
@@ -614,6 +615,14 @@ A <dfn>prerender candidate</dfn> is a [=speculative load candidate=] with the fo
614615
<div algorithm="consider speculation">
615616
To <dfn>consider speculation</dfn> for a [=document=] |document|:
616617

618+
1. If |document|'s [=node navigable=] is not a [=top-level traversable=], then return.
619+
620+
<p class="note" id="note-speculation-top-level">Supporting speculative loads in [=child navigables=] has some complexities and is not currently defined. It might be possible to define in the future.</p>
621+
622+
1. If |document|'s [=node navigable=] is a [=prerendering navigable=], then return.
623+
624+
<p class="note" id="note-speculation-prerendering">Speculative loads in prerendering navigables would be too potentially wasteful.</p>
625+
617626
1. [=Queue a microtask=] that runs the following steps given |document|:
618627
1. If |document| is not [=Document/fully active=], then return.
619628
<p class="issue">It's likely that we should also handle prerendered documents.

0 commit comments

Comments
 (0)