- From: Anne van Kesteren <notifications@github.com>
- Date: Tue, 21 Feb 2023 22:49:02 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/pull/1672/review/1308617314@github.com>
@annevk commented on this pull request.
> + <h3 id="empty-fetch-handler-identification-algorithm"><dfn>Empty Fetch Handler Identification</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 returns false.
+ 1. Let |eventListenerList| be an empty [=list=].
+ 1. [=list/For each=] |eventListener| of |workerGlobalScope|'s [=set of event types to handle=]:
+ 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 [=callback=] is not null:
+ 1. Set |callback| to the result of [=converting|convert to an ECMAScript value=] |eventListener|'s [=callback=] to an ECMAScript value.
+ 1. If [$IsCallable$](|callback|) is false:
+ 1. Let |getResult| be [=Completion=]([$Get$](|callback|), <code>handleEvent</code>).
+ 1. If |getResult| is [=abrupt completion=], then return false.
+ 1. Set |callback| to |getResult|.
+ 1. If [$IsCallable$](|callback|) is false, then return false.
+ 1. If |callback|'s [=function body=] is not empty (i.e. either a [=statement=] or [=declaration=] exist), then return false.
+
+ Note: it detects something like `onfetch = () => {}`. Some sites have a fetch event listener with empty body to make them recognized as progressive web application (PWA).
@domenic I think this still doesn't work for `onfetch` as HTML wraps that function in its own function when creating the callback, right? See https://github.com/WebKit/standards-positions/issues/129#issuecomment-1431008116.
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1672#pullrequestreview-1308617314
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/ServiceWorker/pull/1672/review/1308617314@github.com>
Received on Wednesday, 22 February 2023 06:49:15 UTC