Skip to content

Commit 988b0e1

Browse files
committed
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 54b811f commit 988b0e1

File tree

2 files changed

+353
-51
lines changed

2 files changed

+353
-51
lines changed

spec.bs

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

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

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

0 commit comments

Comments
 (0)