Skip to content

Commit

Permalink
Move Chromium implementation specific WPT.
Browse files Browse the repository at this point in the history
The specification does not define the maximum depth/width.
However, the current WPT limit them.  Let me move such WPTs to Chromium
specific locations.

In the coming CL, I will also write the WPT to ask the minimum
depth/width as a response to:
w3c/ServiceWorker#1714

Change-Id: I722667fbdc69aed32d8fa66d3e17050bf33c480a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5999015
Reviewed-by: Keita Suzuki <[email protected]>
Reviewed-by: Shunya Shishido <[email protected]>
Commit-Queue: Yoshisato Yanagisawa <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1380071}
  • Loading branch information
yoshisatoyanagisawa authored and chromium-wpt-export-bot committed Nov 8, 2024
1 parent 8703803 commit af91552
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 58 deletions.
31 changes: 0 additions & 31 deletions service-workers/service-worker/resources/router-rules.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const TEST_CACHE_NAME = 'v1';
// The value is coming from:
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/common/service_worker/service_worker_router_rule.h;l=28;drc=6f3f85b321146cfc0f9eb81a74c7c2257821461e
const CONDITION_MAX_RECURSION_DEPTH = 10;

const routerRules = {
'condition-urlpattern-constructed-source-network': [{
Expand Down Expand Up @@ -60,34 +57,6 @@ const routerRules = {
condition: {requestMethod: String.fromCodePoint(0x3042)},
source: 'network'
}],
'condition-invalid-or-condition-depth': (() => {
const addOrCondition = (depth) => {
if (depth > CONDITION_MAX_RECURSION_DEPTH) {
return {urlPattern: '/foo'};
}
return {
or: [addOrCondition(depth + 1)]
};
};
return {condition: addOrCondition(1), source: 'network'};
})(),
'condition-invalid-not-condition-depth': (() => {
const generateNotCondition = (depth) => {
if (depth > CONDITION_MAX_RECURSION_DEPTH) {
return {
urlPattern: '/**/example.txt',
};
}
return {not: generateNotCondition(depth + 1)};
};
return {condition: generateNotCondition(1), 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 @@ -15,12 +15,6 @@

const ROUTER_RULE_KEY_INVALID_REQUEST_METHOD =
'condition-invalid-request-method';
const ROUTER_RULE_KEY_INVALID_OR_CONDITION_DEPTH =
'condition-invalid-or-condition-depth';
const ROUTER_RULE_KEY_INVALID_NOT_CONDITION_DEPTH =
'condition-invalid-not-condition-depth';
const ROUTER_RULE_KEY_INVALID_ROUTER_SIZE =
'condition-invalid-router-size';
const ROUTER_RULE_KEY_LACK_OF_CONDITION =
'condition-lack-of-condition';
const ROUTER_RULE_KEY_LACK_OF_SOURCE =
Expand All @@ -33,27 +27,6 @@
assert_equals(errors.length, 1);
}, 'addRoutes should raise for invalid request method.');

promise_test(async t => {
const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_OR_CONDITION_DEPTH);
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 or condition exceeds the depth limit');

promise_test(async t => {
const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_NOT_CONDITION_DEPTH);
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 not 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');

promise_test(async t => {
const worker = await registerAndActivate(t, ROUTER_RULE_KEY_LACK_OF_CONDITION);
t.add_cleanup(() => {reset_info_in_worker(worker)});
Expand Down

0 comments on commit af91552

Please sign in to comment.