Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Client type for ServiceWorkerGlobalScope environments #1074

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

A <dfn export id="dfn-sharedworker-client">shared worker client</dfn> is a [=/client=] whose [=environment settings object/global object=] is a {{SharedWorkerGlobalScope}} object.

A <dfn export id="dfn-worker-client">worker client</dfn> is either a <a>dedicated worker client</a> or a <a>shared worker client</a>.
A <dfn export id="dfn-serviceworker-client">service worker client</dfn> is a [=/client=] whose [=environment settings object/global object=] is a {{ServiceWorkerGlobalScope}} object.

A <dfn export id="dfn-worker-client">worker client</dfn> is a <a>dedicated worker client</a>, a <a>shared worker client</a>, or a <a>service worker client</a>.
</section>

<section>
Expand Down Expand Up @@ -999,6 +1001,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
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"}}.
</section>

<section>
Expand Down Expand Up @@ -1129,6 +1132,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
"window",
"worker",
"sharedworker",
"serviceworker",
"all"
};
</pre>
Expand Down Expand Up @@ -1189,6 +1193,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Add |client| to |targetClients|.
1. Let |matchedClients| be an empty array.
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 <a>environment</a> or is a <a>window client</a>, then:
1. Let |browsingContext| be null.
1. Let |isClientEnumerable| be true.
Expand All @@ -1210,7 +1215,13 @@ 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 <a>Create Window Client</a> 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 <a>dedicated worker client</a>, or |options|.{{ClientQueryOptions/type}} is {{ClientType/"sharedworker"}} or {{ClientType/"all"}} and |client| is a <a>shared worker client</a>, then:
1. Else if |options|.{{ClientQueryOptions/type}} is {{ClientType/"worker"}} or {{ClientType/"all"}} and |client| is a <a>dedicated worker client</a>, then:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sub steps of the "else if" steps seem to be repeated here. How about we make the above window client "if" block continue to the next iteration after its own substeps. And do the following for worker blocks:

Add the result of running Create Client algorithm with |client| to |matchedClients| if any of the following are true:

  • |options|.{{ClientQueryOptions/type}} is {{ClientType/"worker"}} or {{ClientType/"all"}} and |client| is a dedicated worker client
  • |options|.{{ClientQueryOptions/type}} is {{ClientType/"sharedworker"}} or {{ClientType/"all"}} and |client| is a shared worker client
  • |options|.{{ClientQueryOptions/type}} is {{ClientType/"serviceworker"}} or {{ClientType/"all"}} and |client| is a service worker client

1. Let |clientObject| be the result of running <a>Create Client</a> 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 <a>shared worker client</a>, then:
1. Let |clientObject| be the result of running <a>Create Client</a> 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 <a>service worker client</a>, then:
1. Let |clientObject| be the result of running <a>Create Client</a> algorithm with |client| as the argument.
1. Add |clientObject| to |matchedClients|.
1. Sort |matchedClients| such that:
Expand Down