| <!DOCTYPE html> |
| <title>Check that non-successful responses result in discarding the prerender</title> |
| <meta name="timeout" content="long"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/common/utils.js"></script> |
| <script src="/common/dispatcher/dispatcher.js"></script> |
| <script src="resources/utils.js"></script> |
| <body> |
| <script> |
| |
| setup(() => assertSpeculationRulesIsSupported()); |
| function test_prerender_response_code(code, expectation) { |
| promise_test(async t => { |
| const {exec, tryToActivate} = await create_prerendered_page(t, {code}); |
| const result = await tryToActivate(); |
| assert_equals(result, expectation); |
| },`Responses with code ${code} should be ${expectation}`); |
| } |
| |
| const expectations = { |
| activated: [200, 201, 202, 203], |
| discarded: [204, 205, 402, 404, 500, 503] |
| }; |
| |
| for (const expect in expectations) { |
| for (const code of expectations[expect]) |
| test_prerender_response_code(code, expect); |
| } |
| </script> |
| </body> |