Skip to content

Commit dae02eb

Browse files
committed
Addressing nits and porting to v1
1 parent dd52822 commit dae02eb

File tree

2 files changed

+47
-29
lines changed

2 files changed

+47
-29
lines changed

docs/index.bs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
21462146
<section>
21472147
<h3 id="firing-functional-events">Firing Functional Events</h3>
21482148

2149-
To request a <a>functional event</a> dispatch to the [=service worker registration/active worker=] of a [=/service worker registration=], specifications *may* invoke <a>fire a functional event</a>.
2149+
To request a [=functional event=] dispatch to the [=service worker registration/active worker=] of a [=/service worker registration=], specifications *may* invoke [=Fire Functional Event=].
21502150
</section>
21512151
</section>
21522152

@@ -2809,13 +2809,13 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28092809
</section>
28102810

28112811
<section algorithm>
2812-
<h3 id="fire-functional-event-algorithm"><dfn export>Fire a Functional Event</dfn></h3>
2812+
<h3 id="fire-functional-event-algorithm"><dfn export lt="Fire Functional Event|Fire a functional event">Fire Functional Event</dfn></h3>
28132813

28142814
: Input
2815-
:: |eventName|, a DOMString
2815+
:: |eventName|, a string
28162816
:: |eventConstructor|, an event constructor that extends {{ExtendableEvent}}
28172817
:: |registration|, a [=/service worker registration=]
2818-
:: |initializationSteps|, optional steps to initialise |event|, constructed from |eventConstructor|
2818+
:: |initialization|, optional property initialization for |event|, constructed from |eventConstructor|
28192819
:: |postDispatchSteps|, optional steps to run on the [=service worker registration/active worker=]'s event loop, with |dispatchedEvent| set to the instance of |eventConstructor| that was [=dispatched=].
28202820
: Output
28212821
:: None
@@ -2833,7 +2833,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28332833
1. Invoke [=Run Service Worker=] algorithm with |activeWorker| as the argument.
28342834
1. [=Queue a task=] |task| to run these substeps:
28352835
1. Let |event| be the result of [=creating an event=] with |eventConstructor| and the [=relevant realm=] of |activeWorker|'s [=service worker/global object=].
2836-
1. If |initializationSteps| is not null, then initialize |event| with |initializationSteps|.
2836+
1. If |initialization| is not null, then initialize |event| with |initialization|.
28372837
1. [=Dispatch=] |event| on |activeWorker|'s [=service worker/global object=].
28382838
1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |event|.
28392839
1. If |postDispatchSteps| is not null, then run |postDispatchSteps| passing |event| as |dispatchedEvent|.
@@ -2846,19 +2846,19 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28462846
<div class="example">
28472847
To fire an "`amazingthing`" event (which is of type `AmazingThingEvent`) on a particular |serviceWorkerRegistration|, and initialize the event object's properties, the prose would be:
28482848

2849-
1. [=Fire a functional event=] named "`amazingthing`" using `AmazingThingEvent` on |serviceWorkerRegistration| with the following properties:
2849+
1. [=Fire Functional Event=] "`amazingthing`" using `AmazingThingEvent` on |serviceWorkerRegistration| with the following properties:
28502850
: propertyName
28512851
:: value
28522852
: anotherPropertyName
28532853
:: anotherValue
28542854

28552855
Then run the following steps with |dispatchedEvent|:
28562856

2857-
1. Do whatever you need to with |dispatchedEvent|.
2857+
1. Do whatever you need to with |dispatchedEvent| on the service worker's event loop.
28582858

28592859
Note that the initialization steps and post-dispatch steps are optional. If they aren't needed, the prose would be:
28602860

2861-
1. [=Fire a functional event=] named "`whatever`" using {{ExtendableEvent}} on |serviceWorkerRegistration|.
2861+
1. [=Fire Functional Event=] "`whatever`" using {{ExtendableEvent}} on |serviceWorkerRegistration|.
28622862
</div>
28632863
</section>
28642864

docs/v1/index.bs

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,13 +2071,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
20712071
</section>
20722072

20732073
<section>
2074-
<h3 id="request-functional-event-dispatch">Request Functional Event Dispatch</h3>
2074+
<h3 id="firing-functional-events">Firing Functional Events</h3>
20752075

2076-
To request a <a>functional event</a> dispatch to a [=/service worker=], specifications *may* invoke <a>Handle Functional Event</a> algorithm with its [=/service worker registration=] <var ignore>registration</var> and the algorithm |callbackSteps| as the arguments.
2077-
2078-
Specifications *may* define an algorithm |callbackSteps| where the corresponding <a>functional event</a> can be created and fired with specification specific objects. The algorithm is passed <var ignore>globalObject</var> (a {{ServiceWorkerGlobalScope}} object) at which it *may* fire its <a>functional events</a>. This algorithm is called on a <a>task</a> <a lt="queue a task">queued</a> by <a>Handle Functional Event</a> algorithm.
2079-
2080-
Note: See an <a href="https://notifications.spec.whatwg.org/#activating-a-notification">example</a> hook defined in <a biblio data-biblio-type="informative" lt="notifications">Notifications API</a>.
2076+
To request a [=functional event=] dispatch to the [=service worker registration/active worker=] of a [=/service worker registration=], specifications *may* invoke [=Fire Functional Event=].
20812077
</section>
20822078
</section>
20832079

@@ -2672,35 +2668,57 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
26722668
</section>
26732669

26742670
<section algorithm>
2675-
<h3 id="handle-functional-event-algorithm"><dfn export>Handle Functional Event</dfn></h3>
2671+
<h3 id="fire-functional-event-algorithm"><dfn export lt="Fire Functional Event|Fire a functional event">Fire Functional Event</dfn></h3>
26762672

26772673
: Input
2678-
:: |event|, an {{ExtendableEvent}} object
2674+
:: |eventName|, a string
2675+
:: |eventConstructor|, an event constructor that extends {{ExtendableEvent}}
26792676
:: |registration|, a [=/service worker registration=]
2680-
:: |callbackSteps|, an algorithm
2677+
:: |initialization|, optional property initialization for |event|, constructed from |eventConstructor|
2678+
:: |postDispatchSteps|, optional steps to run on the [=service worker registration/active worker=]'s event loop, with |dispatchedEvent| set to the instance of |eventConstructor| that was [=dispatched=].
26812679
: Output
26822680
:: None
26832681

2684-
1. Assert: <a>scope to registration map</a> contains a value equal to |registration|.
2685-
1. Assert: |registration|'s <a>active worker</a> is not null.
2686-
1. Let |activeWorker| be |registration|'s <a>active worker</a>.
2687-
1. If |activeWorker|'s <a>set of event types to handle</a> does not [=set/contain=] |event|'s {{Event/type}}, then:
2688-
1. Return and continue running these steps <a>in parallel</a>.
2689-
1. If the time difference in seconds calculated by the current time minus |registration|'s <a>last update check time</a> is greater than 86400, invoke <a>Soft Update</a> algorithm with |registration|.
2682+
1. Assert: [=scope to registration map=] contains a value equal to |registration|.
2683+
1. Assert: |registration|'s [=active worker=] is not null.
2684+
1. Let |activeWorker| be |registration|'s [=active worker=].
2685+
1. If |activeWorker|'s [=set of event types to handle=] does not [=set/contain=] |eventName|, then return and run the following steps [=in parallel=]:
2686+
1. If the time difference in seconds calculated by the current time minus |registration|'s [=last update check time=] is greater than 86400, invoke [=Soft Update=] algorithm with |registration|.
26902687
1. Abort these steps.
26912688

26922689
Note: To avoid unnecessary delays, the Handle Functional Event enforces early return when no event listeners have been deterministically added in the service worker's global during the very first script execution.
26932690

2694-
1. If |activeWorker|'s <a>state</a> is *activating*, wait for |activeWorker|'s <a>state</a> to become *activated*.
2695-
1. Invoke <a>Run Service Worker</a> algorithm with |activeWorker| as the argument.
2696-
1. <a>Queue a task</a> |task| to run these substeps:
2697-
1. Invoke |callbackSteps| with |activeWorker|'s [=service worker/global object=] as its argument.
2691+
1. If |activeWorker|'s [=state=] is *activating*, wait for |activeWorker|'s [=state=] to become *activated*.
2692+
1. Invoke [=Run Service Worker=] algorithm with |activeWorker| as the argument.
2693+
1. [=Queue a task=] |task| to run these substeps:
2694+
1. Let |event| be the result of [=creating an event=] with |eventConstructor| and the [=relevant realm=] of |activeWorker|'s [=service worker/global object=].
2695+
1. If |initialization| is not null, then initialize |event| with |initialization|.
2696+
1. [=Dispatch=] |event| on |activeWorker|'s [=service worker/global object=].
26982697
1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |event|.
2698+
1. If |postDispatchSteps| is not null, then run |postDispatchSteps| passing |event| as |dispatchedEvent|.
26992699

2700-
The |task| *must* use |activeWorker|'s <a>event loop</a> and the <a>handle functional event task source</a>.
2700+
The |task| *must* use |activeWorker|'s [=event loop=] and the [=handle functional event task source=].
27012701

27022702
1. Wait for |task| to have executed or been discarded.
2703-
1. If the time difference in seconds calculated by the current time minus |registration|'s <a>last update check time</a> is greater than 86400, invoke <a>Soft Update</a> algorithm with |registration|.
2703+
1. If the time difference in seconds calculated by the current time minus |registration|'s [=last update check time=] is greater than 86400, invoke [=Soft Update=] algorithm with |registration|.
2704+
2705+
<div class="example">
2706+
To fire an "`amazingthing`" event (which is of type `AmazingThingEvent`) on a particular |serviceWorkerRegistration|, and initialize the event object's properties, the prose would be:
2707+
2708+
1. [=Fire Functional Event=] "`amazingthing`" using `AmazingThingEvent` on |serviceWorkerRegistration| with the following properties:
2709+
: propertyName
2710+
:: value
2711+
: anotherPropertyName
2712+
:: anotherValue
2713+
2714+
Then run the following steps with |dispatchedEvent|:
2715+
2716+
1. Do whatever you need to with |dispatchedEvent| on the service worker's event loop.
2717+
2718+
Note that the initialization steps and post-dispatch steps are optional. If they aren't needed, the prose would be:
2719+
2720+
1. [=Fire Functional Event=] "`whatever`" using {{ExtendableEvent}} on |serviceWorkerRegistration|.
2721+
</div>
27042722
</section>
27052723

27062724
<section algorithm>

0 commit comments

Comments
 (0)