diff --git a/docs/index.bs b/docs/index.bs index 37242ce5..2813b1c8 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -1602,6 +1602,10 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ }; + A count router condition result is a [=struct=] that consists of: + * A condition count (a number). + * A quota exceeded (a boolean). +

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

@@ -1629,6 +1633,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. For each |rule| of |rules|: 1. Append |rule| to |allRules|. + 1. If running the [=Check Router Registration Limit=] with |allRules| returns false, reject |promise| with a {{TypeError}}. 1. Set |serviceWorker|'s [=service worker/list of router rules=] to |allRules|. 1. Let |serviceWorkerEventLoop| be the [=current global object=]'s [=event loop=]. 1. [=Queue a task=] to run the following steps on |serviceWorkerEventLoop| using the [=DOM manipulation task source=]: @@ -3473,6 +3478,51 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/ 1. Return true.
+
+

Check Router Registration Limit

+ + : Input + :: |routerRules|, a [=list of router rules=] + : Output + :: a boolean + + 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. + + 1. Let |result| be a [=count router condition result=]. + 1. Set |result|'s [=count router condition result/condition count=] to 1024. + 1. Set |result|'s [=count router condition result/quota exceeded=] to false. + 1. [=list/For each=] |rule| of |routerRules|: + 1. Set |result| to be the result of running [=Count Router Inner Conditions=] with |rule|["{{RouterRule/condition}}"], |result|, and 10. + 1. If |result|'s [=count router condition result/quota exceeded=] is true, return false. + 1. Return true. +
+ +
+

Count Router Inner Conditions

+ + : Input + :: |condition|, a {{RouterCondition}} + :: |result|, a [=count router condition result=] + :: |depth|, a number + : Output + :: |result|, a [=count router condition result=] + + 1. Decrement |result|'s [=count router condition result/condition count=] by one. + 1. If |result|'s [=count router condition result/condition count=] is zero, or |depth| is zero, then: + 1. Set |result|'s [=count router condition result/quota exceeded=] to be true. + 1. Return |result|. + 1. If |condition|["{{RouterCondition/_or}}"] [=map/exists=], then: + 1. Decrement |depth| by one. + 1. For each |orCondition| of |condition|["{{RouterCondition/_or}}"]: + 1. Set |result| to be the result of running [=Count Router Inner Conditions=] with |orCondition|, |result|, and |depth|. + 1. If |result|'s [=count router condition result/quota exceeded=] is true, return |result|. + 1. Else if |condition|["{{RouterCondition/not}}"] [=map/exists=], then: + 1. Decrement |depth| by one. + 1. Set |result| to be the result of running [=Count Router Inner Conditions=] with |condition|["{{RouterCondition/not}}"], |result|, and |depth|. + 1. If |result|'s [=count router condition result/quota exceeded=] is true, return |result|. + 1. Return |result|. +
+

Get Router Source

: Input