diff --git a/docs/index.bs b/docs/index.bs
index ede56461..483b7ae5 100644
--- a/docs/index.bs
+++ b/docs/index.bs
@@ -1975,6 +1975,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. If |r|'s [=request/url=]'s [=url/scheme=] is not one of "http" and "https", then:
1. [=fetch/Terminate=] all the ongoing fetches initiated by |requests| with reason *fatal*.
1. Break the loop.
+ 1. If |r|'s [=request/client=]'s [=environment settings object/global object=] is a {{ServiceWorkerGlobalScope}} object, set |request|'s [=service-workers mode=] to "`foreign`".
1. Set |r|'s [=request/initiator=] to "fetch" and [=request/destination=] to "subresource".
1. Add a {{Request}} object associated with |r| to |requestArray|.
1. Let |responsePromise| be a new promise.
@@ -2265,6 +2266,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Let |serviceWorker| be |request|'s [=request/client=]'s [=environment settings object/global object=]'s [=ServiceWorkerGlobalScope/service worker=].
1. If |serviceWorker|'s imported scripts updated flag is unset, then:
1. Let |registration| be |serviceWorker|'s [=containing service worker registration=].
+ 1. Set |request|'s [=service-workers mode=] to "`foreign`".
1. Set |request|'s [=request/cache mode=] to "no-cache" if any of the following are true:
* |registration|'s [=service worker registration/use cache=] is false.
* The [=current global object=]'s [=force bypass cache for importscripts flag=] is set.
@@ -2588,6 +2590,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
To [=fetching scripts/perform the fetch=] given |request|, run the following steps:
+ 1. Append \`Service-Worker\`/\`script\` to |request|'s [=request/header list=].
+
+ Note: See the definition of the Service-Worker header in Appendix B: Extended HTTP headers.
+
1. Set |request|'s [=request/cache mode=] to "no-cache" if any of the following are true:
* |registration|'s [=service worker registration/use cache=] is false.
* |job|'s [=force bypass cache flag=] is set.
@@ -2595,7 +2601,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
Note: Even if the cache mode is not set to "no-cache", the user agent obeys Cache-Control header's max-age value in the network layer to determine if it should bypass the browser cache.
- 1. Set |request|'s [=skip-service-worker flag=].
+ 1. Set |request|'s [=service-workers mode=] to "`none`".
1. If the [=fetching scripts/is top-level=] flag is unset, then return the result of [=/fetching=] |request|.
1. Append \`Service-Worker\`/\`script\` to |request|'s [=request/header list=].
@@ -2909,7 +2915,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Let |preloadRequestHeaders| be |preloadRequest|'s [=request/header list=].
1. Let |preloadResponseObject| be a new {{Response}} object associated with a new {{Headers}} object whose [=guard=] is "`immutable`".
1. [=header list/Append=] to |preloadRequestHeaders| a new [=header=] whose [=header/name=] is \`Service-Worker-Navigation-Preload\` and [=header/value=] is |registration|'s [=navigation preload header value=].
- 1. Set |preloadRequest|'s [=skip-service-worker flag=].
+ 1. Set |preloadRequest|'s [=service-workers mode=] to "`none`".
1. Run the following substeps [=in parallel=]:
1. [=Fetch=] |preloadRequest|.
diff --git a/docs/index.html b/docs/index.html
index 4dc2d68e..6cef070a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1856,12 +1856,12 @@
// scope defaults to the path the script sits in // "/" in this example -navigator.serviceWorker.register("/serviceworker.js").then(registration => { +navigator.serviceWorker.register("/serviceworker.js").then(registration => { console.log("success!"); if (registration.installing) { registration.installing.postMessage("Howdy from your installing page."); } -}, err => { +}, err => { console.error("Installing the worker failed!", err); }); @@ -2390,10 +2390,10 @@
// caching.js -self.addEventListener("install", event => { +self.addEventListener("install", event => { event.waitUntil( // Open a cache of resources. - caches.open("shell-v1").then(cache => { + caches.open("shell-v1").then(cache => { // Begins the process of fetching them. // The coast is only clear when all the resources are ready. return cache.addAll([ @@ -2407,16 +2407,16 @@
has more or less the same effect as a document being loaded in a secure context with the following link element:
<link rel="serviceworker" href="/js/sw.js" scope="/"> +@@ -6623,7 +6630,7 @@<link rel="serviceworker" href="/js/sw.js" scope="/">which is more or less equivalent to the page containing javascript code like:
navigator.serviceworker.register("/js/sw.js", { scope: "/" }); @@ -3909,6 +3909,8 @@@@ -6614,7 +6621,7 @@
Break the loop.
++ If r’s client's global object is a
ServiceWorkerGlobalScopeobject, set request’s service-workers mode to "foreign".Set r’s initiator to "
fetch" and destination to "subresource".@@ -4430,7 +4432,7 @@
7.3.2.
-importScripts(urls)When the
+importScripts(urls)method is called on aServiceWorkerGlobalScopeobject, the user agent must import scripts into worker global scope, given thisServiceWorkerGlobalScopeobject and urls, and with the following steps to perform the fetch given the request request:When the
importScripts(urls)method is called on aServiceWorkerGlobalScopeobject, the user agent must import scripts into worker global scope, given thisServiceWorkerGlobalScopeobject and urls, and with the following steps to perform the fetch given the request request:
Let serviceWorker be request’s client's global object's service worker.
@@ -4439,6 +4441,8 @@
Let registration be serviceWorker’s containing service worker registration.
+- +
Set request’s service-workers mode to "
foreign".Set request’s cache mode to "
no-cache" if any of the following are true:@@ -4521,7 +4525,7 @@
@@ -4898,6 +4902,9 @@ 8.3. Define Event Handler
-Specifications may define an event handler attribute for the corresponding functional event using partial interface definition to the
+ServiceWorkerGlobalScopeinterface:Specifications may define an event handler attribute for the corresponding functional event using partial interface definition to the
ServiceWorkerGlobalScopeinterface:partial interface ServiceWorkerGlobalScope { attribute EventHandler onfunctionalevent; }; @@ -4530,7 +4534,7 @@8.4. Request Functional Event Dispatch
To request a functional event dispatch to a service worker, specifications may invoke Handle Functional Event algorithm with its service worker registration registration and the algorithm callbackSteps as the arguments.
-Specifications may define an algorithm callbackSteps where the corresponding functional event can be created and fired with specification specific objects. The algorithm is passed globalObject (a
+ServiceWorkerGlobalScopeobject) at which it may fire its functional events. This algorithm is called on a task queued by Handle Functional Event algorithm.Specifications may define an algorithm callbackSteps where the corresponding functional event can be created and fired with specification specific objects. The algorithm is passed globalObject (a
ServiceWorkerGlobalScopeobject) at which it may fire its functional events. This algorithm is called on a task queued by Handle Functional Event algorithm.Note: See an example hook defined in Notifications API.
To perform the fetch given request, run the following steps:
+
- +
Append `
+Service-Worker`/`script` to request’s header list.Note: See the definition of the Service-Worker header in Appendix B: Extended HTTP headers.
Set request’s cache mode to "
no-cache" if any of the following are true:@@ -4910,7 +4917,7 @@
Note: Even if the cache mode is not set to "
no-cache", the user agent obeys Cache-Control header’s max-age value in the network layer to determine if it should bypass the browser cache.- -
Set request’s skip-service-worker flag.
+Set request’s service-workers mode to "
none".If the is top-level flag is unset, then return the result of fetching request.
- @@ -5275,7 +5282,7 @@
InitializeHostDefinedRealm() abstract operation with the following customizations:
@@ -5470,7 +5477,7 @@
- -
For the global object, create a new
+ServiceWorkerGlobalScopeobject. Let workerGlobalScope be the created object.For the global object, create a new
ServiceWorkerGlobalScopeobject. Let workerGlobalScope be the created object.Let realmExecutionContext be the created JavaScript execution context.
Append to preloadRequestHeaders a new header whose name is `
Service-Worker-Navigation-Preload` and value is registration’s navigation preload header value.- -
Set preloadRequest’s skip-service-worker flag.
+Set preloadRequest’s service-workers mode to "
none".Run the following substeps in parallel:
@@ -6605,7 +6612,7 @@
Default scope:
// Maximum allowed scope defaults to the path the script sits in // "/js" in this example -navigator.serviceWorker.register("/js/sw.js").then(() => { +navigator.serviceWorker.register("/js/sw.js").then(() => { console.log("Install succeeded with the default scope '/js'."); });Upper path without Service-Worker-Allowed header:
// Set the scope to an upper path of the script location // Response has no Service-Worker-Allowed header -navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).catch(() => { +navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).catch(() => { console.error("Install failed due to the path restriction violation."); });
// Set the scope to an upper path of the script location // Response included "Service-Worker-Allowed : /" -navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).then(() => { +navigator.serviceWorker.register("/js/sw.js", { scope: "/" }).then(() => { console.log("Install succeeded as the max allowed scope was overriden to '/'."); }); @@ -6632,7 +6639,7 @@
// Set the scope to an upper path of the script location // Response included "Service-Worker-Allowed : /foo" -navigator.serviceWorker.register("/foo/bar/sw.js", { scope: "/" }).catch(() => { +navigator.serviceWorker.register("/foo/bar/sw.js", { scope: "/" }).catch(() => { console.error("Install failed as the scope is still out of the overriden maximum allowed scope."); }); @@ -7273,6 +7280,7 @@