From 2d97b008cb9bd800504351dfaddd49c8838ec4a4 Mon Sep 17 00:00:00 2001 From: Hiroshige Hayashizaki Date: Mon, 10 Apr 2023 19:39:57 +0900 Subject: [PATCH 1/5] Use sourceDocument for prefetch lookup in prerendering navigation --- prefetch.bs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prefetch.bs b/prefetch.bs index 4d6f5a4..ab6dc14 100644 --- a/prefetch.bs +++ b/prefetch.bs @@ -121,6 +121,7 @@ spec: COOKIES; urlPrefix: https://httpwg.org/specs/rfc6265.html spec: nav-speculation; urlPrefix: prerendering.html type: dfn text: getting the supported loading modes; url: get-the-supported-loading-modes + text: loading mode; for: navigable; url: navigable-loading-mode text: uncredentialed-prefetch; for: Supports-Loading-Mode; url: supports-loading-mode-uncredentialed-prefetch spec: resource-timing; urlPrefix: https://w3c.github.io/resource-timing/ type: dfn; for: PerformanceResourceTiming; text: delivery type; url: dfn-delivery-type @@ -412,7 +413,7 @@ Update all creation sites to supply an empty string, except for any in this docu
- In attempt to populate the history entry's document, replace the step which invokes create navigation params by fetching with the following: + In attempt to populate the history entry's document, add an optional {{Document}} |sourceDocument| argument, plumb it from navigate, and replace the step which invokes create navigation params by fetching with the following: 1. Otherwise, if both of the following are true: * entry's [=session history entry/URL=]'s [=url/scheme=] is a [=fetch scheme=]; and @@ -422,7 +423,9 @@ Update all creation sites to supply an empty string, except for any in this docu 1. Let |request| be the result of [=creating a navigation request=] given entry, sourceSnapshotParams's [=source snapshot params/fetch client=], navigable's [=navigable/container=], and sourceSnapshotParams's [=source snapshot params/has transient activation=]. 1. Set |request|'s [=request/replaces client id=] to navigable's [=navigable/active document=]'s [=relevant settings object=]'s [=environment/id=]. - 1. Let |prefetchRecord| be the result of [=finding a matching prefetch record=] given navigable's [=navigable/active document=], entry's [=session history entry/URL=], and targetSnapshotParams's [=target snapshot params/sandboxing flags=]. + 1. If navigable's [=navigable/loading mode=] is "`prerender`", then set |referringDocument| to |sourceDocument|. + 1. Otherwise, set |referringDocument| to navigable's [=navigable/active document=]. + 1. Let |prefetchRecord| be the result of [=finding a matching prefetch record=] given |referringDocument|, entry's [=session history entry/URL=], and targetSnapshotParams's [=target snapshot params/sandboxing flags=]. 1. If documentResource is null and |prefetchRecord| is not null: 1. Set navigationParams to the result of [=creating navigation params from a prefetch record=] given navigable, entry's [=session history entry/document state=], navigationId, navTimingType, request, |prefetchRecord|, targetSnapshotParams, and sourceSnapshotParams. 1. [=Copy prefetch cookies=] given |prefetchRecord|'s [=prefetch record/isolated partition key=] and navigationParams's [=navigation params/reserved environment=]. From d3d7be8c84d1ff5339430c1bbdf686dcca94a619 Mon Sep 17 00:00:00 2001 From: Hiroshige Hayashizaki Date: Mon, 17 Apr 2023 15:03:42 +0900 Subject: [PATCH 2/5] Always use sourceDocument if set --- prefetch.bs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prefetch.bs b/prefetch.bs index ab6dc14..2c939e1 100644 --- a/prefetch.bs +++ b/prefetch.bs @@ -413,7 +413,7 @@ Update all creation sites to supply an empty string, except for any in this docu
- In attempt to populate the history entry's document, add an optional {{Document}} |sourceDocument| argument, plumb it from navigate, and replace the step which invokes create navigation params by fetching with the following: + In attempt to populate the history entry's document, add an optional {{Document}} |sourceDocument| argument, and replace the step which invokes create navigation params by fetching with the following: 1. Otherwise, if both of the following are true: * entry's [=session history entry/URL=]'s [=url/scheme=] is a [=fetch scheme=]; and @@ -423,8 +423,9 @@ Update all creation sites to supply an empty string, except for any in this docu 1. Let |request| be the result of [=creating a navigation request=] given entry, sourceSnapshotParams's [=source snapshot params/fetch client=], navigable's [=navigable/container=], and sourceSnapshotParams's [=source snapshot params/has transient activation=]. 1. Set |request|'s [=request/replaces client id=] to navigable's [=navigable/active document=]'s [=relevant settings object=]'s [=environment/id=]. - 1. If navigable's [=navigable/loading mode=] is "`prerender`", then set |referringDocument| to |sourceDocument|. + 1. If |sourceDocument| is given, then set |referringDocument| to |sourceDocument|. 1. Otherwise, set |referringDocument| to navigable's [=navigable/active document=]. +

Or should we fallback to null instead? A notable case where this shouldn't be null is reload, but I'm not sure about other cases.

1. Let |prefetchRecord| be the result of [=finding a matching prefetch record=] given |referringDocument|, entry's [=session history entry/URL=], and targetSnapshotParams's [=target snapshot params/sandboxing flags=]. 1. If documentResource is null and |prefetchRecord| is not null: 1. Set navigationParams to the result of [=creating navigation params from a prefetch record=] given navigable, entry's [=session history entry/document state=], navigationId, navTimingType, request, |prefetchRecord|, targetSnapshotParams, and sourceSnapshotParams. @@ -435,6 +436,8 @@ Update all creation sites to supply an empty string, except for any in this docu 1. Let |coopEnforcementResult| be the result of [=creating a cross-origin opener policy enforcement result for navigation=] given navigable's [=navigable/active document=] and entry's [=session history entry/document state=]'s [=document state/initiator origin=]. 1. Set navigationParams to the result of [=creating navigation params by fetching=] given |request|, entry, |coopEnforcementResult|, navigable, sourceSnapshotParams, targetSnapshotParams, cspNavigationType, navigationId, and navTimingType. + The |sourceDocument| argument should be plumbed from navigate's |sourceDocument| and traverse the history by a delta's |sourceDocument|. +

How about other callers, i.e. apply pending history changes, finalize a same-document navigation and finalize a cross-document navigation?


From c7658e88aeac279b30b944e7f8f50815c2f4497b Mon Sep 17 00:00:00 2001 From: Hiroshige Hayashizaki Date: Mon, 17 Apr 2023 15:36:44 +0900 Subject: [PATCH 3/5] Remove obsolete anchor --- prefetch.bs | 1 - 1 file changed, 1 deletion(-) diff --git a/prefetch.bs b/prefetch.bs index 2c939e1..5b837cc 100644 --- a/prefetch.bs +++ b/prefetch.bs @@ -121,7 +121,6 @@ spec: COOKIES; urlPrefix: https://httpwg.org/specs/rfc6265.html spec: nav-speculation; urlPrefix: prerendering.html type: dfn text: getting the supported loading modes; url: get-the-supported-loading-modes - text: loading mode; for: navigable; url: navigable-loading-mode text: uncredentialed-prefetch; for: Supports-Loading-Mode; url: supports-loading-mode-uncredentialed-prefetch spec: resource-timing; urlPrefix: https://w3c.github.io/resource-timing/ type: dfn; for: PerformanceResourceTiming; text: delivery type; url: dfn-delivery-type From dc87b981baaa9eb9b742888734e22f5f2cd6a89a Mon Sep 17 00:00:00 2001 From: Hiroshige Hayashizaki Date: Mon, 17 Apr 2023 15:37:44 +0900 Subject: [PATCH 4/5] Rename to sourceDocumentForPrefetches --- prefetch.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prefetch.bs b/prefetch.bs index 5b837cc..331d928 100644 --- a/prefetch.bs +++ b/prefetch.bs @@ -412,7 +412,7 @@ Update all creation sites to supply an empty string, except for any in this docu
- In attempt to populate the history entry's document, add an optional {{Document}} |sourceDocument| argument, and replace the step which invokes create navigation params by fetching with the following: + In attempt to populate the history entry's document, add an optional {{Document}} |sourceDocumentForPrefetches| argument, and replace the step which invokes create navigation params by fetching with the following: 1. Otherwise, if both of the following are true: * entry's [=session history entry/URL=]'s [=url/scheme=] is a [=fetch scheme=]; and @@ -422,7 +422,7 @@ Update all creation sites to supply an empty string, except for any in this docu 1. Let |request| be the result of [=creating a navigation request=] given entry, sourceSnapshotParams's [=source snapshot params/fetch client=], navigable's [=navigable/container=], and sourceSnapshotParams's [=source snapshot params/has transient activation=]. 1. Set |request|'s [=request/replaces client id=] to navigable's [=navigable/active document=]'s [=relevant settings object=]'s [=environment/id=]. - 1. If |sourceDocument| is given, then set |referringDocument| to |sourceDocument|. + 1. If |sourceDocumentForPrefetches| is given, then set |referringDocument| to |sourceDocumentForPrefetches|. 1. Otherwise, set |referringDocument| to navigable's [=navigable/active document=].

Or should we fallback to null instead? A notable case where this shouldn't be null is reload, but I'm not sure about other cases.

1. Let |prefetchRecord| be the result of [=finding a matching prefetch record=] given |referringDocument|, entry's [=session history entry/URL=], and targetSnapshotParams's [=target snapshot params/sandboxing flags=]. @@ -435,7 +435,7 @@ Update all creation sites to supply an empty string, except for any in this docu 1. Let |coopEnforcementResult| be the result of [=creating a cross-origin opener policy enforcement result for navigation=] given navigable's [=navigable/active document=] and entry's [=session history entry/document state=]'s [=document state/initiator origin=]. 1. Set navigationParams to the result of [=creating navigation params by fetching=] given |request|, entry, |coopEnforcementResult|, navigable, sourceSnapshotParams, targetSnapshotParams, cspNavigationType, navigationId, and navTimingType. - The |sourceDocument| argument should be plumbed from navigate's |sourceDocument| and traverse the history by a delta's |sourceDocument|. + The |sourceDocumentForPrefetches| argument should be plumbed from navigate's |sourceDocument| and traverse the history by a delta's |sourceDocument|.

How about other callers, i.e. apply pending history changes, finalize a same-document navigation and finalize a cross-document navigation?

From 4474dc595812b63d1543f57c3637beb69ab4ced5 Mon Sep 17 00:00:00 2001 From: Hiroshige Hayashizaki Date: Thu, 27 Apr 2023 17:05:52 +0900 Subject: [PATCH 5/5] Plumb via source snapshot params --- prefetch.bs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/prefetch.bs b/prefetch.bs index 331d928..7db75d3 100644 --- a/prefetch.bs +++ b/prefetch.bs @@ -230,11 +230,10 @@ The user agent may [=prefetch record/cancel and discard=] records from the [=Doc
- To find a matching prefetch record given a {{Document}} |document|, [=URL=] |url|, and [=sandboxing flag set=] |sandboxFlags|, perform the following steps. + To find a matching prefetch record given a [=source snapshot params=] |sourceSnapshotParams|, [=URL=] |url|, and [=sandboxing flag set=] |sandboxFlags|, perform the following steps. - 1. [=Assert=]: |document| is [=Document/fully active=]. - 1. Let |currentTime| be the [=current high resolution time=] for the [=relevant global object=] of |document|. - 1. [=list/For each=] |record| of |document|'s [=Document/prefetch records=]: + 1. Let |currentTime| be the [=current high resolution time=] for |sourceSnapshotParams|'s [=source snapshot params/fetch client=]'s [=environment settings object/global object=]. + 1. [=list/For each=] |record| of |sourceSnapshotParams|'s [=source snapshot params/prefetch records=]: 1. If |record|'s [=prefetch record/URL=] is not equal to |url|, then [=iteration/continue=]. 1. If |record|'s [=prefetch record/state=] is not "`completed`", then [=iteration/continue=]. 1. If |record|'s [=prefetch record/sandboxing flag set=] is empty and |sandboxFlags| is not empty, then [=iteration/continue=]. @@ -242,7 +241,7 @@ The user agent may [=prefetch record/cancel and discard=] records from the [=Doc
Strictly speaking, it would still be possible for this to be valid if sandbox flags have been added to the container since prefetch but those flags would not cause an error due to cross origin opener policy. This is expected to be rare and so isn't handled.
- 1. [=list/Remove=] |record| from |document|'s [=Document/prefetch records=]. + 1. [=list/Remove=] |record| from |sourceSnapshotParams|'s [=source snapshot params/prefetch records=]. 1. If |record|'s [=prefetch record/expiry time=] is less than |currentTime|, return null. 1. If |record|'s [=prefetch record/redirect chain=] [=redirect chain/has updated credentials=], return null. 1. Return |record|. @@ -411,8 +410,16 @@ Update all creation sites to supply an empty string, except for any in this docu
+Add an additional item to [=source snapshot params=] as follows: +: prefetch records +:: a a [=list=] of [=prefetch records=]. + +When to [=snapshot source snapshot params=], set [=source snapshot params/prefetch records=] to sourceDocument's [=Document/prefetch records=]. + +
+
- In attempt to populate the history entry's document, add an optional {{Document}} |sourceDocumentForPrefetches| argument, and replace the step which invokes create navigation params by fetching with the following: + In attempt to populate the history entry's document, replace the step which invokes create navigation params by fetching with the following: 1. Otherwise, if both of the following are true: * entry's [=session history entry/URL=]'s [=url/scheme=] is a [=fetch scheme=]; and @@ -422,10 +429,7 @@ Update all creation sites to supply an empty string, except for any in this docu 1. Let |request| be the result of [=creating a navigation request=] given entry, sourceSnapshotParams's [=source snapshot params/fetch client=], navigable's [=navigable/container=], and sourceSnapshotParams's [=source snapshot params/has transient activation=]. 1. Set |request|'s [=request/replaces client id=] to navigable's [=navigable/active document=]'s [=relevant settings object=]'s [=environment/id=]. - 1. If |sourceDocumentForPrefetches| is given, then set |referringDocument| to |sourceDocumentForPrefetches|. - 1. Otherwise, set |referringDocument| to navigable's [=navigable/active document=]. -

Or should we fallback to null instead? A notable case where this shouldn't be null is reload, but I'm not sure about other cases.

- 1. Let |prefetchRecord| be the result of [=finding a matching prefetch record=] given |referringDocument|, entry's [=session history entry/URL=], and targetSnapshotParams's [=target snapshot params/sandboxing flags=]. + 1. Let |prefetchRecord| be the result of [=finding a matching prefetch record=] given sourceSnapshotParams, entry's [=session history entry/URL=], and targetSnapshotParams's [=target snapshot params/sandboxing flags=]. 1. If documentResource is null and |prefetchRecord| is not null: 1. Set navigationParams to the result of [=creating navigation params from a prefetch record=] given navigable, entry's [=session history entry/document state=], navigationId, navTimingType, request, |prefetchRecord|, targetSnapshotParams, and sourceSnapshotParams. 1. [=Copy prefetch cookies=] given |prefetchRecord|'s [=prefetch record/isolated partition key=] and navigationParams's [=navigation params/reserved environment=]. @@ -435,8 +439,6 @@ Update all creation sites to supply an empty string, except for any in this docu 1. Let |coopEnforcementResult| be the result of [=creating a cross-origin opener policy enforcement result for navigation=] given navigable's [=navigable/active document=] and entry's [=session history entry/document state=]'s [=document state/initiator origin=]. 1. Set navigationParams to the result of [=creating navigation params by fetching=] given |request|, entry, |coopEnforcementResult|, navigable, sourceSnapshotParams, targetSnapshotParams, cspNavigationType, navigationId, and navTimingType. - The |sourceDocumentForPrefetches| argument should be plumbed from navigate's |sourceDocument| and traverse the history by a delta's |sourceDocument|. -

How about other callers, i.e. apply pending history changes, finalize a same-document navigation and finalize a cross-document navigation?