summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/tentative/static-router/static-router-invalid-rules.https.html
blob: 15b8ef5742d7d901e46110f9898e8f3374a2e261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<meta charset="utf-8">
<title>
  Static Router: registration of invalid rules should raise.
</title>
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js">
</script>
<script src="resources/static-router-helpers.sub.js">
</script>
<body>
<script>

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 =
    'condition-lack-of-source';

promise_test(async t => {
  const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_REQUEST_METHOD);
  t.add_cleanup(() => {reset_info_in_worker(worker)});
  const {errors} = await get_info_from_worker(worker);
  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)});
  const {errors} = await get_info_from_worker(worker);
  assert_equals(errors.length, 1);
}, 'addRoutes should raise if the conditon does not exist in the rule');

promise_test(async t => {
  const worker = await registerAndActivate(t, ROUTER_RULE_KEY_LACK_OF_SOURCE);
  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 source does not exiswt in the rule');


</script>
</body>