Skip to content

Commit e185219

Browse files
committed
Adding preloadResponse to fetch event.
1 parent 9f30fc7 commit e185219

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

docs/index.bs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
18371837
[Constructor(DOMString type, FetchEventInit eventInitDict), Exposed=ServiceWorker]
18381838
interface FetchEvent : ExtendableEvent {
18391839
[SameObject] readonly attribute Request request;
1840+
readonly attribute Promise<Response?> preloadResponse;
18401841
readonly attribute DOMString? clientId;
18411842
readonly attribute boolean isReload;
18421843

@@ -1846,6 +1847,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
18461847
<pre class="idl" id="fetch-event-init-dictionary">
18471848
dictionary FetchEventInit : ExtendableEventInit {
18481849
required Request request;
1850+
required Promise&lt;Response?&gt; preloadResponse;
18491851
DOMString? clientId = null;
18501852
boolean isReload = false;
18511853
};
@@ -1867,6 +1869,12 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
18671869
<p><dfn attribute id="fetch-event-request-attribute"><code>request</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to.</p>
18681870
</section>
18691871

1872+
<section>
1873+
<h4 id="fetch-event-preloadresponse">{{FetchEvent/preloadResponse|event.preloadResponse}}</h4>
1874+
1875+
<p><dfn attribute id="fetch-event-preloadresponse-attribute"><code>preloadResponse</code></dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to.</p>
1876+
</section>
1877+
18701878
<section>
18711879
<h4 id="fetch-event-clientid">{{FetchEvent/clientId|event.clientId}}</h4>
18721880

@@ -3717,7 +3725,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
37173725
<li>Let <var>response</var> be null.</li>
37183726
<li>Let <var>registration</var> be null.</li>
37193727
<li>Let <var>client</var> be the <a href="#dfn-service-worker-client">service worker client</a> that corresponds to <var>request</var>'s <a for="request">client</a>.</li>
3720-
<li>Let <var>navigationPreload</var> be null.</li>
3728+
<li>Let <var>preloadResponse</var> be a new <a>promise</a>.</li>
37213729
<li>Assert: <var>request</var>'s <a for="request">destination</a> is not "<code>serviceworker</code>".</li>
37223730
<li>If <var>request</var> is a <a>potential-navigation-or-subresource request</a>, then:
37233731
<ol>
@@ -3739,22 +3747,22 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
37393747
<li>Let <var>preloadResponseObject</var> be a new {{Response}} object and a new associated {{Headers}} object whose <a>guard</a> is "<code>immutable</code>"</li>
37403748
<li><a>Append to header list</a> <var>preloadRequestHeaders</var> a new <a>header</a> whose <a>name</a> is `<code>Service-Worker-Navigation-Preload</code>` and <a>value</a> is <var>registration</var>'s <a>navigation preload header value</a></li>
37413749
<li>Set <var>preloadRequest</var>'s <a>skip-service-worker flag</a></li>
3742-
<li>Set <var>navigationPreload</var> to a new <a>promise</a>.</li>
37433750
<li>Run the following substeps <a>in parallel</a>:
37443751
<ol>
37453752
<li>
37463753
<p><a>Fetch</a> <var>preloadRequest</var>.</p>
3747-
<p>To <a>process response</a> for <var>preloadResponse</var>, run these substeps:</p>
3754+
<p>To <a>process response</a> for <var>navigationPreloadResponse</var>, run these substeps:</p>
37483755
<ol>
3749-
<li><p>If <var>preloadResponse</var>'s <a for="response">type</a> is "<code>error</code>", reject <var>navigationPreload</var> with a <code>TypeError</code> and terminate these substeps.</li>
3750-
<li><p>Associate <var>preloadResponseObject</var> with <var>preloadResponse</var>.
3751-
<li><p>Resolve <var>navigationPreload</var> with <var>preloadResponseObject</var>.
3752-
</ol>
3756+
<li>If <var>navigationPreloadResponse</var>'s <a for="response">type</a> is "<code>error</code>", reject <var>navigationPreload</var> with a <code>TypeError</code> and terminate these substeps.</li>
3757+
<li>Associate <var>preloadResponseObject</var> with <var>navigationPreloadResponse</var>.
3758+
<li>Resolve <var>preloadResponse</var> with <var>navigationPreloadResponse</var>.
3759+
</ol>
37533760
</li>
37543761
</ol>
37553762
</li>
37563763
</ol>
37573764
</li>
3765+
<li>Else, resolve <var>preloadResponse</var> with undefined.</li>
37583766
</ol>
37593767
<p class="note">From this point, the <a href="#dfn-service-worker-client">service worker client</a> starts to <a href="#dfn-use">use</a> its <a href="#dfn-service-worker-client-active-worker">active worker</a>'s <a href="#dfn-containing-service-worker-registration">containing service worker registration</a>.</p>
37603768
</li>
@@ -3774,6 +3782,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
37743782
<ol>
37753783
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{FetchEvent}} interface, with the event type <code><a href="#service-worker-global-scope-fetch-event">fetch</a></code>, which does not bubble.</li>
37763784
<li>Let the <a href="#fetch-event-request-attribute">request</a> attribute of <var>e</var> be initialized to <var>r</var>.</li>
3785+
<li>Let the <a href="#fetch-event-preloadresponse-attribute">preloadResponse</a> attribute of <var>e</var> be initialized to <var>preloadResponse</var>.</li>
37773786
<li>Let the <a href="#fetch-event-clientid-attribute">clientId</a> attribute of <var>e</var> be initialized to <var>client</var>'s <a href="#dfn-service-worker-client-id">id</a> if <var>request</var> is not a <a>non-subresource request</a>, and to null otherwise.</li>
37783787
<li>Let the <a href="#fetch-event-isreload-attribute">isReload</a> attribute of <var>e</var> be initialized to <code>true</code> if <var>request</var>'s <a for="request">client</a> is a <a href="#dfn-window-client">window client</a> and the event was dispatched with the user's intention for the page reload, and <code>false</code> otherwise.</li>
37793788
<li><a>Dispatch</a> <var>e</var> at <var>activeWorker</var>'s <a>environment settings object</a>'s <a for="environment settings object">global object</a>.</li>

0 commit comments

Comments
 (0)