Skip to content

Commit c15259a

Browse files
dtapuskadomenic
authored andcommitted
- Add additional algorithm changes for service workers
- Rename state to lifecycleState
1 parent 7b04487 commit c15259a

File tree

1 file changed

+44
-18
lines changed

1 file changed

+44
-18
lines changed

spec.bs

+44-18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Default Biblio Status: current
1414

1515
<pre class='link-defaults'>
1616
spec:dom; type:interface; text:Document
17+
spec: infra;
18+
type: dfn;
19+
text: list;
20+
for: set; text: append
21+
for: list; text: append
1722
</pre>
1823

1924
<pre class='anchors'>
@@ -42,6 +47,9 @@ spec: ECMA262; urlPrefix: https://tc39.github.io/ecma262/;
4247
type: dfn; text: realm; url: #sec-code-realms
4348
spec: CSS-Houdini; urlPrefix: https://drafts.css-houdini.org/worklets;
4449
type: dfn; text: owning document; for: worklet; url: #workletglobalscope-owner-document
50+
spec: ServiceWorker; urlPrefix: https://w3c.github.io/ServiceWorker/
51+
type: dfn; text: create window client; url: #create-windowclient-algorithm
52+
type: dfn; text: create client; url: #create-client-algorithm
4553
</pre>
4654

4755

@@ -251,66 +259,84 @@ Modifications to the Service Worker Standard {#serviceworker-mod}
251259

252260
<pre class="idl">
253261
partial interface Client {
254-
readonly attribute ClientState state;
262+
readonly attribute ClientLifecycleState lifecycleState;
255263
};
256264

257-
enum ClientState {
265+
enum ClientLifecycleState {
258266
"active",
259267
"frozen"
260268
};
261269
</pre>
262270

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.
271+
A {{Client}} object has an associated <dfn id="dfn-service-worker-client-lifecycle-state" for="Client">lifecycleState</dfn>, which is one of the {{ClientLifecycleState}} enumeration values.
264272

265273
<section>
266-
<h4 id="service-worker-client-state">{{ServiceWorkerClient/state}}</h4>
274+
<h4 id="service-worker-client-lifecycle-state">{{ServiceWorkerClient/lifecycleState}}</h4>
267275

268-
The <dfn attribute for="ServiceWorkerClient">state</dfn> attribute *must* return the [=context object=]'s [=Client/state=].
276+
The <dfn attribute for="ServiceWorkerClient">lifecycleState</dfn> attribute <em>must</em> return the [=context object=]'s [=Client/lifecycleState=].
269277
</section>
270278

271279
### Service Worker: <a href="https://w3c.github.io/ServiceWorker/#clients-interface">Clients Interface</a> ### {#serviceworker-clients-dfn}
272280

273281
<pre class="idl">
274282
partial dictionary ClientQueryOptions {
275-
ClientStateQuery state = "active";
283+
ClientLifecycleStateQuery lifecycleState = "active";
276284
};
277285

278-
enum ClientStateQuery {
286+
enum ClientLifecycleStateQuery {
279287
"active",
280288
"frozen",
281289
"all"
282290
};
283291
</pre>
284292

285-
Adjust <a href="https://w3c.github.io/ServiceWorker/#clients-matchall">Match All</a> algorithm:
293+
294+
### Service Worker Algorithms: <a href="https://w3c.github.io/ServiceWorker/#clients-matchall">Match All</a> algorithm ### {#serviceworker-matchall-dfn}
295+
296+
Rename variable in Step #4.
297+
1. Let |matchedClientData| be a new [=list=].
286298

287299
Before Step #2.5.1 insert
288300

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=].
301+
1. Let <var ignore>lifecycleState</var> be the result of running [=Get Client Lifecycle State=] with <var ignore>client</var>.
302+
1. If <var ignore>options</var>["{{ClientQueryOptions/lifecycleState}}"] is not {{ClientLifecycleStateQuery/"all"}} and does not equal <var ignore>lifecycleState</var>, then [=continue=].
291303

304+
Append lifecycleState to list in Step #5.3.1
305+
1. Let |windowData| be «[ "client" → |client|, "ancestorOriginsList" → a new [=list=], "lifecycleState" → |lifecycleState| ]».
292306

293-
<section>
294-
<h4 id="client-state">{{Client/state}}</h4>
307+
Append lifecycleState to matchedClientData in Step #5.4
308+
1. Add «[ "client" → |client|, "lifecycleState" → |lifecycleState| ]» to |matchedClientData|.
295309

296-
The <dfn attribute for="Client">state</dfn> attribute *must* return the [=context object=]'s [=Client/state=].
297-
</section>
310+
Pass windowData lifecycleState into Create Window Client algorithm in Step #6.2
311+
1. Let <var ignore>windowClient</var> be the result of running [=Create Window Client=] algorithm with |windowData|["`client`"], |windowData|["`frameType`"], |windowData|["`visibilityState`"], |windowData|["`focusState`"], |windowData|["`ancestorOriginsList`"], and |windowData|["`lifecycleState`"] as the arguments.
312+
313+
Adjust Step #6.3
314+
1. [=list/For each=] |clientData| in |matchedClientData|:
315+
1. Let |clientObject| be the result of running [=Create Client=] algorithm with |clientData|["`client`"], and |clientData|["`lifecycleState`"] as the arguments.
316+
1. [=Append=] |clientObject| to <var ignore>clientObjects</var>.
317+
318+
319+
### Service Worker Algorithms: <a href="https://w3c.github.io/ServiceWorker/#dom-clients-openwindow">Open Window</a> algorithm ### {#serviceworker-openwindow-dfn}
298320

321+
Before Step #7.5 insert
322+
1. Let |lifecycleState| be the result of running [=Get Client Lifecycle State=] with [=context object=]'s associated [=service worker client=].
299323

300-
### Service Worker: <a href="https://w3c.github.io/ServiceWorker/#algorithms">Algorithms</a> ### {#serviceworker-algorithms-dfn}
324+
Adjust Step #7.8.2 to provide lifecycleState
325+
1. Let |client| be the result of running [=Create Window Client=] with <var ignore>newContext</var>'s {{Window}} object's [=environment settings object=], <var ignore>frameType</var>, <var ignore>visibilityState</var>, <var ignore>focusState</var>, <var ignore>ancestorOriginsList</var>, and |lifecycleState| as the arguments.
301326

327+
### Service Worker <a href="https://w3c.github.io/ServiceWorker/#algorithms">Algorithms</a> ### {#serviceworker-algorithms-dfn}
302328
Append the following algorithm:
303329

304330
<section algorithm>
305-
<h3 id="get-client-state-algorithm"><dfn>Get Client State</dfn></h3>
331+
<h5 id="get-client-lifecycle-state-algorithm"><dfn>Get Client Lifecycle State</dfn></h5>
306332

307333
: Input
308334
:: |client|, a [=/service worker client=]
309335
: Output
310336
:: |state|, a string
311337

312-
1. Let |state| be {{ClientState/"active"}}.
313-
1. If |client|'s [=responsible document=] is [=frozen=], set |state| to be {{ClientState/"frozen"}}.
338+
1. Let |state| be {{ClientLifecycleState/"active"}}.
339+
1. If |client|'s [=responsible document=] is [=frozen=], set |state| to be {{ClientLifecycleState/"frozen"}}.
314340
1. Return |state|.
315341
</section>
316342

0 commit comments

Comments
 (0)