Skip to content

Commit 7b04487

Browse files
dtapuskadomenic
authored andcommitted
Add State to Service Worker Clients.
As discussed on w3c/ServiceWorker#1442 Unfortunately adoption of page-lifecycle is yet to be formally supported by other vendors so we need to monkey patch this in the page lifecycle spec.
1 parent b71846b commit 7b04487

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

spec.bs

+71
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,77 @@ Run the [=update document frozenness steps=] given <var ignore>child document</v
244244

245245
Each {{HTMLMediaElement}} has a <dfn for="HTMLMediaElement">resume frozen flag</dfn>, which is initially set to false.
246246

247+
Modifications to the Service Worker Standard {#serviceworker-mod}
248+
--------------------------------------------
249+
250+
### Service Worker: <a href="https://w3c.github.io/ServiceWorker/#client-interface">Client Interface</a> ### {#serviceworker-client-dfn}
251+
252+
<pre class="idl">
253+
partial interface Client {
254+
readonly attribute ClientState state;
255+
};
256+
257+
enum ClientState {
258+
"active",
259+
"frozen"
260+
};
261+
</pre>
262+
263+
A {{Client}} object has an associated <dfn id="dfn-service-worker-client-state" for="Client">state</dfn>, which is one of {{ClientState}} attribute value.
264+
265+
<section>
266+
<h4 id="service-worker-client-state">{{ServiceWorkerClient/state}}</h4>
267+
268+
The <dfn attribute for="ServiceWorkerClient">state</dfn> attribute *must* return the [=context object=]'s [=Client/state=].
269+
</section>
270+
271+
### Service Worker: <a href="https://w3c.github.io/ServiceWorker/#clients-interface">Clients Interface</a> ### {#serviceworker-clients-dfn}
272+
273+
<pre class="idl">
274+
partial dictionary ClientQueryOptions {
275+
ClientStateQuery state = "active";
276+
};
277+
278+
enum ClientStateQuery {
279+
"active",
280+
"frozen",
281+
"all"
282+
};
283+
</pre>
284+
285+
Adjust <a href="https://w3c.github.io/ServiceWorker/#clients-matchall">Match All</a> algorithm:
286+
287+
Before Step #2.5.1 insert
288+
289+
1. Let <var ignore>state</var> be the result of running [=Get Client State=] with <var ignore>client</var>.
290+
1. If <var ignore>options</var>["{{ClientQueryOptions/state}}"] is not {{ClientStateQuery/"all"}} and does not equal <var ignore>state</var>, then [=continue=].
291+
292+
293+
<section>
294+
<h4 id="client-state">{{Client/state}}</h4>
295+
296+
The <dfn attribute for="Client">state</dfn> attribute *must* return the [=context object=]'s [=Client/state=].
297+
</section>
298+
299+
300+
### Service Worker: <a href="https://w3c.github.io/ServiceWorker/#algorithms">Algorithms</a> ### {#serviceworker-algorithms-dfn}
301+
302+
Append the following algorithm:
303+
304+
<section algorithm>
305+
<h3 id="get-client-state-algorithm"><dfn>Get Client State</dfn></h3>
306+
307+
: Input
308+
:: |client|, a [=/service worker client=]
309+
: Output
310+
:: |state|, a string
311+
312+
1. Let |state| be {{ClientState/"active"}}.
313+
1. If |client|'s [=responsible document=] is [=frozen=], set |state| to be {{ClientState/"frozen"}}.
314+
1. Return |state|.
315+
</section>
316+
317+
247318
Additions to Page Lifecycle spec {#page-lifecycle}
248319
--------------------------------------------
249320

0 commit comments

Comments
 (0)