You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Rebasing on new, cleaner spec.
* Fixing linking & formatting bugs
* Invalid state error is more consistent with the rest of the spec
* Following review feeback
* Service workers mode
* Reverting skip-sw-flag change
A [=/service worker registration=] has one or more <dfn export id="dfn-service-worker-registration-task-queue">task queues</dfn> that back up the <a>tasks</a> from its <a>active worker</a>'s <a>event loop</a>'s corresponding [=/task queues=]. (The target task sources for this back up operation are the <a>handle fetch task source</a> and the <a>handle functional event task source</a>.) The user agent dumps the <a>active worker</a>'s <a>tasks</a> to the [=/service worker registration=]'s [=service worker registration/task queues=] when the <a>active worker</a> is <a lt="terminate service worker">terminated</a> and <a lt="queue a task">re-queues those tasks</a> to the <a>active worker</a>'s <a>event loop</a>'s corresponding [=/task queues=] when the <a>active worker</a> spins off. Unlike the [=/task queues=] owned by <a>event loops</a>, the [=/service worker registration=]'s [=service worker registration/task queues=] are not processed by any <a>event loops</a> in and of itself.
203
203
204
+
A [=/service worker registration=] has an associated <dfn export>{{NavigationPreloadManager}}</dfn> object.
205
+
206
+
A [=/service worker registration=] has an associated <dfn export>navigation preload enabled flag</dfn>. It is initially unset.
207
+
208
+
A [=/service worker registration=] has an associated <dfn export>navigation preload header value</dfn>, which is a [=byte sequence=]. It is initially set to \`<code>true</code>\`.
The {{NavigationPreloadManager/disable()}} method, when invoked, *must* return a new [=promise=] |promise| and run the following steps [=in parallel=]:
780
+
781
+
1. Let |registration| be the [=context object=]'s associated [=/service worker registration=].
782
+
1. If |registration|'s [=active worker=] is null, [=reject=] |promise| with an "{{InvalidStateError}}" exception, and abort these steps.
The <a method for="NavigationPreloadManager"><code>setHeaderValue(|value|)</code></a> method, when invoked, *must* return [=a new promise=] |promise| and run the following steps [=in parallel=]:
791
+
792
+
1. Let |registration| be the [=context object=]'s associated [=/service worker registration=].
793
+
1. If |registration|'s [=active worker=] is null, [=reject=] |promise| with an "{{InvalidStateError}}" exception, and abort these steps.
794
+
1. Set |registration|'s [=navigation preload header value=] to |value|.
The {{NavigationPreloadManager/getState()}} method, when invoked, *must* return [=a new promise=] |promise| and run the following steps [=in parallel=]:
802
+
803
+
1. Let |registration| be the [=context object=]'s associated [=/service worker registration=].
804
+
1. Let |state| be a new {{NavigationPreloadState}} dictionary.
805
+
1. If |registration|'s [=navigation preload enabled flag=] is set, set |state|'s {{NavigationPreloadState/enabled}} dictionary member to true.
806
+
1. Set |state|'s {{NavigationPreloadState/headerValue}} dictionary member to the |registration|'s [=navigation preload header value=].
1. Set |registration| to the result of running <a>Match Service Worker Registration</a> algorithm passing |request|'s [=request/url=] as the argument.
2798
2885
1. If |registration| is null or |registration|'s <a>active worker</a> is null, return null.
2799
2886
1. If |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, set |reservedClient|'s <a>active service worker</a> to |registration|'s <a>active worker</a>.
2887
+
1. If |request| is a [=navigation request=] and |registration|'s [=navigation preload enabled flag=] is set, and |request|'s [=request/method=] is \`<code>GET</code>\`, then:
2888
+
1. Let |preloadRequest| be the result of [=request/cloning=] the request |request|.
2889
+
1. Let |preloadRequestHeaders| be |preloadRequest|'s [=request/header list=].
2890
+
1. Let |preloadResponseObject| be a new {{Response}} object and a new associated {{Headers}} object whose [=guard=] is "`immutable`".
2891
+
1. [=header list/Append=] to |preloadRequestHeaders| a new [=header=] whose [=header/name=] is \`<code>Service-Worker-Navigation-Preload</code>\` and [=header/value=] is |registration|'s [=navigation preload header value=].
2892
+
1. Set |preloadRequest|'s [=skip-service-worker flag=].
2893
+
1. Run the following substeps [=in parallel=]:
2894
+
1. [=Fetch=] |preloadRequest|.
2895
+
2896
+
To [=process response=] for |navigationPreloadResponse|, run these substeps:
2897
+
2898
+
1. If |navigationPreloadResponse|'s [=response/type=] is "`error`", reject |preloadResponse| with a `TypeError` and terminate these substeps.
2899
+
1. Associate |preloadResponseObject| with |navigationPreloadResponse|.
2900
+
1. Resolve |preloadResponse| with |navigationPreloadResponse|.
2901
+
1. Else, resolve |preloadResponse| with undefined.
2800
2902
2801
2903
Note: From this point, the [=/service worker client=] starts to <a>use</a> its <a>active service worker</a>'s <a>containing service worker registration</a>.
1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}.
2819
2921
1. Initialize |e|’s {{Event/cancelable}} attribute to true.
2820
2922
1. Initialize |e|’s {{FetchEvent/request}} attribute to |r|.
2923
+
1. Initialize |e|’s {{FetchEvent/preloadResponse}} to |preloadResponse|.
2821
2924
1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=].
2822
2925
1. If |request| is a <a>non-subresource request</a> and |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, initialize |e|'s {{FetchEvent/reservedClientId}} attribute to |reservedClient|'s [=environment/id=], and to the empty string otherwise.
2823
2926
1. If |request| is a <a>navigation request</a>, initialize |e|'s {{FetchEvent/targetClientId}} attribute to |request|'s [=request/target client id=], and to the empty string otherwise.
0 commit comments