Skip to content

Commit

Permalink
browser case
Browse files Browse the repository at this point in the history
  • Loading branch information
kjmcnee committed May 6, 2024
1 parent dd0baee commit 4f0c46a
Showing 1 changed file with 39 additions and 26 deletions.
65 changes: 39 additions & 26 deletions prerendering.bs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ spec: nav-speculation; urlPrefix: prefetch.html
type: dfn
text: supports prefetch; url: supports-prefetch
text: list of sufficiently-strict speculative navigation referrer policies
text: wait for a matching prefetch record; url: wait-for-a-matching-prefetch-record
spec: RFC8941; urlPrefix: https://www.rfc-editor.org/rfc/rfc8941.html
type: dfn
text: structured header; url: #section-1
Expand Down Expand Up @@ -202,6 +203,8 @@ By default, a [=navigable=]'s [=navigable/loading mode=] is "`default`". A navig

<p class="note">Although there are only two values for the [=navigable/loading mode=], we use a flexible structure in anticipation of other future loading modes, such as those provided by fenced frames, portals, and uncredentialed (cross-site) prerendering. It's not yet clear whether that anticipation is correct; if, as those features gain full specifications, it turns out not to be, we will instead convert this into a boolean.

Every [=prerendering traversable=] has an <dfn for="prerendering traversable">initial prerender search variance</dfn>, which is a [=URL search variance=] or null, and is initially null.

<dl class="domintro">
<dt><code><var ignore>document</var>.{{Document/prerendering}}</code></dt>

Expand All @@ -212,8 +215,6 @@ The <dfn attribute for="Document">prerendering</dfn> getter steps are to return

<hr>

Every [=navigable=] has a <dfn for="navigable">initial prerender search variance</dfn>, which is a [=URL search variance=] or null, and is initially null.

Every {{Document}} has <dfn export for="Document">prerender records</dfn>, which is a [=list=] of [=prerender records=]. This is used to fulfill [=navigate|navigations=] to a given URL by instead [=prerendering traversable/activating=] the corresponding prerendering traversable.

A <dfn export>prerender record</dfn> is a [=struct=] with the following [=struct/items=]:
Expand All @@ -225,7 +226,7 @@ A <dfn export>prerender record</dfn> is a [=struct=] with the following [=struct
<div algorithm>
A [=prerender record=] |prerenderRecord| <dfn export for="prerender record">matches a URL</dfn> given a [=URL=] |url| if the following algorithm returns true:
1. If |prerenderRecord|'s [=prerender record/starting URL=] is equal to |url|, return true.
1. Let |searchVariance| be |prerenderRecord|'s [=prerender record/prerendering traversable=]'s [=navigable/initial prerender search variance=].
1. Let |searchVariance| be |prerenderRecord|'s [=prerender record/prerendering traversable=]'s [=prerendering traversable/initial prerender search variance=].
1. If |searchVariance| is not null:
1. If |prerenderRecord|'s [=prerender record/starting URL=] and |url| are [=equivalent modulo search variance=] given |searchVariance|, return true.
1. Otherwise, return false.
Expand All @@ -234,7 +235,7 @@ A <dfn export>prerender record</dfn> is a [=struct=] with the following [=struct
<div algorithm>
A [=prerender record=] |prerenderRecord| <dfn export for="prerender record">is expected to match a URL</dfn> given a [=URL=] |url| if the following algorithm returns true:
1. If |prerenderRecord| [=prerender record/matches a URL=] given |url|, return true.
1. If |prerenderRecord|'s [=prerender record/prerendering traversable=]'s [=navigable/initial prerender search variance=] is null:
1. If |prerenderRecord|'s [=prerender record/prerendering traversable=]'s [=prerendering traversable/initial prerender search variance=] is null:
1. Let |searchVariance| be |prerenderRecord|'s [=prerender record/No-Vary-Search hint=].
1. If |prerenderRecord|'s [=prerender record/starting URL=] and |url| are [=equivalent modulo search variance=] given |searchVariance|, return true.
1. Otherwise, return false.
Expand Down Expand Up @@ -269,19 +270,19 @@ Every {{Document}} has an <dfn for="Document">activation start time</dfn>, which

1. Let |record| be a [=prerender record=] with [=prerender record/starting URL=] |startingURL| and [=prerender record/prerendering traversable=] |prerenderingTraversable|.

1. When the user indicates they wish to commit a navigation to an |activationUrl| which is a [=URL=] such that |record| [=prerender record/matches a URL=] given |activationUrl|:
1. When the user indicates they wish to commit a navigation to an |activationURL| which is a [=URL=] such that |record| [=prerender record/matches a URL=] given |activationURL|:

1. If the user indicates they wish to create a new user-visible [=top-level traversable=] while doing so (e.g., by pressing <kbd><kbd>Shift</kbd>+<kbd>Enter</kbd></kbd> after typing in the address bar):

1. TODO update URL
1. [=prerendering traversable/Update the successor for activation=] given |prerenderingTraversable|, |startingURL|, and |activationURL|.

1. Update the user agent's user interface to present |prerenderingTraversable|, e.g., by creating a new tab/window.

1. [=prerendering traversable/Finalize activation=] for |prerenderingTraversable| given |startingURL|'s [=url/origin=].

1. Alternately, if the user indicates they wish to commit the navigation into an existing [=top-level traversable=] |predecessorTraversable| (e.g., by pressing <kbd>Enter</kbd> after typing in the address bar):

1. [=prerendering traversable/Activate=] |prerenderingTraversable| in place of |predecessorTraversable| given "`push`", |startingURL|, and |activationUrl|.
1. [=prerendering traversable/Activate=] |prerenderingTraversable| in place of |predecessorTraversable| given "`push`", |startingURL|, and |activationURL|.

<p class="note">The user might never indicate such a commitment, or might take long enough to do so that the user agent needs to reclaim the resources used by the prerender for some more immediate task. In that case the user agent can [=destroy a top-level traversable|destroy=] |prerenderingTraversable|.
</div>
Expand Down Expand Up @@ -323,7 +324,28 @@ Every {{Document}} has an <dfn for="Document">activation start time</dfn>, which

<div algorithm>

To <dfn for="prerendering traversable">activate</dfn> a [=prerendering traversable=] |successorTraversable| in place of a [=top-level traversable=] |predecessorTraversable| given a [=history handling behavior=] |historyHandling|, a [=URL=] |startingUrl|, a [=URL=] |activationUrl|, an optional [=navigation ID=] |navigationId|:
To <dfn for="prerendering traversable">update the successor for activation</dfn> given a [=prerendering traversable=] |successorTraversable|, a [=URL=] |startingURL|, and a [=URL=] |activationURL|:

1. Let |successorDocument| be |successorTraversable|'s [=navigable/active document=].

1. If |startingURL| equals |successorDocument|'s [=Document/URL=] and |startingURL| does not equal |activationURL|:

1. [=Assert=]: |successorDocument| [=can have its URL rewritten=] to |activationURL|.

1. Let |navigation| be |successorDocument|'s [=relevant global object=]'s [=navigation API=].

1. Let |continue| be the result of [=firing a push-replace-reload navigate event=] at |navigation| given "[=NavigationType/replace=]", |activationURL|, and true.
<p class="issue">Should we do this or just do the update without the event? TODO: resolve before submit

1. If |continue| is true, run the [=URL and history update steps=] given |successorDocument| and |activationURL|.

<p class="note">This allows for the URL of the prerender to match the URL actually navigated to, in the case of inexact matching based on [:No-Vary-Search:].

</div>

<div algorithm>

To <dfn for="prerendering traversable">activate</dfn> a [=prerendering traversable=] |successorTraversable| in place of a [=top-level traversable=] |predecessorTraversable| given a [=history handling behavior=] |historyHandling|, a [=URL=] |startingURL|, a [=URL=] |activationURL|, an optional [=navigation ID=] |navigationId|:

1. [=Assert=]: |successorTraversable|'s [=navigable/active document=]'s [=Document/is initial about:blank=] is false.

Expand All @@ -343,20 +365,7 @@ Every {{Document}} has an <dfn for="Document">activation start time</dfn>, which

1. [=Queue a global task=] on the [=navigation and traversal task source=] given |predecessorTraversable|'s [=navigable/active window=] to [=Document/abort=] |predecessorTraversable|'s [=navigable/active document=].

1. Let |successorDocument| be |successorTraversable|'s [=navigable/active document=].

1. If |startingUrl| equals |successorDocument|'s [=Document/URL=] and |startingUrl| does not equal |activationUrl|:

1. [=Assert=]: |successorDocument| [=can have its URL rewritten=] to |activationUrl|.

1. Let |navigation| be |successorDocument|'s [=relevant global object=]'s [=navigation API=].

1. Let |continue| be the result of [=firing a push-replace-reload navigate event=] at |navigation| given "[=NavigationType/replace=]", |activationUrl|, and true.
<p class="issue">Should we do this or just do the update without the event? TODO: resolve before submit

1. If |continue| is true, run the [=URL and history update steps=] given |successorDocument| and |activationUrl|.

<p class="note">This allows for the URL of the prerender to match the URL actually navigated to, in the case of inexact matching based on [:No-Vary-Search:].
1. [=prerendering traversable/Update the successor for activation=] given |successorTraversable|, |startingURL|, and |activationURL|.

1. [=traversable navigable/Append session history traversal steps=] to |predecessorTraversable| to perform the following steps:

Expand Down Expand Up @@ -477,6 +486,8 @@ Every {{Document}} has an <dfn for="Document">activation start time</dfn>, which
1. Wait until the [=navigable/ongoing navigation=] of the [=prerender record/prerendering traversable=] of any element of |predecessorDocument|'s [=Document/prerender records=] changes.
1. If |cutoffTime| is null and any element of |potentialRecords| has a [=prerender record/prerendering traversable=] whose [=navigable/active document=]'s [=Document/is initial about:blank=] is false, set |cutoffTime| to the [=current high resolution time=] for the [=relevant global object=] of |predecessorDocument|.

<p class="note">See also: [=wait for a matching prefetch record=]. The logic for blocking on ongoing prerenders is similar to the prefetch case.</p>

</div>

Patch the [=navigate=] algorithm to allow the [=prerendering traversable/activate|activation=] of a [=prerendering traversable=] in place of a normal navigation as follows:
Expand All @@ -487,11 +498,12 @@ Patch the [=navigate=] algorithm to allow the [=prerendering traversable/activat
1. Let |matchingPrerenderRecord| be the result of [=waiting for a matching prerendering record=] given |navigable|, <var ignore>url</var>, <var ignore>cspNavigationType</var>, and <var ignore>documentResource</var>.

1. If |matchingPrerenderRecord| is not null, then:

1. Let |matchingPrerenderedNavigable| be |matchingPrerenderRecord|'s [=prerender record/prerendering traversable=].

1. Let |startingUrl| be |matchingPrerenderRecord|'s [=prerender record/starting URL=].
1. Let |startingURL| be |matchingPrerenderRecord|'s [=prerender record/starting URL=].

1. [=prerendering traversable/Activate=] |matchingPrerenderedNavigable| in place of |navigable| given <var ignore>historyHandling</var>, |startingUrl|, <var ignore>url</var>, and <var ignore>navigationId</var>.
1. [=prerendering traversable/Activate=] |matchingPrerenderedNavigable| in place of |navigable| given <var ignore>historyHandling</var>, |startingURL|, <var ignore>url</var>, and <var ignore>navigationId</var>.

1. Abort these steps.
</div>
Expand Down Expand Up @@ -542,8 +554,9 @@ Patch the [=navigate=] algorithm to allow the [=prerendering traversable/activat

1. Return.

1. If |navigable| is a [=prerendering navigable=] and |navigable|'s [=navigable/initial prerender search variance=] is null:
1. Set |navigable|'s [=navigable/initial prerender search variance=] to the result of [=obtaining a URL search variance=] given |navigationParams|'s [=navigation params/response=].
1. If |navigable| is a [=prerendering traversable=] and |navigable|'s [=prerendering traversable/initial prerender search variance=] is null:

1. Set |navigable|'s [=prerendering traversable/initial prerender search variance=] to the result of [=obtaining a URL search variance=] given |navigationParams|'s [=navigation params/response=].

</div>

Expand Down

0 comments on commit 4f0c46a

Please sign in to comment.