diff --git a/docs/index.bs b/docs/index.bs index 9d5e08b9..6399bb2d 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -136,7 +136,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Service Worker

- A service worker is a type of web worker. A [=/service worker=] executes in the registering [=/service worker client=]'s [=/origin=]. + A service worker is a type of web worker. A [=/service worker=] executes in the registering [=/client=]'s [=/origin=]. A [=/service worker=] has an associated state, which is one of *parsed*, *installing*, *installed*, *activating*, *activated*, and *redundant*. It is initially *parsed*. @@ -175,7 +175,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Lifetime

- The lifetime of a [=/service worker=] is tied to the execution lifetime of events and not references held by [=/service worker clients=] to the {{ServiceWorker}} object. + The lifetime of a [=/service worker=] is tied to the execution lifetime of events and not references held by [=/clients=] to the {{ServiceWorker}} object. A user agent *may* terminate [=/service workers=] at any time it: @@ -214,36 +214,38 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Lifetime

- A user agent *must* persistently keep a list of registered [=/service worker registrations=] unless otherwise they are explicitly unregistered. A user agent has a scope to registration map that stores the entries of the tuple of [=/service worker registration=]'s [=service worker registration/scope url=] and the corresponding [=/service worker registration=]. The lifetime of [=/service worker registrations=] is beyond that of the {{ServiceWorkerRegistration}} objects which represent them within the lifetime of their corresponding [=/service worker clients=]. + A user agent *must* persistently keep a list of registered [=/service worker registrations=] unless otherwise they are explicitly unregistered. A user agent has a scope to registration map that stores the entries of the tuple of [=/service worker registration=]'s [=service worker registration/scope url=] and the corresponding [=/service worker registration=]. The lifetime of [=/service worker registrations=] is beyond that of the {{ServiceWorkerRegistration}} objects which represent them within the lifetime of their corresponding [=/clients=].
-
-

Service Worker Client

+
+

Client

- A service worker client is a type of environment or environment settings object. + A client is a type of environment or environment settings object. - A [=/service worker client=] has an algorithm defined as the origin that returns the [=/service worker client=]'s creation URL's [=url/origin=] if the [=/service worker client=] is a type of environment, and the [=/service worker client=]'s [=environment settings object/origin=] otherwise. + A [=/client=] has an algorithm defined as the origin that returns the [=/client=]'s creation URL's [=url/origin=] if the [=/client=] is a type of environment, and the [=/client=]'s [=environment settings object/origin=] otherwise. - A window client is a [=/service worker client=] whose [=environment settings object/global object=] is a {{Window}} object. + A window client is a [=/client=] whose [=environment settings object/global object=] is a {{Window}} object. - A dedicated worker client is a [=/service worker client=] whose [=environment settings object/global object=] is a {{DedicatedWorkerGlobalScope}} object. + A dedicated worker client is a [=/client=] whose [=environment settings object/global object=] is a {{DedicatedWorkerGlobalScope}} object. - A shared worker client is a [=/service worker client=] whose [=environment settings object/global object=] is a {{SharedWorkerGlobalScope}} object. + A shared worker client is a [=/client=] whose [=environment settings object/global object=] is a {{SharedWorkerGlobalScope}} object. - A worker client is either a dedicated worker client or a shared worker client. + A service worker client is a [=/client=] whose [=environment settings object/global object=] is a {{ServiceWorkerGlobalScope}} object. + + A worker client is a dedicated worker client, a shared worker client, or a service worker client.

Selection and Use

- A [=/service worker client=] independently selects and uses a [=/service worker registration=] for its own loading and its subresources. The selection of a [=/service worker registration=], upon a non-subresource request, is a process of either matching a [=/service worker registration=] from scope to registration map or inheriting an existing [=/service worker registration=] from its parent or owner context depending on the request's [=request/url=]. + A [=/client=] independently selects and uses a [=/service worker registration=] for its own loading and its subresources. The selection of a [=/service worker registration=], upon a non-subresource request, is a process of either matching a [=/service worker registration=] from scope to registration map or inheriting an existing [=/service worker registration=] from its parent or owner context depending on the request's [=request/url=]. - When the request's [=request/url=] is not local, a [=/service worker client=] matches a [=/service worker registration=] from scope to registration map. That is, the [=/service worker client=] attempts to consult a [=/service worker registration=] whose [=service worker registration/scope url=] matches its creation URL. + When the request's [=request/url=] is not local, a [=/client=] matches a [=/service worker registration=] from scope to registration map. That is, the [=/client=] attempts to consult a [=/service worker registration=] whose [=service worker registration/scope url=] matches its creation URL. - When the request's [=request/url=] is local, if the [=/service worker client=]'s responsible browsing context is a nested browsing context or the [=/service worker client=] is a worker client, the [=/service worker client=] inherits the [=/service worker registration=] from its parent browsing context's environment or one of the worker's Documents' environment, respectively, if it exists. + When the request's [=request/url=] is local, if the [=/client=]'s responsible browsing context is a nested browsing context or the [=/client=] is a worker client, the [=/client=] inherits the [=/service worker registration=] from its parent browsing context's environment or one of the worker's Documents' environment, respectively, if it exists. - If the selection was successful, the selected [=/service worker registration=]'s active worker starts to control the [=/service worker client=]. Otherwise, the flow returns to [=/fetch=] where it falls back to the default behavior. When a [=/service worker client=] is controlled by an active worker, it is considered that the [=/service worker client=] is using the active worker's containing service worker registration. + If the selection was successful, the selected [=/service worker registration=]'s active worker starts to control the [=/client=]. Otherwise, the flow returns to [=/fetch=] where it falls back to the default behavior. When a [=/client=] is controlled by an active worker, it is considered that the [=/client=] is using the active worker's containing service worker registration.
@@ -479,7 +481,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
- Note: The {{ServiceWorkerRegistration/unregister()}} method unregisters the [=/service worker registration=]. It is important to note that the currently controlled [=/service worker client=]'s active service worker's containing service worker registration is effective until all the [=/service worker clients=] (including itself) using this [=/service worker registration=] unload. That is, the {{ServiceWorkerRegistration/unregister()}} method only affects subsequent navigations. + Note: The {{ServiceWorkerRegistration/unregister()}} method unregisters the [=/service worker registration=]. It is important to note that the currently controlled [=/client=]'s active service worker's containing service worker registration is effective until all the [=/clients=] (including itself) using this [=/service worker registration=] unload. That is, the {{ServiceWorkerRegistration/unregister()}} method only affects subsequent navigations. unregister() method *must* run these steps: @@ -561,7 +563,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A {{ServiceWorkerContainer}} provides capabilities to register, unregister, and update the [=/service worker registrations=], and provides access to the state of the [=/service worker registrations=] and their associated [=/service workers=]. - A {{ServiceWorkerContainer}} has an associated service worker client, which is a [=/service worker client=] whose [=environment settings object/global object=] is associated with the {{Navigator}} object or the {{WorkerNavigator}} object that the {{ServiceWorkerContainer}} is retrieved from. + A {{ServiceWorkerContainer}} has an associated client, which is a [=/client=] whose [=environment settings object/global object=] is associated with the {{Navigator}} object or the {{WorkerNavigator}} object that the {{ServiceWorkerContainer}} is retrieved from. A {{ServiceWorkerContainer}} object has an associated ready promise (a promise). It is initially set to a new promise. @@ -572,7 +574,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe controller attribute *must* run these steps: - 1. Let |client| be the context object's [=ServiceWorkerContainer/service worker client=]. + 1. Let |client| be the context object's [=ServiceWorkerContainer/client=]. 1. Return the {{ServiceWorker}} object that represents |client|'s active service worker. Note: {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} returns null if the request is a force refresh (shift+refresh). The {{ServiceWorker}} objects returned from this attribute getter that represent the same [=/service worker=] are the same objects. @@ -584,7 +586,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe ready attribute *must* run these steps: 1. If the context object's [=ServiceWorkerContainer/ready promise=] is settled, return the context object's [=ServiceWorkerContainer/ready promise=]. - 1. Let |client| be the context object's [=ServiceWorkerContainer/service worker client=]. + 1. Let |client| be the context object's [=ServiceWorkerContainer/client=]. 1. Let |registration| be null. 1. Let |clientURL| be |client|'s creation URL. 1. Run the following substeps in parallel: @@ -611,7 +613,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe register(|scriptURL|, |options|) method *must* run these steps: 1. Let |p| be a promise. - 1. Let |client| be the context object's [=ServiceWorkerContainer/service worker client=]. + 1. Let |client| be the context object's [=ServiceWorkerContainer/client=]. 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. @@ -624,7 +626,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe getRegistration(|clientURL|) method *must* run these steps: - 1. Let |client| be the context object's [=ServiceWorkerContainer/service worker client=]. + 1. Let |client| be the context object's [=ServiceWorkerContainer/client=]. 1. Let |clientURL| be the result of parsing |clientURL| with the context object's relevant settings object's API base URL. 1. If |clientURL| is failure, return a promise rejected with a TypeError. 1. If the [=environment settings object/origin=] of |clientURL| is not |client|'s [=environment settings object/origin=], return a |promise| rejected with a "{{SecurityError}}" exception. @@ -643,7 +645,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe getRegistrations() method *must* run these steps: - 1. Let |client| be the context object's [=ServiceWorkerContainer/service worker client=]. + 1. Let |client| be the context object's [=ServiceWorkerContainer/client=]. 1. Let |promise| be a new promise. 1. Run the following substeps in parallel: 1. Let |array| be an empty array. @@ -741,7 +743,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe controllerchange {{Event}} - The [=ServiceWorkerContainer/service worker client=]'s active service worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a [=/service worker=] causes activation of the [=/service worker registration=] to occur while [=/service worker clients=] are using the [=/service worker registration=], {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the active worker as the [=/service worker=] that controls the [=/service worker client=].) + The [=ServiceWorkerContainer/client=]'s active service worker changes. (See step 9.2 of the Activate algorithm. The skip waiting flag of a [=/service worker=] causes activation of the [=/service worker registration=] to occur while [=/clients=] are using the [=/service worker registration=], {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the active worker as the [=/service worker=] that controls the [=/client=].) @@ -880,7 +882,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A {{ServiceWorkerGlobalScope}} object represents the global execution context of a [=/service worker=]. A {{ServiceWorkerGlobalScope}} object has an associated service worker (a [=/service worker=]). A {{ServiceWorkerGlobalScope}} object has an associated force bypass cache for importscripts flag. It is initially unset. - Note: {{ServiceWorkerGlobalScope}} object provides generic, event-driven, time-limited script execution contexts that run at an origin. Once successfully registered, a [=/service worker=] is started, kept alive and killed by their relationship to events, not [=/service worker clients=]. Any type of synchronous requests must not be initiated inside of a [=/service worker=]. + Note: {{ServiceWorkerGlobalScope}} object provides generic, event-driven, time-limited script execution contexts that run at an origin. Once successfully registered, a [=/service worker=] is started, kept alive and killed by their relationship to events, not [=/clients=]. Any type of synchronous requests must not be initiated inside of a [=/service worker=].

{{ServiceWorkerGlobalScope/clients}}

@@ -897,7 +899,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

{{ServiceWorkerGlobalScope/skipWaiting()}}

- Note: The {{ServiceWorkerGlobalScope/skipWaiting()}} method allows this [=/service worker=] to progress from the [=service worker/registration=]'s waiting position to active even while [=/service worker clients=] are using the [=service worker/registration=]. + Note: The {{ServiceWorkerGlobalScope/skipWaiting()}} method allows this [=/service worker=] to progress from the [=service worker/registration=]'s waiting position to active even while [=/clients=] are using the [=service worker/registration=]. skipWaiting() method *must* run these steps: @@ -969,26 +971,26 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe }; - A {{Client}} object has an associated service worker client (a [=/service worker client=]). + A {{Client}} object has an associated client (a [=/client=]). A {{Client}} object has an associated reserved state, which is either true or false. - A {{WindowClient}} object has an associated visibility state, which is one of {{Document/visibilityState}} attribute value. + A {{WindowClient}} object has an associated visibility state, which is one of {{Document/visibilityState}} attribute value. - A {{WindowClient}} object has an associated focus state, which is either true or false (initially false). + A {{WindowClient}} object has an associated focus state, which is either true or false (initially false). A {{WindowClient}} object has an associated ancestor origins array.

{{Client/url}}

- The url attribute *must* return the context object's associated [=Client/service worker client=]'s serialized creation URL. + The url attribute *must* return the context object's associated [=Client/client=]'s serialized creation URL.

{{Client/id}}

- The id attribute *must* return its associated [=Client/service worker client=]'s [=environment/id=]. + The id attribute *must* return its associated [=Client/client=]'s [=environment/id=].
@@ -996,9 +998,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe The type attribute *must* run these steps: - 1. If the [=context object=]'s [=Client/service worker client=] is a type of [=environment=] or is a [=window client=], return {{ClientType/"window"}}. - 1. Else if the [=context object=]'s [=Client/service worker client=] is a [=dedicated worker client=], return {{ClientType/"worker"}}. - 1. Else if the [=context object=]'s [=Client/service worker client=] is a [=shared worker client=], return {{ClientType/"sharedworker"}}. + 1. If the [=context object=]'s [=Client/client=] is a type of [=environment=] or is a [=window client=], return {{ClientType/"window"}}. + 1. Else if the [=context object=]'s [=Client/client=] is a [=dedicated worker client=], return {{ClientType/"worker"}}. + 1. Else if the [=context object=]'s [=Client/client=] is a [=shared worker client=], return {{ClientType/"sharedworker"}}. + 1. Else if the [=context object=]'s [=Client/client=] is a [=service worker client=], return {{ClientType/"serviceworker"}}.
@@ -1013,7 +1016,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe The postMessage(|message|, |transfer|) method *must* run these steps: 1. Let |sourceSettings| be the context object's relevant settings object. - 1. Let |destination| be the {{ServiceWorkerContainer}} object whose [=ServiceWorkerContainer/service worker client=] is the context object's [=Client/service worker client=]. + 1. Let |destination| be the {{ServiceWorkerContainer}} object whose [=ServiceWorkerContainer/client=] is the context object's [=Client/client=]. 1. If |destination| is null, throw an "{{InvalidStateError}}" exception. 1. Let |targetRealm| be |destination|'s relevant Realm. 1. Let |cloneRecord| be StructuredCloneWithTransfer(|message|, |transfer|, |targetRealm|). If this throws an exception, rethrow that exception and abort these steps. @@ -1043,7 +1046,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

{{WindowClient/ancestorOrigins}}

- The ancestorOrigins attribute *must* return the context object's associated [=Client/service worker client=]'s [=WindowClient/ancestor origins array=]. + The ancestorOrigins attribute *must* return the context object's associated [=Client/client=]'s [=WindowClient/ancestor origins array=].
@@ -1054,17 +1057,17 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If this algorithm is not triggered by user activation, return a promise rejected with an "{{InvalidAccessError}}" exception. 1. Let |promise| be a new promise. 1. Run these substeps in parallel: - 1. Let |browsingContext| be the context object's associated [=Client/service worker client=]'s [=environment settings object/global object=]'s [=/browsing context=]. + 1. Let |browsingContext| be the context object's associated [=Client/client=]'s [=environment settings object/global object=]'s [=/browsing context=]. 1. Let |visibilityState| be null. 1. Let |focusState| be false. 1. Let |ancestorOrigins| be the empty array. - 1. Queue a task |task| to run the following substeps on the context object's associated [=Client/service worker client=]'s responsible event loop using the user interaction task source: + 1. Queue a task |task| to run the following substeps on the context object's associated [=Client/client=]'s responsible event loop using the user interaction task source: 1. Run the focusing steps with |browsingContext|. 1. Set |visibilityState| to |browsingContext|'s active document's {{Document/visibilityState}} attribute value. 1. Set |focusState| to the result of running the has focus steps with |browsingContext|'s active document as the argument. 1. Set |ancestorOrigins| to |browsingContext|'s active document's relevant global object's {{Location}} object's [=Location/ancestor origins array=]. 1. Wait for |task| to have executed. - 1. Let |windowClient| be the result of running Create Window Client algorithm with the context object's associated [=Client/service worker client=], |visibilityState|, |focusState|, and |ancestorOrigins| as the arguments. + 1. Let |windowClient| be the result of running Create Window Client algorithm with the context object's associated [=Client/client=], |visibilityState|, |focusState|, and |ancestorOrigins| as the arguments. 1. If |windowClient|'s focus state is true, resolve |promise| with |windowClient|. 1. Else, reject |promise| with a TypeError. 1. Return |promise|. @@ -1078,16 +1081,16 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |url| be the result of parsing |url| with the context object's relevant settings object's API base URL. 1. If |url| is failure, return a promise rejected with a TypeError. 1. If |url| is about:blank, return a promise rejected with a TypeError. - 1. If the context object's associated [=Client/service worker client=]'s active service worker is not the context object's relevant global object's [=ServiceWorkerGlobalScope/service worker=], return a promise rejected with a TypeError. + 1. If the context object's associated [=Client/client=]'s active service worker is not the context object's relevant global object's [=ServiceWorkerGlobalScope/service worker=], return a promise rejected with a TypeError. 1. Let |promise| be a new promise. 1. Run these substeps in parallel: - 1. Let |browsingContext| be the context object's associated [=Client/service worker client=]'s [=environment settings object/global object=]'s [=/browsing context=]. + 1. Let |browsingContext| be the context object's associated [=Client/client=]'s [=environment settings object/global object=]'s [=/browsing context=]. 1. If |browsingContext| has discarded its {{Document}}, reject |promise| with a TypeError and abort these steps. 1. Let |navigateFailed| to false. 1. Let |visibilityState| be null. 1. Let |focusState| be false. 1. Let |ancestorOrigins| be the empty array. - 1. Queue a task |task| to run the following substeps on the context object's associated [=Client/service worker client=]'s responsible event loop using the user interaction task source: + 1. Queue a task |task| to run the following substeps on the context object's associated [=Client/client=]'s responsible event loop using the user interaction task source: 1. *HandleNavigate*: Navigate |browsingContext| to |url| with exceptions enabled. The source browsing context must be |browsingContext|. 1. If the algorithm steps invoked in the step labeled *HandleNavigate* throws an exception, set |navigateFailed| to true. 1. Set |visibilityState| to |browsingContext|'s active document's {{Document/visibilityState}} attribute value. @@ -1129,6 +1132,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe "window", "worker", "sharedworker", + "serviceworker", "all" }; @@ -1142,7 +1146,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |promise| be a new promise. 1. Run these substeps in parallel: - 1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the same as the associated [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]: + 1. For each [=/client=] |client| whose [=client/origin=] is the same as the associated [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]: 1. If |client|'s [=environment/id=] is not |id|, continue to the next iteration of the loop. 1. If |client| is a type of environment, then: 1. If |client|’s creation URL is not a potentially trustworthy URL, reject |promise| with a "{{SecurityError}}" exception and abort these steps. @@ -1177,7 +1181,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |promise| be a new promise. 1. Run these substeps in parallel: 1. Let |targetClients| be an empty array. - 1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the same as the associated [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]: + 1. For each [=/client=] |client| whose [=client/origin=] is the same as the associated [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]: 1. If |client| is a type of environment, then: 1. If |client|’s creation URL is not a potentially trustworthy URL, continue to the next iteration of the loop. 1. Else: @@ -1188,7 +1192,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |client|'s [=environment/execution ready flag=] is unset, continue to the next iteration of the loop. 1. Add |client| to |targetClients|. 1. Let |matchedClients| be an empty array. - 1. For each [=/service worker client=] |client| in |targetClients|: + 1. For each [=/client=] |client| in |targetClients|: + 1. If |client|'s [=environment settings object/global object=] is the [=current global object=], then continue to the next iteration of the loop. 1. If |options|.{{ClientQueryOptions/type}} is {{ClientType/"window"}} or {{ClientType/"all"}}, and |client| is a type of environment or is a window client, then: 1. Let |browsingContext| be null. 1. Let |isClientEnumerable| be true. @@ -1210,13 +1215,19 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |isClientEnumerable| is true, then: 1. Let |windowClient| be the result of running Create Window Client algorithm with |client|, |visibilityState|, |focusState|, and |ancestorOrigins| as the arguments. 1. Add |windowClient| to |matchedClients|. - 1. Else if |options|.{{ClientQueryOptions/type}} is {{ClientType/"worker"}} or {{ClientType/"all"}} and |client| is a dedicated worker client, or |options|.{{ClientQueryOptions/type}} is {{ClientType/"sharedworker"}} or {{ClientType/"all"}} and |client| is a shared worker client, then: + 1. Else if |options|.{{ClientQueryOptions/type}} is {{ClientType/"worker"}} or {{ClientType/"all"}} and |client| is a dedicated worker client, then: + 1. Let |clientObject| be the result of running Create Client algorithm with |client| as the argument. + 1. Add |clientObject| to |matchedClients|. + 1. Else if |options|.{{ClientQueryOptions/type}} is {{ClientType/"sharedworker"}} or {{ClientType/"all"}} and |client| is a shared worker client, then: + 1. Let |clientObject| be the result of running Create Client algorithm with |client| as the argument. + 1. Add |clientObject| to |matchedClients|. + 1. Else if |options|.{{ClientQueryOptions/type}} is {{ClientType/"serviceworker"}} or {{ClientType/"all"}} and |client| is a service worker client, then: 1. Let |clientObject| be the result of running Create Client algorithm with |client| as the argument. 1. Add |clientObject| to |matchedClients|. 1. Sort |matchedClients| such that: - * {{WindowClient}} objects are always placed before {{Client}} objects whose associated [=Client/service worker clients=] are worker clients. - * {{WindowClient}} objects that have been focused are placed first sorted in the most recently focused order, and {{WindowClient}} objects that have never been focused are placed next sorted in their [=Client/service worker clients=]' creation order. - * {{Client}} objects whose associated [=Client/service worker clients=] are worker clients are placed next sorted in their [=Client/service worker clients=]' creation order. + * {{WindowClient}} objects are always placed before {{Client}} objects whose associated [=Client/clients=] are worker clients. + * {{WindowClient}} objects that have been focused are placed first sorted in the most recently focused order, and {{WindowClient}} objects that have never been focused are placed next sorted in their [=Client/clients=]' creation order. + * {{Client}} objects whose associated [=Client/clients=] are worker clients are placed next sorted in their [=Client/clients=]' creation order. 1. Resolve |promise| with |matchedClients|. 1. Return |promise|.
@@ -1260,7 +1271,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If the [=ServiceWorkerGlobalScope/service worker=] is not an active worker, return a promise rejected with an "{{InvalidStateError}}" exception. 1. Let |promise| be a new promise. 1. Run the following substeps in parallel: - 1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the same as the [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]: + 1. For each [=/client=] |client| whose [=client/origin=] is the same as the [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]: 1. If |client| is a type of environment, then: 1. If |client|’s creation URL is not a potentially trustworthy URL, continue to the next iteration of the loop. 1. Else: @@ -1268,7 +1279,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |registration| be the result of running Match Service Worker Registration algorithm passing |client|'s creation URL as the argument. 1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s containing service worker registration, continue to the next iteration of the loop. 1. If |client|'s active service worker is not the [=ServiceWorkerGlobalScope/service worker=], then: - 1. Invoke Handle Service Worker Client Unload with |client| as the argument. + 1. Invoke Handle Client Unload with |client| as the argument. 1. Set |client|'s active service worker to [=ServiceWorkerGlobalScope/service worker=]. 1. Invoke Notify Controller Change algorithm with |client| as the argument. 1. Resolve |promise| with undefined. @@ -1659,7 +1670,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

{{ExtendableMessageEvent/origin|event.origin}}

- The origin attribute *must* return the value it was initialized to. When the object is created, this attribute *must* be initialized to the empty string. It represents the [=environment settings object/origin=] of the [=/service worker client=] that sent the message. + The origin attribute *must* return the value it was initialized to. When the object is created, this attribute *must* be initialized to the empty string. It represents the [=environment settings object/origin=] of the [=/client=] that sent the message.
@@ -1755,7 +1766,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 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: 1. If the <{link/href}> attribute is the empty string, abort these steps. - 1. Let |client| be the document's [=ServiceWorkerContainer/service worker client=]. + 1. Let |client| be the document's [=ServiceWorkerContainer/client=]. 1. If |client| is not a secure context, queue a task to fire an event named error at the <{link}> element, and abort these steps. 1. Let |scriptURL| be the result of parsing the <{link/href}> attribute with the <{link}> element's node document's document base URL. 1. Let |scopeURL| be null. @@ -2222,7 +2233,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Secure Context

- [=/Service workers=] *must* execute in secure contexts. [=/Service worker clients=] *must* also be secure contexts to register a [=/service worker registration=], to get access to the [=/service worker registrations=] and the [=/service workers=], to do messaging with the [=/service workers=], and to be manipulated by the [=/service workers=]. This effectively means that [=/service workers=] and their [=/service worker clients=] *should* be hosted over HTTPS. A user agent *may* allow localhost, 127.0.0.0/8, and ::1/128 for development purpose. (Note that they may still be secure contexts.) The primary reason for this restriction is to protect users from the risks associated with insecure contexts. + [=/Service workers=] *must* execute in secure contexts. [=/clients=] *must* also be secure contexts to register a [=/service worker registration=], to get access to the [=/service worker registrations=] and the [=/service workers=], to do messaging with the [=/service workers=], and to be manipulated by the [=/service workers=]. This effectively means that [=/service workers=] and their [=/clients=] *should* be hosted over HTTPS. A user agent *may* allow localhost, 127.0.0.0/8, and ::1/128 for development purpose. (Note that they may still be secure contexts.) The primary reason for this restriction is to protect users from the risks associated with insecure contexts.
@@ -2244,7 +2255,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe *This section is non-normative.* - A [=/service worker=] executes in the registering [=/service worker client=]'s [=environment settings object/origin=]. One of the advanced concerns that major applications would encounter is whether they can be hosted from a CDN. By definition, these are servers in other places, often on other [=/origins=]. Therefore, [=/service workers=] cannot be hosted on CDNs. But they can include resources via importScripts(). The reason for this restriction is that [=/service workers=] create the opportunity for a bad actor to turn a bad day into a bad eternity. + A [=/service worker=] executes in the registering [=/client=]'s [=environment settings object/origin=]. One of the advanced concerns that major applications would encounter is whether they can be hosted from a CDN. By definition, these are servers in other places, often on other [=/origins=]. Therefore, [=/service workers=] cannot be hosted on CDNs. But they can include resources via importScripts(). The reason for this restriction is that [=/service workers=] create the opportunity for a bad actor to turn a bad day into a bad eternity.
@@ -2374,7 +2385,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A job has a use cache (a boolean). - A job has a client (a [=/service worker client=]). It is initially null. + A job has a client (a [=/client=]). It is initially null. A job has a referrer (a [=/URL=] or null). @@ -2401,7 +2412,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe :: |scopeURL|, a [=/URL=] :: |scriptURL|, a [=/URL=] :: |promise|, a promise - :: |client|, a [=/service worker client=] + :: |client|, a [=/client=] : Output :: |job|, a job @@ -2498,7 +2509,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe :: |scopeURL|, a [=/URL=] or failure or null :: |scriptURL|, a [=/URL=] or failure :: |promise|, a promise - :: |client|, a [=/service worker client=] + :: |client|, a [=/client=] :: |referrer|, a [=/URL=] :: |workerType|, a worker type :: |useCache|, a boolean @@ -2689,7 +2700,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Run the Update Worker State algorithm passing |registration|'s installing worker and *installing* as the arguments. 1. Assert: |job|'s [=job/job promise=] is not null. 1. Invoke Resolve Job Promise with |job| and the {{ServiceWorkerRegistration}} object which represents |registration|. - 1. Queue a task to fire an event named updatefound at all the {{ServiceWorkerRegistration}} objects for all the [=/service worker clients=] whose creation URL matches |registration|'s [=service worker registration/scope url=] and all the [=/service workers=] whose containing service worker registration is |registration|. + 1. Queue a task to fire an event named updatefound at all the {{ServiceWorkerRegistration}} objects for all the [=/clients=] whose creation URL matches |registration|'s [=service worker registration/scope url=] and all the [=/service workers=] whose containing service worker registration is |registration|. 1. Let |installingWorker| be |registration|'s installing worker. 1. Invoke Run Service Worker algorithm given |installingWorker|, and with the *force bypass cache for importscripts flag* set if |job|'s [=job/force bypass cache flag=] is set. 1. Queue a task |task| to run the following substeps: @@ -2721,7 +2732,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |redundantWorker| is not null, run the Update Worker State algorithm passing |redundantWorker| and *redundant* as the arguments. 1. Invoke Finish Job with |job|. 1. Wait for all the tasks queued by Update Worker State invoked in this algorithm have executed. - 1. Wait until no [=/service worker client=] is using |registration| or |registration|'s waiting worker's skip waiting flag is set. + 1. Wait until no [=/client=] is using |registration| or |registration|'s waiting worker's skip waiting flag is set. 1. If |registration|'s waiting worker is not null, invoke Activate algorithm with |registration| as its argument.
@@ -2746,13 +2757,13 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe Note: Once an active worker is activating, neither a runtime script error nor a force termination of the active worker prevents the active worker from getting activated. 1. If |redundantWorker| is not null, run the Update Worker State algorithm passing |redundantWorker| and *redundant* as the arguments. - 1. For each [=/service worker client=] |client| whose creation URL matches |registration|'s [=service worker registration/scope url=]: + 1. For each [=/client=] |client| whose creation URL matches |registration|'s [=service worker registration/scope url=]: 1. If |client| is a window client, unassociate |client|'s responsible document from its application cache, if it has one. 1. Else if |client| is a shared worker client, unassociate |client|'s [=environment settings object/global object=] from its application cache, if it has one. Note: Resources will now use the service worker registration instead of the existing application cache. - 1. For each [=/service worker client=] |client| who is using |registration|: + 1. For each [=/client=] |client| who is using |registration|: 1. Set |client|'s active worker to |registration|'s active worker. 1. Invoke Notify Controller Change algorithm with |client| as the argument. 1. Let |activeWorker| be |registration|'s active worker. @@ -2800,7 +2811,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe : The API base URL :: Return |serviceWorker|'s [=service worker/script url=]. : The [=environment settings object/origin=] - :: Return its registering [=/service worker client=]'s [=environment settings object/origin=]. + :: Return its registering [=/client=]'s [=environment settings object/origin=]. : The creation URL :: Return |workerGlobalScope|'s [=WorkerGlobalScope/url=]. : The [=environment settings object/HTTPS state=] @@ -2901,7 +2912,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Resolve |preloadResponse| with |navigationPreloadResponse|. 1. Else, resolve |preloadResponse| with undefined. - Note: From this point, the [=/service worker client=] starts to use its active service worker's containing service worker registration. + Note: From this point, the [=/client=] starts to use its active service worker's containing service worker registration. 1. Else if |request| is a subresource request, then: 1. If |client|'s active service worker is non-null, set |registration| to |client|'s active service worker's containing service worker registration. @@ -3062,19 +3073,19 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
-

Handle Service Worker Client Unload

+

Handle Client Unload

- The user agent *must* run these steps when a [=/service worker client=] unloads by unloading, being killed, or terminating. + The user agent *must* run these steps when a [=/client=] unloads by unloading, being killed, or terminating. : Input - :: |client|, a [=/service worker client=] + :: |client|, a [=/client=] : Output :: None 1. Run the following steps atomically. 1. Let |registration| be the [=/service worker registration=] used by |client|. 1. If |registration| is null, abort these steps. - 1. If any other [=/service worker client=] is using |registration|, abort these steps. + 1. If any other [=/client=] is using |registration|, abort these steps. 1. If |registration|'s uninstalling flag is set, invoke Clear Registration algorithm passing |registration| as its argument and abort these steps. 1. If |registration|'s waiting worker is not null, run Activate algorithm with |registration| as the argument.
@@ -3112,9 +3123,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Invoke Finish Job with |job| and abort these steps. 1. Set |registration|'s uninstalling flag. 1. Invoke Resolve Job Promise with |job| and true. - 1. If no [=/service worker client=] is using |registration|, invoke Clear Registration algorithm passing |registration| as its argument. + 1. If no [=/client=] is using |registration|, invoke Clear Registration algorithm passing |registration| as its argument. - Note: When the registration is being used for a client, the deletion of the registration is handled by the Handle Service Worker Client Unload algorithm. + Note: When the registration is being used for a client, the deletion of the registration is handled by the Handle Client Unload algorithm. 1. Invoke Finish Job with |job|.
@@ -3242,12 +3253,12 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Notify Controller Change

: Input - :: |client|, a [=/service worker client=] + :: |client|, a [=/client=] : Output :: None 1. Assert: |client| is not null. - 1. If |client| is a type of environment settings object, queue a task to fire an event named controllerchange at the {{ServiceWorkerContainer}} object |client| is [=ServiceWorkerContainer/service worker client|associated=] with. + 1. If |client| is a type of environment settings object, queue a task to fire an event named controllerchange at the {{ServiceWorkerContainer}} object |client| is [=ServiceWorkerContainer/client|associated=] with. The task *must* use |client|'s responsible event loop and the DOM manipulation task source.
@@ -3332,12 +3343,12 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Create Client

: Input - :: |client|, a [=/service worker client=] + :: |client|, a [=/client=] : Output :: |clientObject|, a {{Client}} object 1. Let |clientObject| be a new {{Client}} object. - 1. Set |clientObject|'s [=Client/service worker client=] to |client|. + 1. Set |clientObject|'s [=Client/client=] to |client|. 1. Set |clientObject|'s [=Client/reserved state=] to true if |client|'s [=environment/execution ready flag=] is unset, and false otherwise. 1. Return |clientObject|.
@@ -3346,7 +3357,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

Create Window Client

: Input - :: |client|, a [=/service worker client=] + :: |client|, a [=/client=] :: |visibilityState|, a string :: |focusState|, a boolean :: |ancestorOrigins|, an array @@ -3354,7 +3365,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe :: |windowClient|, a {{WindowClient}} object 1. Let |windowClient| be a new {{WindowClient}} object. - 1. Set |windowClient|'s [=Client/service worker client=] to |client|. + 1. Set |windowClient|'s [=Client/client=] to |client|. 1. Set |windowClient|'s visibility state to |visibilityState|. 1. Set |windowClient|'s focus state to |focusState|. 1. Set |windowClient|'s [=WindowClient/ancestor origins array=] to |ancestorOrigins|. @@ -3559,4 +3570,4 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe The authors would also like to thank Dimitri Glazkov for his scripts and formatting tools which have been essential in the production of this specification. The authors are also grateful for his considerable guidance. Thanks also to Vivian Cromwell, Greg Simon, Alex Komoroske, Wonsuk Lee, and Seojin Kim for their considerable professional support. -
\ No newline at end of file +