static-router-invalid-rules.https.html (3915B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title> 4 Static Router: registration of invalid rules should raise. 5 </title> 6 <script src="/common/get-host-info.sub.js"></script> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/service-workers/service-worker/resources/test-helpers.sub.js"> 10 </script> 11 <script src="resources/static-router-helpers.sub.js"> 12 </script> 13 <body> 14 <script> 15 16 const ROUTER_RULE_KEY_INVALID_BYTESTRING_REQUEST_METHOD = 17 'condition-invalid-bytestring-request-method'; 18 const ROUTER_RULE_KEY_INVALID_HTTP_REQUEST_METHOD = 19 'condition-invalid-http-request-method'; 20 const ROUTER_RULE_KEY_FORBIDDEN_REQUEST_METHOD = 21 'condition-invalid-forbidden-method'; 22 const ROUTER_RULE_KEY_INVALID_REQUEST_METHOD = 23 'condition-invalid-request-method'; 24 const ROUTER_RULE_KEY_INVALID_OR_CONDITION_DEPTH = 25 'condition-invalid-or-condition-depth'; 26 const ROUTER_RULE_KEY_INVALID_NOT_CONDITION_DEPTH = 27 'condition-invalid-not-condition-depth'; 28 const ROUTER_RULE_KEY_INVALID_ROUTER_SIZE = 29 'condition-invalid-router-size'; 30 const ROUTER_RULE_KEY_LACK_OF_CONDITION = 31 'condition-lack-of-condition'; 32 const ROUTER_RULE_KEY_LACK_OF_SOURCE = 33 'condition-lack-of-source'; 34 35 promise_test(async t => { 36 const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_BYTESTRING_REQUEST_METHOD); 37 t.add_cleanup(() => {reset_info_in_worker(worker)}); 38 const {errors} = await get_info_from_worker(worker); 39 assert_equals(errors.length, 1); 40 }, 'addRoutes should raise for invalid ByteString request method.'); 41 42 promise_test(async t => { 43 const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_HTTP_REQUEST_METHOD); 44 t.add_cleanup(() => {reset_info_in_worker(worker)}); 45 const {errors} = await get_info_from_worker(worker); 46 assert_equals(errors.length, 1); 47 }, 'addRoutes should raise for invalid HTTP request method.'); 48 49 promise_test(async t => { 50 const worker = await registerAndActivate(t, ROUTER_RULE_KEY_FORBIDDEN_REQUEST_METHOD); 51 t.add_cleanup(() => {reset_info_in_worker(worker)}); 52 const {errors} = await get_info_from_worker(worker); 53 assert_equals(errors.length, 1); 54 }, 'addRoutes should raise for forbidden request method.'); 55 56 promise_test(async t => { 57 const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_OR_CONDITION_DEPTH); 58 t.add_cleanup(() => {reset_info_in_worker(worker)}); 59 const {errors} = await get_info_from_worker(worker); 60 assert_equals(errors.length, 1); 61 }, 'addRoutes should raise if or condition exceeds the depth limit'); 62 63 promise_test(async t => { 64 const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_NOT_CONDITION_DEPTH); 65 t.add_cleanup(() => {reset_info_in_worker(worker)}); 66 const {errors} = await get_info_from_worker(worker); 67 assert_equals(errors.length, 1); 68 }, 'addRoutes should raise if not condition exceeds the depth limit'); 69 70 promise_test(async t => { 71 const worker = await registerAndActivate(t, ROUTER_RULE_KEY_INVALID_ROUTER_SIZE); 72 t.add_cleanup(() => {reset_info_in_worker(worker)}); 73 const {errors} = await get_info_from_worker(worker); 74 assert_equals(errors.length, 1); 75 }, 'addRoutes should raise if the number of router rules exceeds the length limit'); 76 77 promise_test(async t => { 78 const worker = await registerAndActivate(t, ROUTER_RULE_KEY_LACK_OF_CONDITION); 79 t.add_cleanup(() => {reset_info_in_worker(worker)}); 80 const {errors} = await get_info_from_worker(worker); 81 assert_equals(errors.length, 1); 82 }, 'addRoutes should raise if the conditon does not exist in the rule'); 83 84 promise_test(async t => { 85 const worker = await registerAndActivate(t, ROUTER_RULE_KEY_LACK_OF_SOURCE); 86 t.add_cleanup(() => {reset_info_in_worker(worker)}); 87 const {errors} = await get_info_from_worker(worker); 88 assert_equals(errors.length, 1); 89 }, 'addRoutes should raise if the source does not exiswt in the rule'); 90 91 92 </script> 93 </body>