blob: 84ff0c60d71f70e818fe7bd9b5e555cc38f4296a [file] [log] [blame]
aahlstrom@google.com47a878a2017-08-09 23:15:411<!DOCTYPE html>
2<html>
3 <head>
4 <title>Preflight cache should be invalidated on timeout</title>
Sergio Villar Senin72876082019-03-22 17:18:585 <meta name="timeout" content="long">
aahlstrom@google.com47a878a2017-08-09 23:15:416 <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ägenstedt2cb86af2018-01-06 16:35:2724 xhr.open("GET", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/reset-token.py?token=" + uuid, true);
aahlstrom@google.com47a878a2017-08-09 23:15:4125 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ägenstedt2cb86af2018-01-06 16:35:2732 xhr.open("PUT", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/access-control-basic-preflight-cache-timeout.py?token=" + uuid, true);
aahlstrom@google.com47a878a2017-08-09 23:15:4133 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ägenstedt2cb86af2018-01-06 16:35:2741 xhr.open("PUT", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/access-control-basic-preflight-cache-timeout.py?token=" + uuid, true);
aahlstrom@google.com47a878a2017-08-09 23:15:4142 xhr.send();
43 }
44 }, "Preflight cache should be invalidated on timeout");
45 </script>
46 </body>
47</html>