diff --git a/fetch.bs b/fetch.bs index 559b752ec..3d102e73e 100644 --- a/fetch.bs +++ b/fetch.bs @@ -705,8 +705,27 @@ explicitly set request's this flag set are subject to additional processing requirements.

A request has an associated -skip-service-worker flag. Unless stated otherwise it is -unset. +service-workers mode, that is "all", +"foreign", or "none". Unless stated otherwise it is +"all". + +

+

This determines which service workers will receive a {{fetch!!event}} event for this fetch. + +

+
"all" +
Relevant local and foreign service workers will get a {{fetch!!event}} or + {{foreignfetch!!event}} event for this fetch. + +
"foreign" +
Only relevant foreign service workers will get a {{foreignfetch!!event}} event for this fetch. + {{fetch(input)!!method}} uses this to bypass the current service worker if the global is a + {{ServiceWorkerGlobalScope}}. + +
"none" +
Neither local nor foreign service workers will get events for this fetch. +
+

A request has an associated initiator, which is @@ -2800,16 +2819,13 @@ optional CORS flag and CORS-preflight flag, run these steps:

  • Let actualResponse be null.

  • -

    If request's skip-service-worker flag is unset, then run these +

    If request's service-workers mode is not "none", then run these substeps:

    1. -

      If request's client is null or - request's client's - global object is not a - {{ServiceWorkerGlobalScope}} object, then set response - to the result of invoking handle fetch for request. +

      If request's service-workers mode is "all", then set + response to the result of invoking handle fetch for request. [[!HTML]] [[!SW]]

    2. @@ -2900,7 +2916,8 @@ optional CORS flag and CORS-preflight flag, run these steps:
    3. If request's redirect mode is - "follow", then set request's skip-service-worker flag. + "follow", then set request's service-workers mode to + "foreign".

      Redirects coming from the network (as opposed to from a service worker) are not to be exposed to a service worker. @@ -5192,6 +5209,10 @@ method, must run these steps: init as arguments. If this throws an exception, reject p with it and return p. +

    4. If request's client's + global object is a {{ServiceWorkerGlobalScope}} object, + set request's service-workers mode to "foreign". +
    5. Let responseObject be a new {{Response}} object and a new associated {{Headers}} object whose guard is "immutable". @@ -5343,7 +5364,7 @@ therefore not shareable, a WebSocket connection is very close to identical to an

    6. Let request be a new request, whose url is requestURL, client is client, - skip-service-worker flag is set, + service-workers mode is "none", synchronous flag is set, mode is "websocket", credentials mode is