From c92c1485583eed0c26a10b5b8dc8ed41ffa8d1e6 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Wed, 7 Jun 2017 05:01:04 +0100 Subject: [PATCH] Changing useCache boolean to updateViaCache enum (#1107) Changing useCache boolean to updateViaCache enum Issue: https://github.com/w3c/ServiceWorker/issues/1104. Tests: https://github.com/w3c/web-platform-tests/pull/5515. HTML change: https://github.com/whatwg/html/commit/b5fcec0fa105de2dd3c3aeeb7ea5c630a7bf5024. --- docs/index.bs | 52 ++++++++------ docs/index.html | 176 +++++++++++++++++++++++++++------------------ docs/v1/index.bs | 34 +++++---- docs/v1/index.html | 132 +++++++++++++++++++++------------- 4 files changed, 238 insertions(+), 156 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 923d6889..3c1887e8 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -202,7 +202,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A [=/service worker registration=] has an associated last update check time. It is initially set to null. - A [=/service worker registration=] has an associated use cache (a boolean). It is initially set to false. + A [=/service worker registration=] has an associated update via cache mode, which is "`imports`", "`all`", or "`none`". It is initially set to "`imports`". A [=/service worker registration=] has an associated uninstalling flag. It is initially unset. @@ -412,7 +412,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe [SameObject] readonly attribute NavigationPreloadManager navigationPreload; readonly attribute USVString scope; - readonly attribute boolean useCache; + readonly attribute ServiceWorkerUpdateViaCache updateViaCache; [NewObject] Promise<void> update(); [NewObject] Promise<boolean> unregister(); @@ -420,6 +420,12 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe // event attribute EventHandler onupdatefound; }; + + enum ServiceWorkerUpdateViaCache { + "imports", + "all", + "none" + }; A {{ServiceWorkerRegistration}} object represents a [=/service worker registration=]. Each {{ServiceWorkerRegistration}} object is associated with a service worker registration (a [=/service worker registration=]). Multiple separate objects implementing the {{ServiceWorkerRegistration}} interface across documents and workers can all be associated with the same [=/service worker registration=] simultaneously. @@ -464,10 +470,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe -
-

{{ServiceWorkerRegistration/useCache}}

+
+

{{ServiceWorkerRegistration/updateViaCache}}

- The useCache attribute *must* return [=ServiceWorkerRegistration/service worker registration=]'s [=service worker registration/use cache=]. + The updateViaCache attribute *must* return [=ServiceWorkerRegistration/service worker registration=]'s [=service worker registration/update via cache mode=].
@@ -564,7 +570,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe dictionary RegistrationOptions { USVString scope; WorkerType type = "classic"; - boolean useCache = false; + ServiceWorkerUpdateViaCache updateViaCache = "imports"; }; @@ -624,7 +630,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |scriptURL| be the result of parsing |scriptURL| with the context object's relevant settings object's API base URL. 1. Let |scopeURL| be null. 1. If |options|.{{RegistrationOptions/scope}} is present, set |scopeURL| to the result of parsing |options|.{{RegistrationOptions/scope}} with the context object's relevant settings object's API base URL. - 1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |p|, |client|, |client|'s creation URL, |options|.{{RegistrationOptions/type}}, and |options|.{{RegistrationOptions/useCache}}. + 1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |p|, |client|, |client|'s creation URL, |options|.{{RegistrationOptions/type}}, and |options|.{{RegistrationOptions/updateViaCache}}. 1. Return |p|.
@@ -1782,14 +1788,14 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If the "scope" target attribute of the Link header is present, set |scopeURL| to the result of parsing the "scope" target attribute with |scriptURL|. 1. Let |workerType| be the "workertype" target attribute of the Link header, or "classic" if no such attribute is present. 1. If |workerType| is not a valid {{WorkerType}} value, abort these steps. - 1. Let |useCache| be true if the Link header has a target attribute named "usecache", otherwise false. - 1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, a new promise, null, |contextURL|, |workerType|, and |useCache|. + 1. Let |updateViaCache| be the "`updateviacache`" [=target attribute=] of the `Link` header, or "`imports`" if no such attribute is present. + 1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, a new promise, null, |contextURL|, |workerType|, and |updateViaCache|.
- When a serviceworker link's <{link}> element is inserted into a document, or a serviceworker link is created on a <{link}> element that is already in a document tree, or the <{link/href}> or <{link/scope}> attributes of the <{link}> element of a serviceworker link is changed, the user agent *should* run these steps: + When a serviceworker link's <{link}> element is inserted into a document, or a serviceworker link is created on a <{link}> element that is already in a document tree, or the <{link/href}>, <{link/scope}>, or <{link/updateviacache}> attributes of the <{link}> element of a serviceworker link is changed, the user agent *should* run these steps: 1. If the <{link/href}> attribute is the empty string, abort these steps. 1. Let |client| be the document's [=ServiceWorkerContainer/service worker client=]. @@ -1799,9 +1805,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If the <{link/scope}> attribute is present, set |scopeURL| to the result of parsing the <{link/scope}> attribute with the <{link}> element's node document's document base URL. 1. Let |workerType| be the <{link/workertype}> attribute, or "classic" if the <{link/workertype}> attribute is omitted. 1. If |workerType| is not a valid {{WorkerType}} value, queue a task to fire an event named error at the <{link}> element, and abort these steps. - 1. Let |useCache| be true if the <{link}> element has a <{link/usecache}> attribute, otherwise false. + 1. Let |updateViaCache| be the <{link/updateviacache}> attribute, or "`imports`" if the <{link/updateviacache}> attribute is omitted. 1. Let |promise| be a new promise. - 1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |promise|, |client|, |client|'s creation URL, |workerType|, and |useCache|. + 1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |promise|, |client|, |client|'s creation URL, |workerType|, and |updateViaCache|. 1. Run the following substeps in parallel: 1. Wait until |promise| settles. 1. If |promise| rejected, queue a task to fire an event named error at the <{link}> element. @@ -1838,7 +1844,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe partial interface HTMLLinkElement { [CEReactions] attribute USVString scope; [CEReactions] attribute WorkerType workerType; - [CEReactions] attribute boolean useCache; + [CEReactions] attribute ServiceWorkerUpdateViaCache updateViaCache; }; @@ -1846,7 +1852,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe The workerType IDL attribute must reflect the element's workertype content attribute. - The useCache IDL attribute must reflect the element's usecache content attribute. + The updateViaCache IDL attribute must reflect the element's updateViaCache content attribute.
@@ -2297,7 +2303,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 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. + * |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|. @@ -2413,7 +2419,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A job has a worker type ("classic" or "module"). - A job has a use cache (a boolean). + A job has an update via cache mode, which is "`imports`", "`all`", or "`none`". A job has a client (a [=/service worker client=]). It is initially null. @@ -2542,7 +2548,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe :: |client|, a [=/service worker client=] :: |referrer|, a [=/URL=] :: |workerType|, a worker type - :: |useCache|, a boolean + :: |updateViaCache|, an [=service worker registration/update via cache mode=] : Output :: none @@ -2558,7 +2564,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If any of the strings in |scopeURL|'s [=url/path=] contains either ASCII case-insensitive "%2f" or ASCII case-insensitive "%5c", reject |promise| with a TypeError and abort these steps. 1. Let |job| be the result of running [=Create Job=] with *register*, |scopeURL|, |scriptURL|, |promise|, and |client|. 1. Set |job|'s [=job/worker type=] to |workerType|. - 1. Set |job|'s [=job/use cache=] to |useCache|. + 1. Set |job|'s [=job/update via cache mode=] to |updateViaCache|. 1. Set |job|'s [=job/referrer=] to |referrer|. 1. Invoke [=Schedule Job=] with |job|. @@ -2584,11 +2590,11 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |registration| is not null, then: 1. If |registration|'s uninstalling flag is set, unset it. 1. Let |newestWorker| be the result of running the Get Newest Worker algorithm passing |registration| as the argument. - 1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=] with the *exclude fragments flag* set, and |job|'s [=job/use cache=]'s value equals |registration|'s [=service worker registration/use cache=]'s value, then: + 1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=] with the *exclude fragments flag* set, and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=], then: 1. Invoke Resolve Job Promise with |job| and the {{ServiceWorkerRegistration}} object which represents |registration|. 1. Invoke Finish Job with |job| and abort these steps. 1. Else: - 1. Invoke Set Registration algorithm with |job|'s [=job/scope url=] and |job|'s [=job/use cache=]. + 1. Invoke Set Registration algorithm with |job|'s [=job/scope url=] and |job|'s [=job/update via cache mode=]. 1. Invoke Update algorithm passing |job| as the argument. @@ -2624,7 +2630,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 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. + * |registration|'s [=service worker registration/update via cache mode=] is not "`all`". * |job|'s [=force bypass cache flag=] is set. * |newestWorker| is not null, and |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. @@ -3192,13 +3198,13 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe : Input :: |scope|, a [=/URL=] - :: |useCache|, a boolean + :: |updateViaCache|, an [=service worker registration/update via cache mode=] : Output :: |registration|, a [=/service worker registration=] 1. Run the following steps atomically. 1. Let |scopeString| be serialized |scope| with the *exclude fragment flag* set. - 1. Let |registration| be a new [=/service worker registration=] whose [=service worker registration/scope url=] is set to |scope| and [=service worker registration/use cache=] is set to |useCache|. + 1. Let |registration| be a new [=/service worker registration=] whose [=service worker registration/scope url=] is set to |scope| and [=service worker registration/update via cache mode=] is set to |updateViaCache|. 1. [=map/Set=] scope to registration map[|scopeString|] to |registration|. 1. Return |registration|. diff --git a/docs/index.html b/docs/index.html index c86dd0d5..72eabea9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1177,7 +1177,7 @@ } } - + - +