summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/tentative/static-router/resources/router-rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/tentative/static-router/resources/router-rules.js')
-rw-r--r--testing/web-platform/tests/service-workers/service-worker/tentative/static-router/resources/router-rules.js36
1 files changed, 29 insertions, 7 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/tentative/static-router/resources/router-rules.js b/testing/web-platform/tests/service-workers/service-worker/tentative/static-router/resources/router-rules.js
index 014cd2ec95..fdc1c9e063 100644
--- a/testing/web-platform/tests/service-workers/service-worker/tentative/static-router/resources/router-rules.js
+++ b/testing/web-platform/tests/service-workers/service-worker/tentative/static-router/resources/router-rules.js
@@ -1,10 +1,17 @@
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': [{
condition: {urlPattern: new URLPattern({pathname: '/**/direct.txt'})},
source: 'network'
}],
+ 'condition-urlpattern-not-source-network': [{
+ condition: {not: {urlPattern: new URLPattern({pathname: '/**/not.txt'})}},
+ source: 'network'
+ }],
'condition-urlpattern-constructed-match-all-source-cache': [
{condition: {urlPattern: new URLPattern({})}, source: 'cache'},
],
@@ -43,22 +50,37 @@ const routerRules = {
[{condition: {requestMethod: 'PUT'}, source: 'network'}],
'condition-request-method-delete-network':
[{condition: {requestMethod: 'DELETE'}, source: 'network'}],
+ 'condition-lack-of-condition': [{
+ source: 'network'
+ }],
+ 'condition-lack-of-source': [{
+ condition: {requestMode: 'no-cors'},
+ }],
'condition-invalid-request-method': [{
condition: {requestMethod: String.fromCodePoint(0x3042)},
source: 'network'
}],
'condition-invalid-or-condition-depth': (() => {
- const max = 10;
- const addOrCondition = (obj, depth) => {
- if (depth > max) {
- return obj;
+ const addOrCondition = (depth) => {
+ if (depth > CONDITION_MAX_RECURSION_DEPTH) {
+ return {urlPattern: '/foo'};
}
return {
- urlPattern: `/foo-${depth}`,
- or: [addOrCondition(obj, depth + 1)]
+ or: [addOrCondition(depth + 1)]
};
};
- return {condition: addOrCondition({}, 0), source: 'network'};
+ 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 {