You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A [=/service worker=] has an associated <dfn>list of router rules</dfn> (a [=list=] of {{RouterRule}}s). It is initially an empty [=list=].
214
214
215
-
A [=/service worker=] has an associated <dfn>router rule count</dfn> (the number of registered {{RouterRule}}s). It is initially set to zero.
216
-
217
-
Note: [=router rule count=] is defined as the limit of the total number of registered router rules. This prevents the user agent from spending much resources by evaluating too many router rules. The limit is 1024.
218
-
219
215
A [=/service worker=] is said to be <dfn>running</dfn> if its [=event loop=] is running.
Note: {{RouterCondition/_or}} and {{RouterCondition/not}} might have the other {{RouterCondition/_or}} or {{RouterCondition/not}} inside. To avoid spending much resources by the nested condition or performance penalty on evaluation, depth of such nested conditions can be limited.
1603
+
A <dfn export id="dfn-count-router-condition-result">count router condition result</dfn> is a [=struct=] that consists of:
1604
+
* A <dfn export id="dfn-count-router-condition-result-total-count" for="count router condition result">total count</dfn> (a number).
1605
+
* A <dfn export id="dfn-dfn-count-router-condition-result-depth" for="count router condition result">depth</dfn> (a number).
1. If running the [=Verify Router Condition=] algorithm with |rule|["{{RouterRule/condition}}"] and |serviceWorker| returns false, return [=a promise rejected with=] a {{TypeError}}.
1621
1619
1. Append |rule| to |routerRules|.
1622
1620
1. If |routerRules| [=list/contains=] a {{RouterRule}} whose {{RouterRule/source}} is either of "{{RouterSourceEnum/fetch-event}}" or "{{RouterSourceEnum/race-network-and-fetch-handler}}", and |serviceWorker|'s [=set of event types to handle=] does not [=set/contain=]{{ServiceWorkerGlobalScope/fetch!!event}}, return [=a promise rejected with=] a {{TypeError}}.
1621
+
1. If running the [=Check Router Registration Limit=] with |serviceWorker| returns false, return [=a promise rejected with=] a {{TypeError}}.
1623
1622
1. Set |serviceWorker|'s [=service worker/list of router rules=] to |routerRules|.
Note: Router conditions can be complex and nested using {{RouterCondition/_or}} and {{RouterCondition/not}}. To prevent excessive processing, this algorithm introduces two limits. First, the total number of conditions, counting all nested conditions, cannot exceed 1024. Second, the nesting depth is limited to 10 levels to avoid exponential computation.
3473
+
3474
+
1. Let |result| be a [=count router condition result=].
3475
+
1. Set |result|'s [=count router condition result/total count=] to 0.
3476
+
1. Set |result|'s [=count router condition result/depth=] to 1.
3477
+
1. Let |maxCount| be 1024.
3478
+
1. Let |maxDepth| be 10.
3479
+
1. [=list/For each=] |rule| of |serviceWorker|'s [=service worker/list of router rules=]:
3480
+
1. Let |currentResult| be the result of running [=Count Router Inner Conditions=] with |rule|["{{RouterRule/condition}}"], |result|, |maxCount|, and |maxDepth|.
1. Else if |condition|["{{RouterCondition/not}}"][=map/exists=], then:
3508
+
1. Increment |result|'s [=count router condition result/depth=] by one.
3509
+
1. Set |result| to be the result of running [=Count Router Inner Conditions=] with |condition|["{{RouterCondition/not}}"], |result|, |maxCount|, and |maxDepth|.
0 commit comments