| aahlstrom@google.com | 336689d | 2017-08-09 09:05:56 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>Preflight cache should be invalidated by changed method</title> |
| 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| 7 | <script src="/common/get-host-info.sub.js"></script> |
| 8 | <script src="/common/utils.js"></script> |
| 9 | </head> |
| 10 | <body> |
| 11 | <script type="text/javascript"> |
| 12 | const uuid = token(); |
| 13 | const xhr = new XMLHttpRequest; |
| 14 | |
| 15 | async_test(function(test) { |
| 16 | xhr.onerror = test.unreached_func("FAIL: Network error."); |
| 17 | xhr.onload = test.step_func(function() { |
| 18 | // Token reset. We can start the test now. |
| 19 | assert_equals(xhr.responseText, "PASS"); |
| 20 | firstRequest(); |
| 21 | }); |
| 22 | |
| Philip Jägenstedt | 2cb86af | 2018-01-06 16:35:27 | [diff] [blame] | 23 | xhr.open("GET", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/reset-token.py?token=" + uuid, true); |
| aahlstrom@google.com | 336689d | 2017-08-09 09:05:56 | [diff] [blame] | 24 | xhr.send(); |
| 25 | |
| 26 | function firstRequest() { |
| 27 | xhr.onload = test.step_func(function() { |
| 28 | assert_equals(xhr.responseText, "PASS: First PUT request."); |
| 29 | secondRequest(); |
| 30 | }); |
| Philip Jägenstedt | 2cb86af | 2018-01-06 16:35:27 | [diff] [blame] | 31 | xhr.open("PUT", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/access-control-basic-preflight-cache-invalidation.py?token=" + uuid, true); |
| aahlstrom@google.com | 336689d | 2017-08-09 09:05:56 | [diff] [blame] | 32 | xhr.send(); |
| 33 | } |
| 34 | |
| 35 | function secondRequest() { |
| 36 | xhr.onload = test.step_func(function() { |
| 37 | assert_equals(xhr.responseText, "PASS: Second OPTIONS request was sent."); |
| 38 | test.done(); |
| 39 | }); |
| 40 | // Send a header not included in the inital cache. |
| Philip Jägenstedt | 2cb86af | 2018-01-06 16:35:27 | [diff] [blame] | 41 | xhr.open("XMETHOD", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/access-control-basic-preflight-cache-invalidation.py?token=" + uuid, true); |
| aahlstrom@google.com | 336689d | 2017-08-09 09:05:56 | [diff] [blame] | 42 | xhr.send(); |
| 43 | } |
| 44 | }, "Preflight cache should be invalidated by changed method"); |
| 45 | |
| 46 | </script> |
| 47 | </body> |
| 48 | </html> |