Skip to content

Commit 5577df5

Browse files
committed
add getRegistrationById()
1 parent 874ba0c commit 5577df5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docs/index.bs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
122122
}
123123
</pre>
124124

125-
<!-- TODO: expose getRegistrationById() -->
126-
<!-- TODO: uncontrol old clients that no longer match in Activate -->
127125
<!-- TODO: change scope logic -->
126+
<!-- TODO: uncontrol old clients that no longer match in Activate -->
128127

129128
<section>
130129
<h2 id="motivations">Motivations</h2>
@@ -693,6 +692,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
693692
[NewObject] Promise&lt;ServiceWorkerRegistration&gt; register(USVString scriptURL, optional RegistrationOptions options = {});
694693

695694
[NewObject] Promise&lt;any&gt; getRegistration(optional USVString clientURL = "");
695+
[NewObject] Promise&lt;any&gt; getRegistrationById(DOMString id);
696696
[NewObject] Promise&lt;FrozenArray&lt;ServiceWorkerRegistration&gt;&gt; getRegistrations();
697697

698698
void startMessages();
@@ -786,6 +786,20 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
786786
1. Return |promise|.
787787
</section>
788788

789+
<section algorithm="navigator-service-worker-getRegistrationById">
790+
<h4 id="navigator-service-worker-getRegistrationById">{{ServiceWorkerContainer/getRegistrationById(id)}}</h4>
791+
792+
<dfn method for="ServiceWorkerContainer"><code>getRegistrationById(|id|)</code></dfn> method steps are:
793+
794+
1. Let |origin| be [=current settings object=]'s [=environment settings object/origin=].
795+
1. Let |promise| be a new <a>promise</a>.
796+
1. Run the following substeps <a>in parallel</a>
797+
1. Let |registration| be the result of running the [=GetRegistration=] algorithm passing |origin| and |id| as the arguments.
798+
1. If |registration| is null, resolve |promise| with undefined and abort these steps.
799+
1. Resolve |promise| with the result of [=getting the service worker registration object=] that represents |registration| in |promise|'s [=relevant settings object=].
800+
1. Return |promise|.
801+
</section>
802+
789803
<section algorithm="navigator-service-worker-getRegistrations">
790804
<h4 id="navigator-service-worker-getRegistrations">{{ServiceWorkerContainer/getRegistrations()}}</h4>
791805

0 commit comments

Comments
 (0)