Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
[Exposed=ServiceWorker]
interface InstallEvent : ExtendableEvent {
constructor(DOMString type, optional ExtendableEventInit eventInitDict = {});
Promise<undefined> addRoutes((RouterRule or sequence<RouterRule>) rules);
Promise<undefined> addRoutes(Promise<(RouterRule or sequence<RouterRule>)> rules);
};

dictionary RouterRule {
Expand Down Expand Up @@ -1605,15 +1605,25 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/

The <dfn method for="InstallEvent"><code>addRoutes(|rules|)</code></dfn> method steps are:

1. Let |event| be [=this=].
1. If |event|'s [=dispatch flag=] is unset, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. [=ExtendableEvent/Add lifetime promise=] |rules| to |event|.

Note: {{InstallEvent/addRoutes(r)|event.addRoutes(r)}} extends the lifetime of the event by default as if {{ExtendableEvent/waitUntil()|event.waitUntil(r)}} is called.

1. Let |serviceWorker| be the [=current global object=]'s associated [=ServiceWorkerGlobalScope/service worker=].
1. Let |routerRules| be a copy of |serviceWorker|'s [=list of router rules=].
1. If |rules| is a {{RouterRule}} dictionary, set |rules| to &#x00AB; |rules| &#x00BB;.
1. For each |rule| of |rules|:
1. If running the [=Verify Router Condition=] algorithm with |rule|["{{RouterRule/condition}}"] and |serviceWorker| returns false, return [=a promise rejected with=] a {{TypeError}}.
1. Append |rule| to |routerRules|.
1. If |routerRules| [=list/contains=] a {{RouterRule}} whose {{RouterRule/source}} is "{{RouterSourceEnum/fetch-event}}" and |serviceWorker|'s [=set of event types to handle=] does not [=set/contain=] {{ServiceWorkerGlobalScope/fetch!!event}}, return [=a promise rejected with=] a {{TypeError}}.
1. Set |serviceWorker|'s [=service worker/list of router rules=] to |routerRules|.
1. Return [=a promise resolved with=] undefined.
1. Let |allRules| be a copy of |serviceWorker|'s [=list of router rules=].
1. [=Upon rejection=] of |rules|:
1. Return [=a promise rejected with=] a {{TypeError}}.
1. [=Upon fulfillment=] of |rules| with |routerRules|:
1. If |routerRules| is not either of a {{RouterRule}} dictionary or a sequence of {{RouterRule}} dictionaries, then return [=a promise rejected with=] a {{TypeError}}.
1. If |routerRules| is a {{RouterRule}} dictionary, set |routerRules| to &#x00AB; |routerRules| &#x00BB;.
1. For each |rule| of |routerRules|:
1. If running the [=Verify Router Condition=] algorithm with |rule|["{{RouterRule/condition}}"] and |serviceWorker| returns false, return [=a promise rejected with=] a {{TypeError}}.
1. Append |rule| to |allRules|.
1. If |allRules| [=list/contains=] a {{RouterRule}} whose {{RouterRule/source}} is "{{RouterSourceEnum/fetch-event}}" and |serviceWorker|'s [=set of event types to handle=] does not [=set/contain=] {{ServiceWorkerGlobalScope/fetch!!event}}, return [=a promise rejected with=] a {{TypeError}}.
1. Set |serviceWorker|'s [=service worker/list of router rules=] to |allRules|.
1. Return [=a promise resolved with=] undefined.

</section>
</section>
Expand Down
Loading