From 0a553aff1b0d47984816c9552703db2d2a99f323 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Tue, 28 Nov 2023 03:37:38 +0000 Subject: [PATCH 01/20] Revive of PR #1686. I used to work on the specification update to support the ServiceWorker static routing API (https://github.com/WICG/service-worker-static-routing-api) https://github.com/w3c/ServiceWorker/pull/1686 However, I accidentally closed it by force-sync to the ServiceWorker specification's repository HEAD. This CL is for reviving it. --- docs/index.bs | 134 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index a5b3635f..468c5cc9 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -133,6 +133,22 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ text: obtain a storage key; url: obtain-a-storage-key text: storage key/equals; url: storage-key-equals +spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ + type: dfn + text: parse; for: urlpattern; url: parse-a-pattern-string + text: component; for: urlpattern; url: component + text: match; for: urlpattern; url: match + text: protocol component; for: urlpattern; url: urlpattern-protocol-component + text: username component; for: urlpattern; url: urlpattern-username-component + text: password component; for: urlpattern; url: urlpattern-password-component + text: hostname component; for: urlpattern; url: urlpattern-hostname-component + text: port component; for: urlpattern; url: urlpattern-port-component + text: pathname component; for: urlpattern; url: urlpattern-pathname-component + text: search component; for: urlpattern; url: urlpattern-search-component + text: hash component; for: urlpattern; url: urlpattern-hash-component + text: pattern string; for: urlpattern-component; url: component-pattern-string + text: type; for: urlpattern-part; url: part-type +
@@ -207,6 +223,8 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
 
     A [=/service worker=] has an associated all fetch listeners are empty flag. It is initially unset.
 
+    A [=/service worker=] has an associated static router rules object. It is initially unset.
+
     A [=/service worker=] is said to be running if its [=event loop=] is running.
 
     
@@ -1545,6 +1563,46 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ Note: [=/Service workers=] delay treating the [=installing worker=] as "`installed`" until all the [=promises=] in the {{install!!event}} event's [=extend lifetime promises=] resolve successfully. (See the relevant [Install algorithm step](#install-settle-step).) If any of the promises rejects, the installation fails. This is primarily used to ensure that a [=/service worker=] is not considered "`installed`" until all of the core caches it depends on are populated. Likewise, [=/service workers=] delay treating the [=active worker=] as "`activated`" until all the [=promises=] in the {{activate!!event}} event's [=extend lifetime promises=] settle. (See the relevant [Activate algorithm step](#activate-settle-step).) This is primarily used to ensure that any [=functional events=] are not dispatched to the [=/service worker=] until it upgrades database schemas and deletes the outdated cache entries.
+
+

{{InstallEvent}}

+ +
+      [Exposed=ServiceWorker]
+      interface InstallEvent : ExtendableEvent {
+        Promise<undefined> registerRouter((RouterRule or sequence<RouterRule>) rules);
+      };
+
+      dictionary RouterRule {
+        required RouterCondition condition;
+        required RouterSourceEnum source;
+      };
+
+      dictionary RouterCondition {
+        USVString urlPattern;
+      };
+
+      enum RouterSourceEnum { "network" };
+    
+ + Each {{RouterCondition/urlPattern}} object has an associated URLPattern, a {{URLPattern}}, which is initially unset. + +
+

{{InstallEvent/registerRouter(rules)|event.registerRouter(rules)}}

+ + {{InstallEvent/registerRouter(rules)}} registers this service worker the rules to offload simple tasks that the fetch handler does. + + registerRouter(|rules|) method *must* run these steps: + + 1. Let |routerRules| be a list of {{RouterRule}} dictionaries. + 1. If |rules| is a {{RouterRule}} dictionary, set |rules| to « |rules| ». + 1. for each |rule| in |rules|: + 1. If running [=VerifyRouterRule=] algorithm with |rule| and [=/service worker=] returns false, throw a TypeError. + 1. Append |rule| to |routerRules|. + 1. Set [=/service worker=]'s [=static router rules object=] to |routerRules|. + +
+
+

{{FetchEvent}}

@@ -2822,7 +2880,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Set |installFailed| to true. 1. Else: 1. [=Queue a task=] |task| on |installingWorker|'s [=event loop=] using the [=DOM manipulation task source=] to run the following steps: - 1. Let |e| be the result of creating an event with {{ExtendableEvent}}. + 1. Let |e| be the result of creating an event with {{InstallEvent}}. 1. Initialize |e|’s {{Event/type}} attribute to {{install!!event}}. 1. Dispatch |e| at |installingWorker|'s [=service worker/global object=]. 1. *WaitForAsynchronousExtensions*: Run the following substeps in parallel: @@ -3067,6 +3125,8 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Assert: |request|'s [=request/destination=] is not "serviceworker". 1. If |request|'s [=request/destination=] is either "embed" or "object", then: 1. Return null. + 1. Else if |registration|'s active worker's [=static router rules object=] is set: + 1. If running [=GetRouterSource=] algorithm with [=static router rules object=] and |request| returns "network", return null. 1. Else if |request| is a non-subresource request, then: 1. If |reservedClient| is not null and is an environment settings object, then: 1. If |reservedClient| is not a secure context, return null. @@ -3175,6 +3235,78 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Return |response|.
+
+

VerifyRouterRule

+ + : Input + :: |rule|, a {{RouterRule}} + :: |serviceWorker|, a [=/service worker=] + : Output + :: a boolean + + 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] is the empty string, return false. + 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. + 1. If |rawPattern| is a [=string=], then: + 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. + 1. Set |pattern| to the result of constructing a {{URLPattern}} using the {{URLPattern/URLPattern(input, baseURL)}} constructor steps given |rawPattern| and |baseURL|. If those steps throw, catch the exception and return false. + 1. Otherwise, if |rawPattern| is {{URLPatternInit}}: + 1. Set |pattern| to the result of constructing a {{URLPattern}} using the {{URLPattern/URLPattern(input)}} constructor steps given |rawPattern|. If those steps throw, catch the exception and return false. + 1. Otherwise, return false. + 1. If running the [=VerifyURLPattern=] algorithm with |pattern| returns false, return false. + 1. Set |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated {{URLPattern}} to |pattern|. + 1. Return true. +
+ +
+

VerifyURLPattern

+ + : Input + :: |pattern|, a {{URLPattern}} + : Output + :: a boolean + + 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/protocol component=] returns false, return false. + 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/username component=] returns false, return false. + 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/password component=] returns false, return false. + 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/hostname component=] returns false, return false. + 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/port component=] returns false, return false. + 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/pathname component=] returns false, return false. + 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/search component=] returns false, return false. + 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/hash component=] returns false, return false. + 1. Return true. +
+ +
+

VerifyURLPatternComponent

+ + : Input + :: |component|, a [=component=]. + : Output + :: a boolean + + 1. Let |parts| be a result of [=urlpattern/parsing=] |component|'s associated [=urlpattern-component/pattern string=]. + 1. [=list/For each=] |part| of |parts|: + 1. If |part|'s [=urlpattern-part/type=] is "regexp", return false. + + Note: Since running a user-defined regular expression has a security concern, it is prohibited. + + 1. Return true. +
+ +
+

GetRouterSource

+ : Input + :: |rules|, a list of {{RouterRule}} + :: |request|, a [=/request=] + : Output + :: {{RouterSourceEnum}} or null + + 1. [=list/For each=] |rule| of |rules|: + 1. If running [=urlpattern/match=] with |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated [=URLPattern=] and |request|'s [=request/URL=] returns null, [=continue=]. + 1. Return |rule|'s {{RouterRule/source}}. + 1. Return null. +
+

Should Skip Event

: Input From bdc2474497ca62a01eddd7180fb38486f758c8f4 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Thu, 30 Nov 2023 07:27:14 +0000 Subject: [PATCH 02/20] Introduce changes upon whatwg/urlpattern#199. --- docs/index.bs | 61 ++++++++++----------------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 468c5cc9..097f0469 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -1569,7 +1569,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/
       [Exposed=ServiceWorker]
       interface InstallEvent : ExtendableEvent {
-        Promise<undefined> registerRouter((RouterRule or sequence<RouterRule>) rules);
+        Promise<undefined> addRoutes((RouterRule or sequence<RouterRule>) rules);
       };
 
       dictionary RouterRule {
@@ -1578,24 +1578,24 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/
       };
 
       dictionary RouterCondition {
-        USVString urlPattern;
+        URLPatternCompatible urlPattern;
       };
 
-      enum RouterSourceEnum { "network" };
+      enum RouterSource { "network" };
     
Each {{RouterCondition/urlPattern}} object has an associated URLPattern, a {{URLPattern}}, which is initially unset.
-

{{InstallEvent/registerRouter(rules)|event.registerRouter(rules)}}

+

{{InstallEvent/addRoutes(rules)|event.addRoutes(rules)}}

- {{InstallEvent/registerRouter(rules)}} registers this service worker the rules to offload simple tasks that the fetch handler does. + {{InstallEvent/addRoutes(rules)}} registers this service worker the rules to offload simple tasks that the fetch handler does. - registerRouter(|rules|) method *must* run these steps: + addRoutes(|rules|) method *must* run these steps: 1. Let |routerRules| be a list of {{RouterRule}} dictionaries. 1. If |rules| is a {{RouterRule}} dictionary, set |rules| to « |rules| ». - 1. for each |rule| in |rules|: + 1. For each |rule| of |rules|: 1. If running [=VerifyRouterRule=] algorithm with |rule| and [=/service worker=] returns false, throw a TypeError. 1. Append |rule| to |routerRules|. 1. Set [=/service worker=]'s [=static router rules object=] to |routerRules|. @@ -3244,52 +3244,13 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ : Output :: a boolean - 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] is the empty string, return false. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. If |rawPattern| is a [=string=], then: - 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. - 1. Set |pattern| to the result of constructing a {{URLPattern}} using the {{URLPattern/URLPattern(input, baseURL)}} constructor steps given |rawPattern| and |baseURL|. If those steps throw, catch the exception and return false. - 1. Otherwise, if |rawPattern| is {{URLPatternInit}}: - 1. Set |pattern| to the result of constructing a {{URLPattern}} using the {{URLPattern/URLPattern(input)}} constructor steps given |rawPattern|. If those steps throw, catch the exception and return false. - 1. Otherwise, return false. - 1. If running the [=VerifyURLPattern=] algorithm with |pattern| returns false, return false. - 1. Set |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated {{URLPattern}} to |pattern|. - 1. Return true. -
- -
-

VerifyURLPattern

- - : Input - :: |pattern|, a {{URLPattern}} - : Output - :: a boolean - - 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/protocol component=] returns false, return false. - 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/username component=] returns false, return false. - 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/password component=] returns false, return false. - 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/hostname component=] returns false, return false. - 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/port component=] returns false, return false. - 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/pathname component=] returns false, return false. - 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/search component=] returns false, return false. - 1. If running the [=VerifyURLPatternComponent=] algorithm with |pattern|'s [=urlpattern/hash component=] returns false, return false. - 1. Return true. -
+ 1. Let |pattern| be the result of [=building a URLPattern from a Web IDL value=] |rawPattern| given |baseURL| and |serivceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false. + 1. If |pattern| [=URLPattern/has regexp groups=] returns true, return false. -
-

VerifyURLPatternComponent

- - : Input - :: |component|, a [=component=]. - : Output - :: a boolean - - 1. Let |parts| be a result of [=urlpattern/parsing=] |component|'s associated [=urlpattern-component/pattern string=]. - 1. [=list/For each=] |part| of |parts|: - 1. If |part|'s [=urlpattern-part/type=] is "regexp", return false. - - Note: Since running a user-defined regular expression has a security concern, it is prohibited. + Note: Since running a user-defined regular expression has a security concern, it is prohibited. + 1. Set |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated {{URLPattern}} to |pattern|. 1. Return true.
From ef050e2ebda1757c39c63a28555c90b5791ae452 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Thu, 30 Nov 2023 08:35:17 +0000 Subject: [PATCH 03/20] Fixed the parse error. --- docs/index.bs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index 097f0469..9cb17ca8 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3244,8 +3244,9 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ : Output :: a boolean + 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of [=building a URLPattern from a Web IDL value=] |rawPattern| given |baseURL| and |serivceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false. + 1. Let |pattern| be the result of [=building a URLPattern from a Web IDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false. 1. If |pattern| [=URLPattern/has regexp groups=] returns true, return false. Note: Since running a user-defined regular expression has a security concern, it is prohibited. From 39b670fcdc058c85b6ec60c50c4a75d1cf254a80 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Thu, 30 Nov 2023 08:46:48 +0000 Subject: [PATCH 04/20] clean up. --- docs/index.bs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 9cb17ca8..b6680dab 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -135,19 +135,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ type: dfn - text: parse; for: urlpattern; url: parse-a-pattern-string - text: component; for: urlpattern; url: component text: match; for: urlpattern; url: match - text: protocol component; for: urlpattern; url: urlpattern-protocol-component - text: username component; for: urlpattern; url: urlpattern-username-component - text: password component; for: urlpattern; url: urlpattern-password-component - text: hostname component; for: urlpattern; url: urlpattern-hostname-component - text: port component; for: urlpattern; url: urlpattern-port-component - text: pathname component; for: urlpattern; url: urlpattern-pathname-component - text: search component; for: urlpattern; url: urlpattern-search-component - text: hash component; for: urlpattern; url: urlpattern-hash-component - text: pattern string; for: urlpattern-component; url: component-pattern-string - text: type; for: urlpattern-part; url: part-type
@@ -1574,7 +1562,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ dictionary RouterRule { required RouterCondition condition; - required RouterSourceEnum source; + required RouterSource source; }; dictionary RouterCondition { @@ -3246,7 +3234,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of [=building a URLPattern from a Web IDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false. + 1. Let |pattern| be the result of [=URLPattern/building a URLPattern from a WebIDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false. 1. If |pattern| [=URLPattern/has regexp groups=] returns true, return false. Note: Since running a user-defined regular expression has a security concern, it is prohibited. @@ -3261,7 +3249,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ :: |rules|, a list of {{RouterRule}} :: |request|, a [=/request=] : Output - :: {{RouterSourceEnum}} or null + :: {{RouterSource}} or null 1. [=list/For each=] |rule| of |rules|: 1. If running [=urlpattern/match=] with |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated [=URLPattern=] and |request|'s [=request/URL=] returns null, [=continue=]. From 75d848a2677154d1651057629fb37a1f4b5f799c Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Thu, 30 Nov 2023 09:06:45 +0000 Subject: [PATCH 05/20] another dfn fix. --- docs/index.bs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index b6680dab..bd567b36 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -136,6 +136,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ type: dfn text: match; for: urlpattern; url: match + text: building a urlpattern from a webidl value; for: urlpattern; url: building-a-urlpattern-from-a-webidl-value @@ -3234,7 +3235,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of [=URLPattern/building a URLPattern from a WebIDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false. + 1. Let |pattern| be the result of [=urlpattern/building a URLPattern from a WebIDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false. 1. If |pattern| [=URLPattern/has regexp groups=] returns true, return false. Note: Since running a user-defined regular expression has a security concern, it is prohibited. From 025eb824511ddfb0565b6526fd0c7fab3b7dc849 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Thu, 30 Nov 2023 09:36:11 +0000 Subject: [PATCH 06/20] Rename of static router rules object. --- docs/index.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index bd567b36..6a44b1f0 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -212,7 +212,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ A [=/service worker=] has an associated all fetch listeners are empty flag. It is initially unset. - A [=/service worker=] has an associated static router rules object. It is initially unset. + A [=/service worker=] has an associated list of router rules. It is initially unset. A [=/service worker=] is said to be running if its [=event loop=] is running. @@ -1587,7 +1587,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. For each |rule| of |rules|: 1. If running [=VerifyRouterRule=] algorithm with |rule| and [=/service worker=] returns false, throw a TypeError. 1. Append |rule| to |routerRules|. - 1. Set [=/service worker=]'s [=static router rules object=] to |routerRules|. + 1. Set [=/service worker=]'s [=service worker/list of router rules=] to |routerRules|. @@ -3114,8 +3114,8 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. Assert: |request|'s [=request/destination=] is not "serviceworker". 1. If |request|'s [=request/destination=] is either "embed" or "object", then: 1. Return null. - 1. Else if |registration|'s active worker's [=static router rules object=] is set: - 1. If running [=GetRouterSource=] algorithm with [=static router rules object=] and |request| returns "network", return null. + 1. Else if |registration|'s active worker's [=service worker/list of router rules=] is set: + 1. If running [=GetRouterSource=] algorithm with [=service worker/list of router rules=] and |request| returns "network", return null. 1. Else if |request| is a non-subresource request, then: 1. If |reservedClient| is not null and is an environment settings object, then: 1. If |reservedClient| is not a secure context, return null. From d90ac0badd719f9e91c3d5c5ee3702d684b2ab9a Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Thu, 30 Nov 2023 09:56:20 +0000 Subject: [PATCH 07/20] Stop associating the URLPattern and construct URLPattern on-demand. --- docs/index.bs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 6a44b1f0..fc963b41 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -1573,8 +1573,6 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ enum RouterSource { "network" }; - Each {{RouterCondition/urlPattern}} object has an associated URLPattern, a {{URLPattern}}, which is initially unset. -

{{InstallEvent/addRoutes(rules)|event.addRoutes(rules)}}

@@ -3115,7 +3113,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. If |request|'s [=request/destination=] is either "embed" or "object", then: 1. Return null. 1. Else if |registration|'s active worker's [=service worker/list of router rules=] is set: - 1. If running [=GetRouterSource=] algorithm with [=service worker/list of router rules=] and |request| returns "network", return null. + 1. If running [=GetRouterSource=] algorithm with active worker and |request| returns "network", return null. 1. Else if |request| is a non-subresource request, then: 1. If |reservedClient| is not null and is an environment settings object, then: 1. If |reservedClient| is not a secure context, return null. @@ -3224,6 +3222,18 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. Return |response|.
+
+

ParseURLPattern

+ : Input + :: |rawPattern|, a {{RouterCondition/urlPattern}}" + :: |serviceWorker|, a [=/service worker=] + : Output + :: {{URLPattern}} + + 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. + 1. Return the result of [=urlpattern/building a URLPattern from a WebIDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. +
+

VerifyRouterRule

@@ -3233,27 +3243,27 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ : Output :: a boolean - 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of [=urlpattern/building a URLPattern from a WebIDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. If this throws an exception, catch it and return false. + 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. 1. If |pattern| [=URLPattern/has regexp groups=] returns true, return false. Note: Since running a user-defined regular expression has a security concern, it is prohibited. - 1. Set |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated {{URLPattern}} to |pattern|. 1. Return true.

GetRouterSource

: Input - :: |rules|, a list of {{RouterRule}} + :: |serviceWorker|, a [=/service worker=] :: |request|, a [=/request=] : Output :: {{RouterSource}} or null - 1. [=list/For each=] |rule| of |rules|: - 1. If running [=urlpattern/match=] with |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]'s associated [=URLPattern=] and |request|'s [=request/URL=] returns null, [=continue=]. + 1. [=list/For each=] |rule| of |serviceWorker|'s [=service worker/list of router rules=]: + 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. + 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. + 1. If running [=urlpattern/match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. 1. Return |rule|'s {{RouterRule/source}}. 1. Return null.
From 65776401d7f842bbae63079fafeaa2fb79e22056 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Mon, 4 Dec 2023 07:00:32 +0000 Subject: [PATCH 08/20] Addressed some of comments. --- docs/index.bs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index fc963b41..5d375f14 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -136,7 +136,6 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ type: dfn text: match; for: urlpattern; url: match - text: building a urlpattern from a webidl value; for: urlpattern; url: building-a-urlpattern-from-a-webidl-value @@ -1578,7 +1577,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ {{InstallEvent/addRoutes(rules)}} registers this service worker the rules to offload simple tasks that the fetch handler does. - addRoutes(|rules|) method *must* run these steps: + The addRoutes(|rules|) method steps are: 1. Let |routerRules| be a list of {{RouterRule}} dictionaries. 1. If |rules| is a {{RouterRule}} dictionary, set |rules| to « |rules| ». @@ -3225,13 +3224,13 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/

ParseURLPattern

: Input - :: |rawPattern|, a {{RouterCondition/urlPattern}}" + :: |rawPattern|, a [=string=] :: |serviceWorker|, a [=/service worker=] : Output :: {{URLPattern}} 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. - 1. Return the result of [=urlpattern/building a URLPattern from a WebIDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. + 1. Return the result of [=building a URLPattern from a WebIDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=].
@@ -3243,9 +3242,11 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ : Output :: a boolean + 1. If |rule|["{{RouterRule/condition}}"] does not [=map/exist=], return false. + 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], return false. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. - 1. If |pattern| [=URLPattern/has regexp groups=] returns true, return false. + 1. If |pattern| [=URLPattern/has regexp groups=], then return false. Note: Since running a user-defined regular expression has a security concern, it is prohibited. @@ -3261,10 +3262,12 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ :: {{RouterSource}} or null 1. [=list/For each=] |rule| of |serviceWorker|'s [=service worker/list of router rules=]: - 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. - 1. If running [=urlpattern/match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. - 1. Return |rule|'s {{RouterRule/source}}. + 1. If |rule|["{{RouterRule/condition}}"] does not [=map/exist=], continue. + 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] [=map/exists=], then: + 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. + 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. + 1. If running [=urlpattern/match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. + 1. Return |rule|'s {{RouterRule/source}}. 1. Return null.
From cd5c86420582347652d860cd6b97c88dd05f27e1 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Mon, 4 Dec 2023 08:29:55 +0000 Subject: [PATCH 09/20] Update the case without the urlPattern condition. Considering the future update of the condition, we should mark the case handled as one of conditions. Also, we need to make it extensible. --- docs/index.bs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 5d375f14..05e1eeeb 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3242,15 +3242,18 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ : Output :: a boolean - 1. If |rule|["{{RouterRule/condition}}"] does not [=map/exist=], return false. - 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], return false. - 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. - 1. If |pattern| [=URLPattern/has regexp groups=], then return false. + 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], then: + 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. + 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. + 1. If |pattern| [=URLPattern/has regexp groups=], then return false. - Note: Since running a user-defined regular expression has a security concern, it is prohibited. + Note: Since running a user-defined regular expression has a security concern, it is prohibited. - 1. Return true. + 1. Return true. + + Note: support for other conditions will be implemented here. + + 1. Return false.
@@ -3268,6 +3271,9 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. 1. If running [=urlpattern/match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. 1. Return |rule|'s {{RouterRule/source}}. + + Note: support for other conditions will be implemented here. + 1. Return null.
From 0162980cdf85f3e68f5d132def90e37f7b3363b2 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Mon, 4 Dec 2023 08:47:24 +0000 Subject: [PATCH 10/20] Fix the urlPattern existence handling. It was flipped by mistake. --- docs/index.bs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 05e1eeeb..b234ac53 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3242,7 +3242,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ : Output :: a boolean - 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], then: + 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] [=map/exists=], then: 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. 1. If |pattern| [=URLPattern/has regexp groups=], then return false. @@ -3251,8 +3251,6 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. Return true. - Note: support for other conditions will be implemented here. - 1. Return false. @@ -3272,8 +3270,6 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/ 1. If running [=urlpattern/match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. 1. Return |rule|'s {{RouterRule/source}}. - Note: support for other conditions will be implemented here. - 1. Return null. From 4639e6c06d0fd8bc855737df4da7bee18becf736 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Mon, 4 Dec 2023 09:00:04 +0000 Subject: [PATCH 11/20] Remove the "spec: urlpattern; ..." line. --- docs/index.bs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index b234ac53..1692ad5c 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -51,6 +51,7 @@ spec: webidl; text: resolve; spec:csp-next; type:dfn; text:enforced +spec:urlpattern; type:dfn; text:match
@@ -132,11 +133,6 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
         text: storage key; url: storage-key
         text: obtain a storage key; url: obtain-a-storage-key
         text: storage key/equals; url: storage-key-equals
-
-spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/
-    type: dfn
-        text: match; for: urlpattern; url: match
-
 
@@ -3267,7 +3263,7 @@ spec: urlpattern; urlPrefix: https://wicg.github.io/urlpattern/
           1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] [=map/exists=], then:
               1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"].
               1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|.
-              1. If running [=urlpattern/match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=].
+              1. If running [=match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=].
               1. Return |rule|'s {{RouterRule/source}}.
 
       1. Return null.

From f4f57ececba28fab79073ca42bd7ee775d2016d3 Mon Sep 17 00:00:00 2001
From: Yoshisato Yanagisawa 
Date: Mon, 4 Dec 2023 09:05:39 +0000
Subject: [PATCH 12/20] Simplified the if statement on urlPattern condition
 does not exist.

---
 docs/index.bs | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/docs/index.bs b/docs/index.bs
index 1692ad5c..8841853f 100644
--- a/docs/index.bs
+++ b/docs/index.bs
@@ -3238,16 +3238,14 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
       : Output
       :: a boolean
 
-      1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] [=map/exists=], then:
-          1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"].
-          1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false.
-          1. If |pattern| [=URLPattern/has regexp groups=], then return false.
-
-              Note: Since running a user-defined regular expression has a security concern, it is prohibited.
+      1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exiss=], Return false.
+      1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"].
+      1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false.
+      1. If |pattern| [=URLPattern/has regexp groups=], then return false.
 
-          1. Return true.
+          Note: Since running a user-defined regular expression has a security concern, it is prohibited.
 
-      1. Return false.
+      1. Return true.
   
 
   
@@ -3259,12 +3257,11 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ :: {{RouterSource}} or null 1. [=list/For each=] |rule| of |serviceWorker|'s [=service worker/list of router rules=]: - 1. If |rule|["{{RouterRule/condition}}"] does not [=map/exist=], continue. - 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] [=map/exists=], then: - 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. - 1. If running [=match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. - 1. Return |rule|'s {{RouterRule/source}}. + 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], continue. + 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. + 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. + 1. If running [=match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. + 1. Return |rule|'s {{RouterRule/source}}. 1. Return null.
From 0d4ed51ef4e95c4361f84e7e962f968df52ceac7 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Mon, 4 Dec 2023 09:06:47 +0000 Subject: [PATCH 13/20] Fix typo. --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index 8841853f..c166754e 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3238,7 +3238,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ : Output :: a boolean - 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exiss=], Return false. + 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], Return false. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. 1. If |pattern| [=URLPattern/has regexp groups=], then return false. From dd0590bbcb968784fe462e4b2e9f6cffbc35b870 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 6 Dec 2023 07:19:53 +0000 Subject: [PATCH 14/20] Merged the simple fixes. --- docs/index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index c166754e..d8968f43 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3238,7 +3238,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ : Output :: a boolean - 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], Return false. + 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], return false. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. 1. If |pattern| [=URLPattern/has regexp groups=], then return false. @@ -3261,7 +3261,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. 1. If running [=match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. - 1. Return |rule|'s {{RouterRule/source}}. + 1. Return |rule|["{{RouterRule/source}}"]. 1. Return null. From 8bfef6fc8ad1260cb63f33ddd8faa4df6e236986 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 6 Dec 2023 07:21:04 +0000 Subject: [PATCH 15/20] siple fix. --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index d8968f43..f0233398 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3108,7 +3108,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. If |request|'s [=request/destination=] is either "embed" or "object", then: 1. Return null. 1. Else if |registration|'s active worker's [=service worker/list of router rules=] is set: - 1. If running [=GetRouterSource=] algorithm with active worker and |request| returns "network", return null. + 1. If running [=GetRouterSource=] with |registration|'s active worker and |request| returns "network", return null. 1. Else if |request| is a non-subresource request, then: 1. If |reservedClient| is not null and is an environment settings object, then: 1. If |reservedClient| is not a secure context, return null. From 0909c9c35cd55c962cad553b3185d63b87668a09 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 6 Dec 2023 07:25:53 +0000 Subject: [PATCH 16/20] Rename algorithm names to align with other algorithm names. --- docs/index.bs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index f0233398..2e3f3940 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -1578,7 +1578,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Let |routerRules| be a list of {{RouterRule}} dictionaries. 1. If |rules| is a {{RouterRule}} dictionary, set |rules| to « |rules| ». 1. For each |rule| of |rules|: - 1. If running [=VerifyRouterRule=] algorithm with |rule| and [=/service worker=] returns false, throw a TypeError. + 1. If running [=Verify Router Rule=] algorithm with |rule| and [=/service worker=] returns false, throw a TypeError. 1. Append |rule| to |routerRules|. 1. Set [=/service worker=]'s [=service worker/list of router rules=] to |routerRules|. @@ -3108,7 +3108,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. If |request|'s [=request/destination=] is either "embed" or "object", then: 1. Return null. 1. Else if |registration|'s active worker's [=service worker/list of router rules=] is set: - 1. If running [=GetRouterSource=] with |registration|'s active worker and |request| returns "network", return null. + 1. If running [=Get Router Source=] with |registration|'s active worker and |request| returns "network", return null. 1. Else if |request| is a non-subresource request, then: 1. If |reservedClient| is not null and is an environment settings object, then: 1. If |reservedClient| is not a secure context, return null. @@ -3218,7 +3218,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
-

ParseURLPattern

+

Parse URL Pattern

: Input :: |rawPattern|, a [=string=] :: |serviceWorker|, a [=/service worker=] @@ -3230,7 +3230,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
-

VerifyRouterRule

+

Verify Router Rule

: Input :: |rule|, a {{RouterRule}} @@ -3240,7 +3240,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], return false. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. + 1. Let |pattern| be the result of running Parse URL Pattern algorithm passing |rawPattern| and |serviceWorker|. If this throws an exception, catch it and return false. 1. If |pattern| [=URLPattern/has regexp groups=], then return false. Note: Since running a user-defined regular expression has a security concern, it is prohibited. @@ -3249,7 +3249,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
-

GetRouterSource

+

Get Router Source

: Input :: |serviceWorker|, a [=/service worker=] :: |request|, a [=/request=] @@ -3259,7 +3259,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. [=list/For each=] |rule| of |serviceWorker|'s [=service worker/list of router rules=]: 1. If |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"] does not [=map/exist=], continue. 1. Let |rawPattern| be |rule|["{{RouterRule/condition}}"]["{{RouterCondition/urlPattern}}"]. - 1. Let |pattern| be the result of running ParseURLPattern algorithm passing |rawPattern| and |serviceWorker|. + 1. Let |pattern| be the result of running Parse URL Pattern algorithm passing |rawPattern| and |serviceWorker|. 1. If running [=match=] with |pattern| and |request|'s [=request/URL=] returns null, [=continue=]. 1. Return |rule|["{{RouterRule/source}}"]. From 2fd1936291f778aadb95a78e43b777334841cfc6 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 6 Dec 2023 07:46:00 +0000 Subject: [PATCH 17/20] Make which service worker to use clear. --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index 2e3f3940..4c3eb91b 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -1580,7 +1580,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. For each |rule| of |rules|: 1. If running [=Verify Router Rule=] algorithm with |rule| and [=/service worker=] returns false, throw a TypeError. 1. Append |rule| to |routerRules|. - 1. Set [=/service worker=]'s [=service worker/list of router rules=] to |routerRules|. + 1. Set the [=current global object=]'s associated [=ServiceWorkerGlobalScope/service worker=]'s [=service worker/list of router rules=] to |routerRules|.
From bef58577b17fcd712e8b88aa3b4ce940b0392ccc Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 6 Dec 2023 07:50:37 +0000 Subject: [PATCH 18/20] Put algorithm after the algorithm. --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index 4c3eb91b..257e0f0f 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3108,7 +3108,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. If |request|'s [=request/destination=] is either "embed" or "object", then: 1. Return null. 1. Else if |registration|'s active worker's [=service worker/list of router rules=] is set: - 1. If running [=Get Router Source=] with |registration|'s active worker and |request| returns "network", return null. + 1. If running [=Get Router Source=] algorithm with |registration|'s active worker and |request| returns "network", return null. 1. Else if |request| is a non-subresource request, then: 1. If |reservedClient| is not null and is an environment settings object, then: 1. If |reservedClient| is not a secure context, return null. From 1d8cf97e0505783f191f7c1c1db677376c8b38f7 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 6 Dec 2023 09:36:35 +0000 Subject: [PATCH 19/20] Fixed typo. --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index 257e0f0f..4dfe6089 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3226,7 +3226,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ :: {{URLPattern}} 1. Let |baseURL| be |serviceWorker|'s [=service worker/script url=]. - 1. Return the result of [=building a URLPattern from a WebIDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=]. + 1. Return the result of [=building a URLPattern from a Web IDL value=] |rawPattern| given |baseURL| and |serviceWorker|'s [=service worker/global object=]'s [=relevant realm=].
From acdd79da3deb2a8c640fa0b4ae0bcd2dc0175ead Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 6 Dec 2023 09:42:07 +0000 Subject: [PATCH 20/20] Fix "Parse URL Pattern" argument. --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index 4dfe6089..1f749e41 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -3220,7 +3220,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/

Parse URL Pattern

: Input - :: |rawPattern|, a [=string=] + :: |rawPattern|, a {{URLPatternCompatible}} :: |serviceWorker|, a [=/service worker=] : Output :: {{URLPattern}}