Re: [w3c/ServiceWorker] Skip executing fetch handlers if it is no-op. (PR #1672)

@jakearchibald requested changes on this pull request.

One small error, and the exporting from other specs left to do.

> +  <section algorithm>
+    <h3 id="all-fetch-listeners-are-empty-algorithm"><dfn>All Fetch Listeners Are Empty</dfn></h3>
+
+      : Input
+      :: |workerGlobalScope|, a [=service worker/global object=].
+      : Output
+      :: a boolean
+
+      1. If |workerGlobalScope|'s [=set of event types to handle=] does not [=set/contain=] <code>fetch</code>, then return true.
+      1. Let |eventHandler| be |workerGlobalScope|'s <a spec="html">event handler map</a>["onfetch"]'s value.
+      1. Let |eventListenerList| be an empty [=list=].
+      1. [=list/For each=] |eventListener| of |workerGlobalScope|'s [=event listener list=]:
+          1. If |eventListener|'s <a spec="dom">type</a> is "<code>fetch</code>", then [=list/append=] |eventListener| to |eventListenerList|.
+      1. [=list/For each=] |eventListener| of |eventListenerList|:
+          1. If |eventListener|'s [=event listener/callback=] is null, then [=continue=].
+          1. If |eventHandler| is not null, and |eventListener| equals |eventHandler|'s <a spec="html">listener</a>, then set |callback| to the result of [=converting|convert to an ECMAScript value=] |eventHandler|'s <a spec="html">listener</a> value to an ECMAScript value.

Lines like this are still pointing to unexported terms in other specs. Can you get these exported in other specs first? I don't want to land the spec linking to unexported terms.

> @@ -3075,6 +3122,12 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
       1. If the result of running the [=Should Skip Event=] algorithm with "fetch" and |activeWorker| is true, then:
           1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
           1. Return null.
+      1. If |activeWorker|'s [=all fetch listeners are empty flag=] is set:
+          1. [=In parallel=]:
+              1. If |activeWorker|'s [=service worker/state=] is "activating", then wait for |activeWorker|'s [=service worker/state=] to become "activated".
+              1. Run the [=Run Service Worker=] algorithm with |activeWorker|.
+              1. If |shouldSoftUpdate| is true, then run the [=Soft Update algorithm=] with |registration|.

```suggestion
              1. If |shouldSoftUpdate| is true, then run the [=Soft Update=] algorithm with |registration|.
```

The link text here was wrong (and was causing a bikeshed error.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1672#pullrequestreview-1336783634
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/pull/1672/review/1336783634@github.com>

Received on Monday, 13 March 2023 11:16:46 UTC