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