From fcabe9cf1fcd57e1d5b927603b6188f58fa19f62 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Mon, 5 Mar 2018 21:58:35 +0900 Subject: [PATCH 1/4] Improve service worker script caching and update This change includes/considers the following: - Include imported scripts to byte-check (for classic scripts). - Compare responses' body instead of source text as per https://github.com/whatwg/html/issues/3316. - Handle duplicate importScripts() as per https://github.com/w3c/ServiceWorker/issues/1041. - Replace *imported scripts updated flag* referenced in importScripts() by using service worker's state item. - Have Update's perform the fetch steps cover module scripts. - Avoid dobule-download of imported scripts pointed out in https://github.com/w3c/ServiceWorker/pull/1023#discussion_r92201798. This change basically makes it check out if the main script resource is identical to the existing resource. If so, it returns; otherwise, it creates a new service worker and evalute it to check out if any imported scripts are changed. It continues with Install only when any of the resources has been changed. With the change, importScripts() returns resources from the cache for any duplicated requests including the request for the main script. Fixes #1041, #1212, #1023. --- docs/index.bs | 81 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 0b5dd618..8119cd0c 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -165,7 +165,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A [=/service worker=] has an associated skip waiting flag. Unless stated otherwise it is unset. - A [=/service worker=] has an associated imported scripts updated flag. It is initially unset. + A [=/service worker=] has an associated classic scripts imported flag. It is initially unset. + + A [=/service worker=] has an associated include updated resources flag. It is initially unset. A [=/service worker=] has an associated set of event types to handle (a [=ordered set|set=]) whose [=list/item=] is an event listener's event type. It is initially an empty set. @@ -2027,22 +2029,28 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe When the importScripts(|urls|) method is called on a {{ServiceWorkerGlobalScope}} object, the user agent *must* import scripts into worker global scope, given this {{ServiceWorkerGlobalScope}} object and |urls|, and with the following steps to [=fetching scripts/perform the fetch=] given the [=/request=] |request|: 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 "`none`". - 1. Set |request|'s [=request/cache mode=] to "no-cache" if any of the following are true: - * |registration|'s [=service worker registration/update via cache mode=] is "`none`". - * The [=current global object=]'s [=force bypass cache for importscripts flag=] is set. - * |registration|'s [=last update check time=] is not null and the time difference in seconds calculated by the current time minus |registration|’s [=last update check time=] is greater than 86400. - 1. Let |response| be the result of fetching |request|. - 1. If |response|’s cache state is not "local", set |registration|’s [=service worker registration/last update check time=] to the current time. - 1. [=Extract a MIME type=] from the |response|'s [=unsafe response=]'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], return a [=network error=]. - 1. If |response|'s unsafe response's [=response/type=] is not "error", and |response|'s [=response/status=] is an ok status, then: - 1. [=map/Set=] script resource map[|request|'s [=request/url=]] to |response|. - 1. Return |response|. - 1. Else: - 1. If script resource map[|url|] [=map/exists=], return script resource map[|url|]. - 1. Else, return a network error. + 1. If |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] [=map/exists=], return [=service worker/script resource map=][|request|'s [=request/url=]]. + 1. If |serviceWorker|'s [=state=] is *installed*, *activating*, *activated*, or *redundant*, return a [=network error=]. + 1. Let |registration| be |serviceWorker|'s [=containing service worker registration=]. + 1. Set |request|'s [=service-workers mode=] to "`none`". + 1. Set |request|'s [=request/cache mode=] to "no-cache" if any of the following are true: + * |registration|'s [=service worker registration/update via cache mode=] is "`none`". + * The [=current global object=]'s [=force bypass cache for importscripts flag=] is set. + * |registration|'s [=last update check time=] is not null and the time difference in seconds calculated by the current time minus |registration|’s [=last update check time=] is greater than 86400. + 1. Let |response| be the result of fetching |request|. + 1. If |response|’s cache state is not "local", set |registration|’s [=service worker registration/last update check time=] to the current time. + 1. [=Extract a MIME type=] from the |response|'s [=unsafe response=]'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], return a [=network error=]. + 1. If |response|'s unsafe response's [=response/type=] is not "error", and |response|'s [=response/status=] is an ok status, then: + 1. Let |newestWorker| be the result of running [=Get Newest Worker=] with |registration|. + 1. Let |resource| be null. + 1. If |newestWorker| is not null, set |resource| to |newestWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]], or null if it does not [=map/exist=]. + 1. Set |serviceWorker|'s [=service worker/include updated resources flag=] if any of the following are true: + * |newestWorker| is null. + * |resource| is null. + * |resource|'s [=response/body=] is not byte-for-byte identical with |response|'s [=response/body=]. + 1. [=map/Set=] [=service worker/script resource map=][|request|'s [=request/url=]] to |response|. + 1. Set |serviceWorker|'s [=classic scripts imported flag=]. + 1. Return |response|. @@ -2069,7 +2077,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Privacy

- [=/Service workers=] introduce new persistent storage features including scope to registration map (for [=/service worker registrations=] and their [=/service workers=]), [=request response list=] and name to cache map (for caches), and script resource map (for script resources). In order to protect users from any potential unsanctioned tracking threat, these persistent storages *should* be cleared when users intend to clear them and *should* maintain and interoperate with existing user controls e.g. purging all existing persistent storages. + [=/Service workers=] introduce new persistent storage features including scope to registration map (for [=/service worker registrations=] and their [=/service workers=]), [=request response list=] and name to cache map (for caches), and [=service worker/script resource map=] (for script resources). In order to protect users from any potential unsanctioned tracking threat, these persistent storages *should* be cleared when users intend to clear them and *should* maintain and interoperate with existing user controls e.g. purging all existing persistent storages.
@@ -2147,8 +2155,12 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A job has a worker type ("classic" or "module"). + A [=job=] has a script resource map which is an ordered map where the keys are [=/URLs=] and the values are [=/responses=]. + A job has an update via cache mode, which is "`imports`", "`all`", or "`none`". + A [=job=] has a potentially include updated resources flag. It is initially unset. + A job has a client (a [=/service worker client=]). It is initially null. A job has a referrer (a [=/URL=] or null). @@ -2418,6 +2430,11 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Else: 1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}. 1. Asynchronously complete these steps with a network error. + 1. Set |job|'s [=job/potentially include updated resources flag=] if any of the following are true: + * |newestWorker| is null. + * |newestWorker|'s [=classic scripts imported flag=] is set. + * |newestWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]]'s [=response/body=] is not byte-for-byte identical with |response|'s [=response/body=]. + 1. Set |job|'s [=job/script resource map=][|request|'s [=request/url=]] to |response|. 1. If |response|'s cache state is not "local", set |registration|'s last update check time to the current time. Issue: The response's cache state concept had been removed from fetch. The fetch issue #376 tracks the request to restore the concept or add some similar way to check this state. @@ -2434,20 +2451,23 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Invoke Finish Job with |job| and abort these steps. Else, continue the rest of these steps after the algorithm's asynchronous completion, with |script| being the asynchronous completion value. - - 1. If |newestWorker| is not null, |newestWorker|'s [=service worker/script url=] [=url/equals=] |job|'s [=job/script url=], and |script|'s [=source text=] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=source text=], if |script| is a [=classic script=], and |script|'s [=module script/module record=]'s \[[ECMAScriptCode]] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=module script/module record=]'s \[[ECMAScriptCode]] otherwise, then: + 1. If |job|'s [=job/potentially include updated resources flag=] is unset, then: 1. Invoke [=Resolve Job Promise=] with |job| and |registration|. + 1. Invoke [=Finish Job=] with |job| and abort these steps. + 1. Let |worker| be a new [=/service worker=]. + 1. Set |worker|'s [=service worker/script url=] to |job|'s [=job/script url=], |worker|'s script resource to |script|, and |worker|'s [=service worker/type=] to |job|'s worker type. + 1. [=map/For each=] |url| → |response| of |job|'s [=job/script resource map=]: + 1. Set |worker|'s [=service worker/script resource map=][|url|] to |response|. + 1. Set |worker|'s script resource's HTTPS state to |httpsState|. + 1. Set |worker|'s script resource's [=script resource/referrer policy=] to |referrerPolicy|. + 1. Invoke Run Service Worker algorithm given |worker|, and with the *force bypass cache for importscripts flag* set if |job|'s [=job/force bypass cache flag=] is set. + 1. If an uncaught runtime script error occurs during the above step, then: + 1. Invoke [=Reject Job Promise=] with |job| and `TypeError`. + 1. If |newestWorker| is null, invoke Clear Registration algorithm passing |registration| as its argument. 1. Invoke Finish Job with |job| and abort these steps. - 1. Else: - 1. Let |worker| be a new [=/service worker=]. - 1. Set |worker|'s [=service worker/script url=] to |job|'s [=job/script url=], |worker|'s script resource to |script|, and |worker|'s [=service worker/type=] to |job|'s worker type. - 1. Set |worker|'s script resource's HTTPS state to |httpsState|. - 1. Set |worker|'s script resource's [=script resource/referrer policy=] to |referrerPolicy|. - 1. Invoke Run Service Worker algorithm given |worker|, and with the *force bypass cache for importscripts flag* set if |job|'s [=job/force bypass cache flag=] is set. - 1. If an uncaught runtime script error occurs during the above step, then: - 1. Invoke [=Reject Job Promise=] with |job| and `TypeError`. - 1. If |newestWorker| is null, invoke Clear Registration algorithm passing |registration| as its argument. - 1. Invoke Finish Job with |job| and abort these steps. + 1. If |worker|'s [=classic scripts imported flag=] is set, and |worker|'s [=service worker/include updated resources flag=] is unset, then: + 1. Invoke [=Resolve Job Promise=] with |job| and |registration|. + 1. Invoke [=Finish Job=] with |job| and abort these steps. 1. Invoke Install algorithm with |job|, |worker|, and |registration| as its arguments. @@ -2509,7 +2529,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Run the Update Registration State algorithm passing |registration|, "installing" and null as the arguments. 1. If |newestWorker| is null, invoke Clear Registration algorithm passing |registration| as its argument. 1. Invoke Finish Job with |job| and abort these steps. - 1. Set |registration|'s installing worker's imported scripts updated flag. 1. If |registration|'s waiting worker is not null, then: 1. [=Terminate Service Worker|Terminate=] |registration|'s [=waiting worker=]. 1. Run the [=Update Worker State=] algorithm passing |registration|'s [=waiting worker=] and *redundant* as the arguments. From ea8404745f7c9a4293f6646b6e84eeacb5c8530b Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Wed, 7 Mar 2018 14:34:36 +0900 Subject: [PATCH 2/4] Clarify a reference to the script resource map --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index 8119cd0c..65b90efd 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -2048,7 +2048,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe * |newestWorker| is null. * |resource| is null. * |resource|'s [=response/body=] is not byte-for-byte identical with |response|'s [=response/body=]. - 1. [=map/Set=] [=service worker/script resource map=][|request|'s [=request/url=]] to |response|. + 1. [=map/Set=] |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] to |response|. 1. Set |serviceWorker|'s [=classic scripts imported flag=]. 1. Return |response|. From e2c9db259d6561342eed86fec6f0bbf868884c79 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Thu, 8 Mar 2018 15:41:39 +0900 Subject: [PATCH 3/4] Do all byte-check before starting the service worker This addresses https://github.com/w3c/ServiceWorker/pull/1283#discussion_r172754443. This makes fetching the imported classic scripts done before evaluating the main script such that it does not start the service worker if no scripts (including imported scripts) were updated. This replaces unnecessary flags with local variables according to comments. --- docs/index.bs | 60 +++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 65b90efd..66a01e0f 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -167,8 +167,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A [=/service worker=] has an associated classic scripts imported flag. It is initially unset. - A [=/service worker=] has an associated include updated resources flag. It is initially unset. - A [=/service worker=] has an associated set of event types to handle (a [=ordered set|set=]) whose [=list/item=] is an event listener's event type. It is initially an empty set. A [=/service worker=] has an associated set of extended events (a [=ordered set|set=]) whose [=list/item=] is an {{ExtendableEvent}}. It is initially an empty set. @@ -2029,25 +2027,19 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe When the importScripts(|urls|) method is called on a {{ServiceWorkerGlobalScope}} object, the user agent *must* import scripts into worker global scope, given this {{ServiceWorkerGlobalScope}} object and |urls|, and with the following steps to [=fetching scripts/perform the fetch=] given the [=/request=] |request|: 1. Let |serviceWorker| be |request|'s [=request/client=]'s [=environment settings object/global object=]'s [=ServiceWorkerGlobalScope/service worker=]. - 1. If |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] [=map/exists=], return [=service worker/script resource map=][|request|'s [=request/url=]]. - 1. If |serviceWorker|'s [=state=] is *installed*, *activating*, *activated*, or *redundant*, return a [=network error=]. + 1. If |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] [=map/exists=], return the [=map/entry=]'s [=map/value=]. + 1. If |serviceWorker|'s [=state=] is not *parsed* or *installing*, return a [=network error=]. 1. Let |registration| be |serviceWorker|'s [=containing service worker registration=]. 1. Set |request|'s [=service-workers mode=] to "`none`". - 1. Set |request|'s [=request/cache mode=] to "no-cache" if any of the following are true: + 1. Set |request|'s [=request/cache mode=] to "`no-cache`" if any of the following are true: * |registration|'s [=service worker registration/update via cache mode=] is "`none`". * The [=current global object=]'s [=force bypass cache for importscripts flag=] is set. * |registration|'s [=last update check time=] is not null and the time difference in seconds calculated by the current time minus |registration|’s [=last update check time=] is greater than 86400. - 1. Let |response| be the result of fetching |request|. - 1. If |response|’s cache state is not "local", set |registration|’s [=service worker registration/last update check time=] to the current time. - 1. [=Extract a MIME type=] from the |response|'s [=unsafe response=]'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], return a [=network error=]. - 1. If |response|'s unsafe response's [=response/type=] is not "error", and |response|'s [=response/status=] is an ok status, then: - 1. Let |newestWorker| be the result of running [=Get Newest Worker=] with |registration|. - 1. Let |resource| be null. - 1. If |newestWorker| is not null, set |resource| to |newestWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]], or null if it does not [=map/exist=]. - 1. Set |serviceWorker|'s [=service worker/include updated resources flag=] if any of the following are true: - * |newestWorker| is null. - * |resource| is null. - * |resource|'s [=response/body=] is not byte-for-byte identical with |response|'s [=response/body=]. + 1. Let |response| be the result of [=fetch|fetching=] |request|. + 1. Set |response| to |response|'s [=unsafe response=]. + 1. If |response|’s cache state is not "`local`", set |registration|’s [=service worker registration/last update check time=] to the current time. + 1. [=Extract a MIME type=] from the |response|'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], return a [=network error=]. + 1. If |response|'s [=response/type=] is not "`error`", and |response|'s [=response/status=] is an ok status, then: 1. [=map/Set=] |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] to |response|. 1. Set |serviceWorker|'s [=classic scripts imported flag=]. 1. Return |response|. @@ -2155,12 +2147,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A job has a worker type ("classic" or "module"). - A [=job=] has a script resource map which is an ordered map where the keys are [=/URLs=] and the values are [=/responses=]. - A job has an update via cache mode, which is "`imports`", "`all`", or "`none`". - A [=job=] has a potentially include updated resources flag. It is initially unset. - A job has a client (a [=/service worker client=]). It is initially null. A job has a referrer (a [=/URL=] or null). @@ -2383,6 +2371,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Invoke Finish Job with |job| and abort these steps. 1. Let |httpsState| be "none". 1. Let |referrerPolicy| be the empty string. + 1. Let |hasUpdatedResources| be false. + 1. Let |updatedResourceMap| be an [=ordered map=] where the keys are [=/URLs=] and the values are [=/responses=]. 1. Switching on |job|'s worker type, run these substeps with the following options: : "classic" @@ -2430,15 +2420,28 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Else: 1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}. 1. Asynchronously complete these steps with a network error. - 1. Set |job|'s [=job/potentially include updated resources flag=] if any of the following are true: - * |newestWorker| is null. - * |newestWorker|'s [=classic scripts imported flag=] is set. - * |newestWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]]'s [=response/body=] is not byte-for-byte identical with |response|'s [=response/body=]. - 1. Set |job|'s [=job/script resource map=][|request|'s [=request/url=]] to |response|. + 1. Set |updatedResourceMap|[|request|'s [=request/url=]] to |response|. 1. If |response|'s cache state is not "local", set |registration|'s last update check time to the current time. Issue: The response's cache state concept had been removed from fetch. The fetch issue #376 tracks the request to restore the concept or add some similar way to check this state. + 1. If |newestWorker| is null, or |newestWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]]'s [=response/body=] is not byte-for-byte identical with |response|'s [=response/body=], set |hasUpdatedResources| to true. + 1. Else if |newestWorker|'s [=classic scripts imported flag=] is set, then: + 1. [=map/For each=] |url| → |storedResponse| of |newestWorker|'s [=service worker/script resource map=]: + 1. Let |request| be a new [=/request=] whose [=request/url=] is |url|, [=request/client=] is |job|'s [=job/client=], [=request/destination=] is "`script`", [=request/parser metadata=] is "`not parser-inserted`", [=request/synchronous flag=] is set, and whose [=request/use-URL-credentials flag=] is set. + 1. Set |request|'s [=request/cache mode=] to "`no-cache`" if any of the following are true: + * |registration|'s [=service worker registration/update via cache mode=] is "`none`". + * |job|'s [=force bypass cache flag=] is set. + * |registration|'s [=last update check time=] is not null and the time difference in seconds calculated by the current time minus |registration|’s [=last update check time=] is greater than 86400. + 1. Let |fetchedResponse| be the result of [=fetch|fetching=] |request|. + 1. Set |fetchedResponse| to |fetchedResponse|'s [=unsafe response=]. + 1. Set |updatedResourceMap|[|request|'s [=request/url=]] to |fetchedResponse|. + 1. If |fetchedResponse|'s cache state is not "local", set |registration|’s [=last update check time=] to the current time. + 1. [=Extract a MIME type=] from the |fetchedResponse|'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], asynchronously complete these steps with a [=network error=]. + 1. If |fetchedResponse|'s [=response/type=] is "`error`", or |fetchedResponse|'s [=response/status=] is not an [=ok status=], asynchronously complete these steps with a [=network error=]. + 1. If |fetchedResponse|'s [=response/body=] is not byte-for-byte identical with |storedResponse|'s [=response/body=], set |hasUpdatedResources| to true. + + Note: The control does not break the loop in this step to continue with all the imported scripts to populate the cache. 1. Return true. If the algorithm asynchronously completes with null, then: @@ -2451,12 +2454,12 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Invoke Finish Job with |job| and abort these steps. Else, continue the rest of these steps after the algorithm's asynchronous completion, with |script| being the asynchronous completion value. - 1. If |job|'s [=job/potentially include updated resources flag=] is unset, then: + 1. If |hasUpdatedResources| is false, then: 1. Invoke [=Resolve Job Promise=] with |job| and |registration|. 1. Invoke [=Finish Job=] with |job| and abort these steps. 1. Let |worker| be a new [=/service worker=]. 1. Set |worker|'s [=service worker/script url=] to |job|'s [=job/script url=], |worker|'s script resource to |script|, and |worker|'s [=service worker/type=] to |job|'s worker type. - 1. [=map/For each=] |url| → |response| of |job|'s [=job/script resource map=]: + 1. [=map/For each=] |url| → |response| of |updatedResourceMap|: 1. Set |worker|'s [=service worker/script resource map=][|url|] to |response|. 1. Set |worker|'s script resource's HTTPS state to |httpsState|. 1. Set |worker|'s script resource's [=script resource/referrer policy=] to |referrerPolicy|. @@ -2465,9 +2468,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Invoke [=Reject Job Promise=] with |job| and `TypeError`. 1. If |newestWorker| is null, invoke Clear Registration algorithm passing |registration| as its argument. 1. Invoke Finish Job with |job| and abort these steps. - 1. If |worker|'s [=classic scripts imported flag=] is set, and |worker|'s [=service worker/include updated resources flag=] is unset, then: - 1. Invoke [=Resolve Job Promise=] with |job| and |registration|. - 1. Invoke [=Finish Job=] with |job| and abort these steps. 1. Invoke Install algorithm with |job|, |worker|, and |registration| as its arguments. From c34985f912e41a98929c2ec3593b98dc155c9911 Mon Sep 17 00:00:00 2001 From: Jungkee Song Date: Tue, 13 Mar 2018 15:50:30 +0900 Subject: [PATCH 4/4] Apply the changes to V1 and add html files --- docs/index.bs | 14 +- docs/index.html | 364 +++++++++++++++++++++++++-------------------- docs/v1/index.bs | 81 ++++++---- docs/v1/index.html | 358 +++++++++++++++++++++++++------------------- 4 files changed, 462 insertions(+), 355 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 66a01e0f..94257ae2 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -2027,7 +2027,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe When the importScripts(|urls|) method is called on a {{ServiceWorkerGlobalScope}} object, the user agent *must* import scripts into worker global scope, given this {{ServiceWorkerGlobalScope}} object and |urls|, and with the following steps to [=fetching scripts/perform the fetch=] given the [=/request=] |request|: 1. Let |serviceWorker| be |request|'s [=request/client=]'s [=environment settings object/global object=]'s [=ServiceWorkerGlobalScope/service worker=]. - 1. If |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] [=map/exists=], return the [=map/entry=]'s [=map/value=]. + 1. If |serviceWorker|'s [=script resource map=][|request|'s [=request/url=]] [=map/exists=], return the [=map/entry=]'s [=map/value=]. 1. If |serviceWorker|'s [=state=] is not *parsed* or *installing*, return a [=network error=]. 1. Let |registration| be |serviceWorker|'s [=containing service worker registration=]. 1. Set |request|'s [=service-workers mode=] to "`none`". @@ -2040,7 +2040,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |response|’s cache state is not "`local`", set |registration|’s [=service worker registration/last update check time=] to the current time. 1. [=Extract a MIME type=] from the |response|'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], return a [=network error=]. 1. If |response|'s [=response/type=] is not "`error`", and |response|'s [=response/status=] is an ok status, then: - 1. [=map/Set=] |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] to |response|. + 1. [=map/Set=] |serviceWorker|'s [=script resource map=][|request|'s [=request/url=]] to |response|. 1. Set |serviceWorker|'s [=classic scripts imported flag=]. 1. Return |response|. @@ -2069,7 +2069,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Privacy

- [=/Service workers=] introduce new persistent storage features including scope to registration map (for [=/service worker registrations=] and their [=/service workers=]), [=request response list=] and name to cache map (for caches), and [=service worker/script resource map=] (for script resources). In order to protect users from any potential unsanctioned tracking threat, these persistent storages *should* be cleared when users intend to clear them and *should* maintain and interoperate with existing user controls e.g. purging all existing persistent storages. + [=/Service workers=] introduce new persistent storage features including scope to registration map (for [=/service worker registrations=] and their [=/service workers=]), [=request response list=] and name to cache map (for caches), and [=script resource map=] (for script resources). In order to protect users from any potential unsanctioned tracking threat, these persistent storages *should* be cleared when users intend to clear them and *should* maintain and interoperate with existing user controls e.g. purging all existing persistent storages.
@@ -2372,7 +2372,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |httpsState| be "none". 1. Let |referrerPolicy| be the empty string. 1. Let |hasUpdatedResources| be false. - 1. Let |updatedResourceMap| be an [=ordered map=] where the keys are [=/URLs=] and the values are [=/responses=]. + 1. Let |updatedResourceMap| be an [=ordered map=] where the [=map/keys=] are [=/URLs=] and the [=map/values=] are [=/responses=]. 1. Switching on |job|'s worker type, run these substeps with the following options: : "classic" @@ -2425,9 +2425,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe Issue: The response's cache state concept had been removed from fetch. The fetch issue #376 tracks the request to restore the concept or add some similar way to check this state. - 1. If |newestWorker| is null, or |newestWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]]'s [=response/body=] is not byte-for-byte identical with |response|'s [=response/body=], set |hasUpdatedResources| to true. + 1. If |newestWorker| is null, or |newestWorker|'s [=script resource map=][|request|'s [=request/url=]]'s [=response/body=] is not byte-for-byte identical with |response|'s [=response/body=], set |hasUpdatedResources| to true. 1. Else if |newestWorker|'s [=classic scripts imported flag=] is set, then: - 1. [=map/For each=] |url| → |storedResponse| of |newestWorker|'s [=service worker/script resource map=]: + 1. [=map/For each=] |url| → |storedResponse| of |newestWorker|'s [=script resource map=]: 1. Let |request| be a new [=/request=] whose [=request/url=] is |url|, [=request/client=] is |job|'s [=job/client=], [=request/destination=] is "`script`", [=request/parser metadata=] is "`not parser-inserted`", [=request/synchronous flag=] is set, and whose [=request/use-URL-credentials flag=] is set. 1. Set |request|'s [=request/cache mode=] to "`no-cache`" if any of the following are true: * |registration|'s [=service worker registration/update via cache mode=] is "`none`". @@ -2460,7 +2460,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |worker| be a new [=/service worker=]. 1. Set |worker|'s [=service worker/script url=] to |job|'s [=job/script url=], |worker|'s script resource to |script|, and |worker|'s [=service worker/type=] to |job|'s worker type. 1. [=map/For each=] |url| → |response| of |updatedResourceMap|: - 1. Set |worker|'s [=service worker/script resource map=][|url|] to |response|. + 1. Set |worker|'s [=script resource map=][|url|] to |response|. 1. Set |worker|'s script resource's HTTPS state to |httpsState|. 1. Set |worker|'s script resource's [=script resource/referrer policy=] to |referrerPolicy|. 1. Invoke Run Service Worker algorithm given |worker|, and with the *force bypass cache for importscripts flag* set if |job|'s [=job/force bypass cache flag=] is set. diff --git a/docs/index.html b/docs/index.html index d4930d25..0fe1a74f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1177,9 +1177,9 @@ } - + - + - + - +