Skip to content

Commit

Permalink
Add WPT for the length of router rules (web-platform-tests#44998)
Browse files Browse the repository at this point in the history
This CL will add test to ensure the router registration will fail if
the length of router rules exceeds the limit, which is currently 256.

Bug: 1519727, 40943429
Change-Id: Id849ddcd08dc5f246436471db60b9dcc71d2324a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5348571
Reviewed-by: Yoshisato Yanagisawa <[email protected]>
Reviewed-by: Kouhei Ueno <[email protected]>
Reviewed-by: Minoru Chikamune <[email protected]>
Commit-Queue: Shunya Shishido <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1269937}

Co-authored-by: Shunya Shishido <[email protected]>
  • Loading branch information
chromium-wpt-export-bot and sisidovski authored Mar 11, 2024
1 parent cefe814 commit 1efa678
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const routerRules = {
};
return {condition: addOrCondition({}, 0), source: 'network'};
})(),
'condition-invalid-router-size': [...Array(512)].map((val, i) => {
return {
condition: {urlPattern: `/foo-${i}`},
source: 'network'
};
}),
'condition-request-destination-script-network':
[{condition: {requestDestination: 'script'}, source: 'network'}],
'condition-or-source-network': [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
'condition-invalid-request-method';
const ROUTER_RULE_KEY_INVALID_OR_CONDITION_DEPTH =
'condition-invalid-or-condition-depth';
const ROUTER_RULE_KEY_INVALID_ROUTER_SIZE =
'condition-invalid-router-size';

promise_test(async t => {
const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_REQUEST_METHOD);
Expand All @@ -32,5 +34,12 @@
assert_equals(errors.length, 1);
}, 'addRoutes should raise if or condition exceeds the depth limit');

promise_test(async t => {
const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_ROUTER_SIZE);
t.add_cleanup(() => {reset_info_in_worker(worker)});
const {errors} = await get_info_from_worker(worker);
assert_equals(errors.length, 1);
}, 'addRoutes should raise if the number of router rules exceeds the length limit');

</script>
</body>

0 comments on commit 1efa678

Please sign in to comment.