Skip to content

Commit

Permalink
Clean up Clients interface methods
Browse files Browse the repository at this point in the history
As a follow-up of the decision to not expose the reserved client, this change
added a filter exclude discarded client. This change also removes the
unnecessary branch that checks whether the environment's creation URL is
trustworthy as now we're dealing with only the clients that are execution ready.
(i.e. the clients must be an environment settings object at least.)

Related issue: #1245.
  • Loading branch information
jungkees committed Jul 1, 2018
1 parent ff36205 commit 30cb8f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
20 changes: 6 additions & 14 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,12 +1174,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Run the following steps [=in parallel=]:
1. Let |targetClients| be a new [=list=].
1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the [=same origin|same=] as the associated [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]:
1. If |client| is an [=environment settings object=], then:
1. If |client| is not a [=secure context=], [=continue=].
1. Else:
1. If |client|’s [=creation URL=] is not a [=potentially trustworthy URL=], [=continue=].
1. If |client|'s [=environment/execution ready flag=] is unset or |client|'s [=discarded flag=] is set, [=continue=].
1. If |client| is not a [=secure context=], [=continue=].
1. If |options|["{{ClientQueryOptions/includeUncontrolled}}"] is false, and if |client|'s [=active service worker=] is not the associated [=ServiceWorkerGlobalScope/service worker=], [=continue=].
1. If |client|'s [=environment/execution ready flag=] is unset, [=continue=].
1. Add |client| to |targetClients|.
1. Let |matchedWindowData| be a new [=list=].
1. Let |matchedClients| be a new [=list=].
Expand Down Expand Up @@ -1263,12 +1260,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Let |promise| be a new <a>promise</a>.
1. Run the following substeps <a>in parallel</a>:
1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the <a lt="same origin">same</a> as the [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]:
1. If |client| is an [=environment settings object=], then:
1. If |client| is not a <a>secure context</a>, continue to the next iteration of the loop.
1. Else:
1. If |client|’s <a>creation URL</a> is not a <a>potentially trustworthy URL</a>, continue to the next iteration of the loop.
1. If |client|'s [=environment/execution ready flag=] is unset or |client|'s [=discarded flag=] is set, [=continue=].
1. If |client| is not a [=secure context=], [=continue=].
1. Let |registration| be the result of running <a>Match Service Worker Registration</a> algorithm passing |client|'s <a>creation URL</a> as the argument.
1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>, continue to the next iteration of the loop.
1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>, [=continue=].
1. If |client|'s <a>active service worker</a> is not the [=ServiceWorkerGlobalScope/service worker=], then:
1. Invoke <a>Handle Service Worker Client Unload</a> with |client| as the argument.
1. Set |client|'s <a>active service worker</a> to [=ServiceWorkerGlobalScope/service worker=].
Expand Down Expand Up @@ -3261,10 +3256,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
: Output
:: none

1. If |client| is an [=environment settings object=], then:
1. If |client| is not a [=secure context=], reject |promise| with a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. Else:
1. If |client|’s [=creation URL=] is not a [=potentially trustworthy URL=], reject |promise| with a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. If |client| is not a [=secure context=], reject |promise| with a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. If |client| is an [=environment settings object=] and is not a [=window client=], then:
1. Let |clientObject| be the result of running [=Create Client=] algorithm with |client| as the argument.
1. Resolve |promise| with |clientObject| and abort these steps.
Expand Down
20 changes: 6 additions & 14 deletions docs/v1/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,12 +1112,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Run the following steps [=in parallel=]:
1. Let |targetClients| be a new [=list=].
1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the [=same origin|same=] as the associated [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]:
1. If |client| is an [=environment settings object=], then:
1. If |client| is not a [=secure context=], [=continue=].
1. Else:
1. If |client|’s [=creation URL=] is not a [=potentially trustworthy URL=], [=continue=].
1. If |client|'s [=environment/execution ready flag=] is unset or |client|'s [=discarded flag=] is set, [=continue=].
1. If |client| is not a [=secure context=], [=continue=].
1. If |options|["{{ClientQueryOptions/includeUncontrolled}}"] is false, and if |client|'s [=active service worker=] is not the associated [=ServiceWorkerGlobalScope/service worker=], [=continue=].
1. If |client|'s [=environment/execution ready flag=] is unset, [=continue=].
1. Add |client| to |targetClients|.
1. Let |matchedWindowData| be a new [=list=].
1. Let |matchedClients| be a new [=list=].
Expand Down Expand Up @@ -1201,12 +1198,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Let |promise| be a new <a>promise</a>.
1. Run the following substeps <a>in parallel</a>:
1. For each [=/service worker client=] |client| whose [=service worker client/origin=] is the <a lt="same origin">same</a> as the [=ServiceWorkerGlobalScope/service worker=]'s [=environment settings object/origin=]:
1. If |client| is an [=environment settings object=], then:
1. If |client| is not a <a>secure context</a>, continue to the next iteration of the loop.
1. Else:
1. If |client|’s <a>creation URL</a> is not a <a>potentially trustworthy URL</a>, continue to the next iteration of the loop.
1. If |client|'s [=environment/execution ready flag=] is unset or |client|'s [=discarded flag=] is set, [=continue=].
1. If |client| is not a [=secure context=], [=continue=].
1. Let |registration| be the result of running <a>Match Service Worker Registration</a> algorithm passing |client|'s <a>creation URL</a> as the argument.
1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>, continue to the next iteration of the loop.
1. If |registration| is not the [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>, [=continue=].
1. If |client|'s <a>active service worker</a> is not the [=ServiceWorkerGlobalScope/service worker=], then:
1. Invoke <a>Handle Service Worker Client Unload</a> with |client| as the argument.
1. Set |client|'s <a>active service worker</a> to [=ServiceWorkerGlobalScope/service worker=].
Expand Down Expand Up @@ -3108,10 +3103,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
: Output
:: none

1. If |client| is an [=environment settings object=], then:
1. If |client| is not a [=secure context=], reject |promise| with a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. Else:
1. If |client|’s [=creation URL=] is not a [=potentially trustworthy URL=], reject |promise| with a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. If |client| is not a [=secure context=], reject |promise| with a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. If |client| is an [=environment settings object=] and is not a [=window client=], then:
1. Let |clientObject| be the result of running [=Create Client=] algorithm with |client| as the argument.
1. Resolve |promise| with |clientObject| and abort these steps.
Expand Down

0 comments on commit 30cb8f1

Please sign in to comment.