|
61 | 61 | const {requests} = await get_info_from_worker(worker);
|
62 | 62 | assert_equals(requests.length, 2);
|
63 | 63 | }, 'Subresource load matched the rule with race-network-and-fetch-handler source, and the server reseponse is faster than the fetch handler');
|
| 64 | + |
| 65 | +promise_test(async t => { |
| 66 | + const rnd = randomString(); |
| 67 | + const worker = await registerAndActivate(t, ROUTER_KEY, SW_SRC); |
| 68 | + const iframe = await createIframe(t, FRAME_SRC); |
| 69 | + // Expect the response from the network request. |
| 70 | + const response = await iframe.contentWindow.fetch(`?nonce=${rnd}&sw_slow&server_no_content`); |
| 71 | + assert_equals(response.status, 204); |
| 72 | + // Ensure the fetch handler is also executed. |
| 73 | + const {requests} = await get_info_from_worker(worker); |
| 74 | + assert_equals(requests.length, 2); |
| 75 | +}, 'Subresource load matched the rule with race-network-and-fetch-handler source, and the server reseponse with 204 response is faster than the fetch handler'); |
| 76 | + |
| 77 | + |
| 78 | +promise_test(async t => { |
| 79 | + const rnd = randomString(); |
| 80 | + const worker = await registerAndActivate(t, ROUTER_KEY, SW_SRC); |
| 81 | + const iframe = await createIframe(t, FRAME_SRC); |
| 82 | + const response = await iframe.contentWindow.fetch(`?nonce=${rnd}&sw_slow&server_not_found`); |
| 83 | + // Expect the response from the network request was faster, but the result was 404. |
| 84 | + // So, the fetch handler result will be used instead. |
| 85 | + assert_equals(response.status, 200); |
| 86 | + assert_equals(await response.text(), rnd); |
| 87 | + const {requests} = await get_info_from_worker(worker); |
| 88 | + assert_equals(requests.length, 2); |
| 89 | +}, 'Subresource load matched the rule with race-network-and-fetch-handler source, and the server reseponse is faster than the fetch handler, but not found'); |
64 | 90 | </script>
|
65 | 91 | </body>
|
0 commit comments