diff --git a/docs/index.bs b/docs/index.bs index 0ad25616..b57784d1 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -260,15 +260,49 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
-

Selection and Use

+

Control 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 [=/service worker client=] has an [=active service worker=] that serves its own loading and its subresources. When a [=/service worker client=] has a non-null [=active service worker=], it is said to be controlled by that [=active service worker=]. When a [=/service worker client=] is [=controlled=] by a [=/service worker=], it is said that the [=/service worker client=] is using the [=/service worker=]’s [=containing service worker registration=]. + A [=/service worker client=]'s [=active service worker=] is determined as explained in the following subsections. - 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. + *The rest of the section is non-normative.* - 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 from the environment of a {{Document}} in the [=/service worker client=]'s [=environment settings object/global object=]'s [=owner set=], respectively, if it exists. + Issue: The behavior in this section is not fully specified yet and will be specified in [HTML Standard](https://html.spec.whatwg.org). The work is tracked by the [issue](https://github.com/w3c/ServiceWorker/issues/765) and the [pull request](https://github.com/whatwg/html/pull/2809). - 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. +
+

The window client case

+ + A [=window client=] is [created](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object) when a [=/browsing context=] is [created](https://html.spec.whatwg.org/#creating-a-new-browsing-context) and when it [=navigates=]. + + When a [=window client=] is [created](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object) in the process of a [=/browsing context=] [creation](https://html.spec.whatwg.org/#creating-a-new-browsing-context): + + If the [=/browsing context=]'s initial [=active document=]'s [=/origin=] is an [=opaque origin=], the [=window client=]'s [=active service worker=] is set to null. + Otherwise, it is set to the creator [=document=]'s [=/service worker client=]'s [=active service worker=]. + + When a [=window client=] is [created](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object) in the process of the [=/browsing context=]'s [=navigate|navigation=]: + + If the [=fetch=] is routed through [=/HTTP fetch=], the [=window client=]'s [=active service worker=] is set to the result of the service worker registration matching. + Otherwise, if the created [=document=]'s [=/origin=] is an [=opaque origin=] or not the [=same origin|same=] as its creator [=document=]'s [=/origin=], the [=window client=]'s [=active service worker=] is set to null. + Otherwise, it is set to the creator [=document=]'s [=/service worker client=]'s [=active service worker=]. + + Note: For an initial [=navigate|navigation=] with [=replacement enabled=], the initial [=window client=] that was [created](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object) when the [=/browsing context=] was [created](https://html.spec.whatwg.org/#creating-a-new-browsing-context) is reused, but the [=active service worker=] is determined by the same behavior as above. + + Note: [Sandboxed](https://html.spec.whatwg.org/#attr-iframe-sandbox) [=iframes=] without the sandboxing directives, `allow-same-origin` and `allow-scripts`, result in having the [=active service worker=] value of null as their [=/origin=] is an [=opaque origin=].. +
+ +
+

The worker client case

+ + A [=worker client=] is created when the user agent [=run a worker|runs a worker=]. + + When the [=worker client=] is created: + + When the [=fetch=] is routed through [=/HTTP fetch=], the [=worker client=]'s [=active service worker=] is set to the result of the service worker registration matching. + Otherwise, if the [=worker client=]'s [=service worker client/origin=] is an [=opaque origin=], or the [=/request=]'s [=request/URL=] is a [=blob URL=] and the [=worker client=]'s [=service worker client/origin=] is not the [=same origin|same=] as the [=/origin=] of the last item in the [=worker client=]'s [=/global object=]'s [=owner set=], the [=worker client=]'s [=active service worker=] is set to null. + Otherwise, it is set to the [=active service worker=] of the [=environment settings object=] of the last [=item=] in the [=worker client=]'s [=/global object=]'s [=owner set=]. +
+ + Note: [=Window clients=] and [=worker clients=] with a [data: URL](https://tools.ietf.org/html/rfc2397#section-2) result in having the [=active service worker=] value of null as their [=/origin=] is an [=opaque origin=]. [=Window clients=] and [=worker clients=] with a [=blob URL=] can inherit the [=active service worker=] of their creator [=document=] or owner, but if the [=/request=]'s [=request/origin=] is not the [=same origin|same=] as the [=/origin=] of their creator [=document=] or owner, the [=active service worker=] is set to null.
diff --git a/docs/v1/index.bs b/docs/v1/index.bs index 4576028f..f479d31a 100644 --- a/docs/v1/index.bs +++ b/docs/v1/index.bs @@ -243,15 +243,49 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
-

Selection and Use

+

Control 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 [=/service worker client=] has an [=active service worker=] that serves its own loading and its subresources. When a [=/service worker client=] has a non-null [=active service worker=], it is said to be controlled by that [=active service worker=]. When a [=/service worker client=] is [=controlled=] by a [=/service worker=], it is said that the [=/service worker client=] is using the [=/service worker=]’s [=containing service worker registration=]. + A [=/service worker client=]'s [=active service worker=] is determined as explained in the following subsections. - 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. + *The rest of the section is non-normative.* - 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 from the environment of a {{Document}} in the [=/service worker client=]'s [=environment settings object/global object=]'s [=owner set=], respectively, if it exists. + Note: The behavior in this section is not fully specified yet and will be specified in [HTML Standard](https://html.spec.whatwg.org). The work is tracked by the [issue](https://github.com/w3c/ServiceWorker/issues/765) and the [pull request](https://github.com/whatwg/html/pull/2809). For any Service Workers changes, we will incorporate them into [Service Workers Nightly](https://w3c.github.io/ServiceWorker/). - 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. +
+

The window client case

+ + A [=window client=] is [created](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object) when a [=/browsing context=] is [created](https://html.spec.whatwg.org/#creating-a-new-browsing-context) and when it [=navigates=]. + + When a [=window client=] is [created](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object) in the process of a [=/browsing context=] [creation](https://html.spec.whatwg.org/#creating-a-new-browsing-context): + + If the [=/browsing context=]'s initial [=active document=]'s [=/origin=] is an [=opaque origin=], the [=window client=]'s [=active service worker=] is set to null. + Otherwise, it is set to the creator [=document=]'s [=/service worker client=]'s [=active service worker=]. + + When a [=window client=] is [created](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object) in the process of the [=/browsing context=]'s [=navigate|navigation=]: + + If the [=fetch=] is routed through [=/HTTP fetch=], the [=window client=]'s [=active service worker=] is set to the result of the service worker registration matching. + Otherwise, if the created [=document=]'s [=/origin=] is an [=opaque origin=] or not the [=same origin|same=] as its creator [=document=]'s [=/origin=], the [=window client=]'s [=active service worker=] is set to null. + Otherwise, it is set to the creator [=document=]'s [=/service worker client=]'s [=active service worker=]. + + Note: For an initial [=navigate|navigation=] with [=replacement enabled=], the initial [=window client=] that was [created](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object) when the [=/browsing context=] was [created](https://html.spec.whatwg.org/#creating-a-new-browsing-context) is reused, but the [=active service worker=] is determined by the same behavior as above. + + Note: [Sandboxed](https://html.spec.whatwg.org/#attr-iframe-sandbox) [=iframes=] without the sandboxing directives, `allow-same-origin` and `allow-scripts`, result in having the [=active service worker=] value of null as their [=/origin=] is an [=opaque origin=].. +
+ +
+

The worker client case

+ + A [=worker client=] is created when the user agent [=run a worker|runs a worker=]. + + When the [=worker client=] is created: + + When the [=fetch=] is routed through [=/HTTP fetch=], the [=worker client=]'s [=active service worker=] is set to the result of the service worker registration matching. + Otherwise, if the [=worker client=]'s [=service worker client/origin=] is an [=opaque origin=], or the [=/request=]'s [=request/URL=] is a [=blob URL=] and the [=worker client=]'s [=service worker client/origin=] is not the [=same origin|same=] as the [=/origin=] of the last item in the [=worker client=]'s [=/global object=]'s [=owner set=], the [=worker client=]'s [=active service worker=] is set to null. + Otherwise, it is set to the [=active service worker=] of the [=environment settings object=] of the last [=item=] in the [=worker client=]'s [=/global object=]'s [=owner set=]. +
+ + Note: [=Window clients=] and [=worker clients=] with a [data: URL](https://tools.ietf.org/html/rfc2397#section-2) result in having the [=active service worker=] value of null as their [=/origin=] is an [=opaque origin=]. [=Window clients=] and [=worker clients=] with a [=blob URL=] can inherit the [=active service worker=] of their creator [=document=] or owner, but if the [=/request=]'s [=request/origin=] is not the [=same origin|same=] as the [=/origin=] of their creator [=document=] or owner, the [=active service worker=] is set to null.