Skip to content

Commit 4ce01b5

Browse files
committed
Improve clients.get(id)
This commit embraces the recently added environment concept in enumerating service worker clients. Also, for an environment type client, it references the environment's target browsing context's active document's UI properties to set the visibilityState and the focused state. Related commit: 8b483b0
1 parent f17178b commit 4ce01b5

File tree

4 files changed

+120
-80
lines changed

4 files changed

+120
-80
lines changed

docs/index.bs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,32 +1272,41 @@ spec: url; urlPrefix: https://url.spec.whatwg.org/
12721272
<li>Run these substeps <a>in parallel</a>:
12731273
<ol>
12741274
<li>For each <a href="#dfn-service-worker-client">service worker client</a> <var>client</var> whose <a for="resource">origin</a> is the <a lt="same origin">same</a> as the associated <a href="#dfn-service-worker-global-scope-service-worker">service worker</a>'s <a for="resource">origin</a>:
1275+
<p class="issue">For environment type clients, the environment's creation URL's origin should be used for the origin check instead of the client's origin. See <a href="https://github.com/whatwg/html/issues/1992">the issue</a> to define the environment's origin algorithm.</p>
12751276
<ol>
1276-
<li>If <var>client</var>'s <a for="environment">id</a> is <var>id</var>, then:
1277+
<li>If <var>client</var>'s <a for="environment">id</a> is not <var>id</var>, continue to the next iteration of the loop.</li>
1278+
<li>If <var>client</var> is a type of <a>environment</a>, then:
1279+
<ol>
1280+
<li>If <var>client</var>’s <a>creation URL</a> is not a <a>potentially trustworthy URL</a>, reject <var>promise</var> with a "{{SecurityError}}" exception and abort these steps.</li>
1281+
</ol>
1282+
</li>
1283+
<li>Else:
12771284
<ol>
12781285
<li>If <var>client</var> is not a <a>secure context</a>, reject <var>promise</var> with a "{{SecurityError}}" exception and abort these steps.</li>
1279-
<li>If <var>client</var> is a <a href="#dfn-window-client">window client</a>, then:
1280-
<ol>
1281-
<li>Let <var>browsingContext</var> be <var>client</var>'s <a for="environment settings object">global object</a>'s <a for="/">browsing context</a>.</li>
1282-
<li>Let <var>visibilityState</var> be null.</li>
1283-
<li>Let <var>focusState</var> be null.</li>
1284-
<li><a>Queue a task</a> <var>task</var> to run the following substeps:
1285-
<ol>
1286-
<li>Set <var>visibilityState</var> to <var>browsingContext</var>'s <a>active document</a>'s {{Document/visibilityState}} attribute value.</li>
1287-
<li>Set <var>focusState</var> to the result of running the <a>has focus steps</a> with <var>browsingContext</var>'s <a>active document</a> as the argument.</li>
1288-
</ol>
1289-
</li>
1290-
<li>Wait for <var>task</var> to have executed.</li>
1291-
<li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>client</var>, <var>visibilityState</var> and <var>focusState</var> as the arguments.</li>
1292-
<li>Resolve <var>promise</var> with <var>windowClient</var> and abort these steps.</li>
1293-
</ol>
1294-
</li>
1295-
<li>Else:
1286+
</ol>
1287+
</li>
1288+
<li>If <var>client</var> is a type of <a>environment</a> or is a <a href="#dfn-window-client">window client</a>, then:
1289+
<ol>
1290+
<li>Let <var>browsingContext</var> be null.</li>
1291+
<li>Let <var>visibilityState</var> be null.</li>
1292+
<li>Let <var>focusState</var> be null.</li>
1293+
<li>If <var>client</var> is a type of <a>environment</a>, set <var>browsingContext</var> to <var>client</var>’s <a for="environment">target browsing context</a>.</li>
1294+
<li>Else, set <var>browsingContext</var> to <var>client</var>'s <a for="environment settings object">global object</a>'s <a for="/">browsing context</a>.</li>
1295+
<li><a>Queue a task</a> <var>task</var> to run the following substeps:
12961296
<ol>
1297-
<li>Let <var>clientObject</var> be the result of running <a href="#create-client-algorithm">Create Client</a> algorithm with <var>client</var> as the argument.</li>
1298-
<li>Resolve <var>promise</var> with <var>clientObject</var> and abort these steps.</li>
1297+
<li>Set <var>visibilityState</var> to <var>browsingContext</var>'s <a>active document</a>'s {{Document/visibilityState}} attribute value.</li>
1298+
<li>Set <var>focusState</var> to the result of running the <a>has focus steps</a> with <var>browsingContext</var>'s <a>active document</a> as the argument.</li>
12991299
</ol>
13001300
</li>
1301+
<li>Wait for <var>task</var> to have executed.</li>
1302+
<li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>client</var>, <var>visibilityState</var> and <var>focusState</var> as the arguments.</li>
1303+
<li>Resolve <var>promise</var> with <var>windowClient</var> and abort these steps.</li>
1304+
</ol>
1305+
</li>
1306+
<li>Else:
1307+
<ol>
1308+
<li>Let <var>clientObject</var> be the result of running <a href="#create-client-algorithm">Create Client</a> algorithm with <var>client</var> as the argument.</li>
1309+
<li>Resolve <var>promise</var> with <var>clientObject</var> and abort these steps.</li>
13011310
</ol>
13021311
</li>
13031312
</ol>

docs/index.html

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,33 +2564,42 @@ <h4 class="heading settled" data-level="4.3.1" id="clients-get"><span class="sec
25642564
<ol>
25652565
<li>
25662566
For each <a href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-24">service worker client</a> <var>client</var> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a> is the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#same-origin">same</a> as the associated <a href="#dfn-service-worker-global-scope-service-worker" id="ref-for-dfn-service-worker-global-scope-service-worker-7">service worker</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#origin-2">origin</a>:
2567+
<p class="issue" id="issue-eb16f4c7"><a class="self-link" href="#issue-eb16f4c7"></a>For environment type clients, the environment’s creation URL’s origin should be used for the origin check instead of the client’s origin. See <a href="https://github.com/whatwg/html/issues/1992">the issue</a> to define the environment’s origin algorithm.</p>
25672568
<ol>
2569+
<li>If <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-id">id</a> is not <var>id</var>, continue to the next iteration of the loop.
25682570
<li>
2569-
If <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-id">id</a> is <var>id</var>, then:
2571+
If <var>client</var> is a type of <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment">environment</a>, then:
2572+
<ol>
2573+
<li>If <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-creation-url">creation URL</a> is not a <a data-link-type="dfn" href="https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url">potentially trustworthy URL</a>, reject <var>promise</var> with a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception and abort these steps.
2574+
</ol>
2575+
<li>
2576+
Else:
25702577
<ol>
25712578
<li>If <var>client</var> is not a <a data-link-type="dfn" href="https://w3c.github.io/webappsec-secure-contexts/#secure-context">secure context</a>, reject <var>promise</var> with a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" exception and abort these steps.
2579+
</ol>
2580+
<li>
2581+
If <var>client</var> is a type of <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment">environment</a> or is a <a href="#dfn-window-client" id="ref-for-dfn-window-client-4">window client</a>, then:
2582+
<ol>
2583+
<li>Let <var>browsingContext</var> be null.
2584+
<li>Let <var>visibilityState</var> be null.
2585+
<li>Let <var>focusState</var> be null.
2586+
<li>If <var>client</var> is a type of <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment">environment</a>, set <var>browsingContext</var> to <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-target-browsing-context">target browsing context</a>.
2587+
<li>Else, set <var>browsingContext</var> to <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>.
25722588
<li>
2573-
If <var>client</var> is a <a href="#dfn-window-client" id="ref-for-dfn-window-client-4">window client</a>, then:
2574-
<ol>
2575-
<li>Let <var>browsingContext</var> be <var>client</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-global">global object</a>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context">browsing context</a>.
2576-
<li>Let <var>visibilityState</var> be null.
2577-
<li>Let <var>focusState</var> be null.
2578-
<li>
2579-
<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps:
2580-
<ol>
2581-
<li>Set <var>visibilityState</var> to <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.
2582-
<li>Set <var>focusState</var> to the result of running the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a> with <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a> as the argument.
2583-
</ol>
2584-
<li>Wait for <var>task</var> to have executed.
2585-
<li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>client</var>, <var>visibilityState</var> and <var>focusState</var> as the arguments.
2586-
<li>Resolve <var>promise</var> with <var>windowClient</var> and abort these steps.
2587-
</ol>
2588-
<li>
2589-
Else:
2589+
<a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps:
25902590
<ol>
2591-
<li>Let <var>clientObject</var> be the result of running <a href="#create-client-algorithm">Create Client</a> algorithm with <var>client</var> as the argument.
2592-
<li>Resolve <var>promise</var> with <var>clientObject</var> and abort these steps.
2591+
<li>Set <var>visibilityState</var> to <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/page-visibility/#dom-document-visibilitystate">visibilityState</a></code> attribute value.
2592+
<li>Set <var>focusState</var> to the result of running the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#has-focus-steps">has focus steps</a> with <var>browsingContext</var>’s <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#active-document">active document</a> as the argument.
25932593
</ol>
2594+
<li>Wait for <var>task</var> to have executed.
2595+
<li>Let <var>windowClient</var> be the result of running <a href="#create-windowclient-algorithm">Create Window Client</a> algorithm with <var>client</var>, <var>visibilityState</var> and <var>focusState</var> as the arguments.
2596+
<li>Resolve <var>promise</var> with <var>windowClient</var> and abort these steps.
2597+
</ol>
2598+
<li>
2599+
Else:
2600+
<ol>
2601+
<li>Let <var>clientObject</var> be the result of running <a href="#create-client-algorithm">Create Client</a> algorithm with <var>client</var> as the argument.
2602+
<li>Resolve <var>promise</var> with <var>clientObject</var> and abort these steps.
25942603
</ol>
25952604
</ol>
25962605
<li>Resolve <var>promise</var> with undefined.
@@ -5997,6 +6006,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span cla
59976006
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-script">script</a>
59986007
<li><a href="https://html.spec.whatwg.org/multipage/workers.html#shared-workers">shared workers</a>
59996008
<li><a href="https://html.spec.whatwg.org/multipage/browsers.html#source-browsing-context">source browsing context</a>
6009+
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-target-browsing-context">target browsing context</a>
60006010
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task">task</a>
60016011
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#task-queue">task queue</a>
60026012
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#task-source">task source</a>
@@ -6396,6 +6406,7 @@ <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">I
63966406
</pre>
63976407
<h2 class="no-num no-ref heading settled" id="issues-index"><span class="content">Issues Index</span><a class="self-link" href="#issues-index"></a></h2>
63986408
<div style="counter-reset:issue">
6409+
<div class="issue">For environment type clients, the environment’s creation URL’s origin should be used for the origin check instead of the client’s origin. See <a href="https://github.com/whatwg/html/issues/1992">the issue</a> to define the environment’s origin algorithm.<a href="#issue-eb16f4c7"> ↵ </a></div>
63996410
<div class="issue">The response’s cache state concept had been removed from fetch. The fetch issue <a href="https://github.com/whatwg/fetch/issues/376">#376</a> tracks the request to restore the concept or add some similar way to check this state.<a href="#issue-3c7457a0"> ↵ </a></div>
64006411
</div>
64016412
<aside class="dfn-panel" data-for="dfn-service-worker">

0 commit comments

Comments
 (0)