Re: [w3c/ServiceWorker] Add Register a Service Worker algorithm for use by other specifications (PR #1848)

@monica-ch commented on this pull request.



> +  <section algorithm>
+    <h3 id="register-a-service-worker-algorithm"><dfn export>Register a Service Worker</dfn></h3>
+
+    Note: Because this algorithm has no calling [=/service worker client=], the [=job/referrer=] is not set by [=Create Job=]. To satisfy the same-origin checks in the [=Register=] algorithm (steps 2 and 3), this algorithm explicitly sets the job's [=job/referrer=] to |scriptURL|. Combined with the same-origin precondition asserted in step 1, this ensures both same-origin checks in [=Register=] pass.
+
+      : Input
+      :: |storageKey|, a [=/storage key=]
+      :: |scriptURL|, a [=/URL=]
+      :: |scopeURL|, a [=/URL=]
+      :: |workerType|, a [=job/worker type=]
+      :: |updateViaCache|, a [=service worker registration/update via cache mode=]
+      : Output
+      :: None
+
+      1. Assert: |scriptURL|'s [=url/origin=] and |scopeURL|'s [=url/origin=] are [=same origin=].
+      1. If the result of running <a>potentially trustworthy origin</a> with |scriptURL|'s [=url/origin=] as the argument is <code>Not Trusted</code>, return.

Addressed in e053de5. I extracted the fragment removal, HTTP/HTTPS scheme check, and encoded-slash path check into a shared `Validate and Normalize a Service Worker URL` algorithm. Both `Start Register` and the exported `Register a Service Worker` algorithm now use it, while `Start Register` retains its existing `TypeError` rejection and scope-defaulting behavior.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1848#discussion_r3964792255
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/pull/1848/review/5149928967@github.com>

Received on Wednesday, 9 September 2026 04:57:49 UTC