@@ -711,8 +711,27 @@ explicitly set <a for=/>request</a>'s
711711this flag set are subject to additional processing requirements.
712712
713713<p> A <a for=/>request</a> has an associated
714- <dfn export>skip-service-worker flag</dfn> . Unless stated otherwise it is
715- unset.
714+ <dfn for=request export>service-workers mode</dfn> , that is "<code> all</code> ",
715+ "<code> foreign</code> ", or "<code> none</code> ". Unless stated otherwise it is
716+ "<code> all</code> ".
717+
718+ <div class=note>
719+ <p> This determines which service workers will receive a {{fetch!!event}} event for this fetch.
720+
721+ <dl>
722+ <dt> "<code> all</code> "
723+ <dd> Relevant local and foreign service workers will get a {{fetch!!event}} or
724+ {{foreignfetch!!event}} event for this fetch.
725+
726+ <dt> "<code> foreign</code> "
727+ <dd> Only relevant foreign service workers will get a {{foreignfetch!!event}} event for this fetch.
728+ {{fetch(input)!!method}} uses this to bypass the current service worker if the global is a
729+ {{ServiceWorkerGlobalScope}} .
730+
731+ <dt> "<code> none</code> "
732+ <dd> Neither local nor foreign service workers will get events for this fetch.
733+ </dd>
734+ </div>
716735
717736<p> A <a for=/>request</a> has an associated
718737<dfn export for=request id=concept-request-initiator>initiator</dfn> , which is
@@ -2806,16 +2825,13 @@ optional <i>CORS flag</i> and <i>CORS-preflight flag</i>, run these steps:
28062825 <li><p> Let <var> actualResponse</var> be null.
28072826
28082827 <li>
2809- <p> If <var> request</var> 's <a>skip- service-worker flag </a> is unset , then run these
2828+ <p> If <var> request</var> 's <a>service-workers mode </a> is not " <code> none </code> " , then run these
28102829 substeps:
28112830
28122831 <ol>
28132832 <li>
2814- <p> If <var> request</var> 's <a for=request>client</a> is null or
2815- <var> request</var> 's <a for=request>client</a>' s
2816- <a for="environment settings object">global object</a> is not a
2817- {{ServiceWorkerGlobalScope}} object, then set <var> response</var>
2818- to the result of invoking <a for=/>handle fetch</a> for <var> request</var> .
2833+ <p> If <var> request</var> 's <a>service-workers mode</a> is "<code> all</code> ", then set
2834+ <var> response</var> to the result of invoking <a for=/>handle fetch</a> for <var> request</var> .
28192835 [[!HTML]] [[!SW]]
28202836
28212837 <li>
@@ -2906,7 +2922,8 @@ optional <i>CORS flag</i> and <i>CORS-preflight flag</i>, run these steps:
29062922
29072923 <li>
29082924 <p> If <var> request</var> 's <a for=request>redirect mode</a> is
2909- "<code> follow</code> ", then set <var> request</var> 's <a>skip-service-worker flag</a> .
2925+ "<code> follow</code> ", then set <var> request</var> 's <a>service-workers mode</a> to
2926+ "<code> foreign</code> ".
29102927
29112928 <p class="note no-backref"> Redirects coming from the network (as opposed to from a service
29122929 worker) are not to be exposed to a service worker.
@@ -5259,6 +5276,10 @@ method, must run these steps:
52595276 <var> init</var> as arguments. If this throws an exception, reject
52605277 <var> p</var> with it and return <var> p</var> .
52615278
5279+ <li> If <var> request</var> 's <a for=request>client</a>' s
5280+ <a for="environment settings object">global object</a> is a {{ServiceWorkerGlobalScope}} object,
5281+ set <var> request</var> 's <a>service-workers mode</a> to "<code> foreign</code> ".
5282+
52625283 <li><p> Let <var> responseObject</var> be a new {{Response}} object and a new associated
52635284 {{Headers}} object whose <a for=Headers>guard</a> is
52645285 "<code> immutable</code> ".
@@ -5410,7 +5431,7 @@ therefore not shareable, a WebSocket connection is very close to identical to an
54105431 <li><p> Let <var> request</var> be a new <a for=/>request</a> , whose
54115432 <a for=request>url</a> is <var> requestURL</var> ,
54125433 <a for=request>client</a> is <var> client</var> ,
5413- <a>skip- service-worker flag </a> is set ,
5434+ <a>service-workers mode </a> is " <code> none </code> " ,
54145435 <a>synchronous flag</a> is set,
54155436 <a for=request>mode</a> is "<code> websocket</code> ",
54165437 <a for=request>credentials mode</a> is
0 commit comments