static-router-fetch-event.https.html (1494B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title> 4 Static Router: routers are evaluated with the fetch-event source. 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 const ROUTER_KEY = 'condition-urlpattern-string-source-fetch-event'; 16 const REGISTERED_ROUTE = 'resources/simple.html'; 17 18 promise_test(async t => { 19 const worker = await registerAndActivate(t, ROUTER_KEY); 20 const rnd = randomString(); 21 const iframe = await createIframe(t, `${REGISTERED_ROUTE}?nonce=${rnd}`); 22 const {errors, requests} = await get_info_from_worker(worker); 23 24 assert_equals(errors.length, 0); 25 assert_equals(requests.length, 1); 26 assert_equals(iframe.contentWindow.document.body.innerText, rnd); 27 }, 'Main resource matched the rule with fetch-event source'); 28 29 iframeTest(REGISTERED_ROUTE, ROUTER_KEY, async (t, iwin, worker) => { 30 const rnd = randomString(); 31 const response = await iwin.fetch(`?nonce=${rnd}`); 32 assert_equals(response.status, 200); 33 assert_equals(await response.text(), rnd); 34 const {requests} = await get_info_from_worker(worker); 35 // Main resource request + subreosurce request = 2. 36 assert_equals(requests.length, 2); 37 }, 'Subresource load matched the rule fetch-event source'); 38 </script> 39 </body>