blob: b8deda4349e08039f4ada65825bbf61b3dc20581 [file] [log] [blame]
aahlstrom@google.com6c6fa242017-08-17 06:51:581<!DOCTYPE html>
2<html>
3 <head>
4 <title>Preflight cache should allow second request without preflight OPTIONS request</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
14 async_test(function(test) {
15 const xhr = new XMLHttpRequest;
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ägenstedt2cb86af2018-01-06 16:35:2723 xhr.open("GET", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/reset-token.py?token=" + uuid, true);
aahlstrom@google.com6c6fa242017-08-17 06:51:5824 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ägenstedt2cb86af2018-01-06 16:35:2731 xhr.open("PUT", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/access-control-basic-preflight-cache.py?token=" + uuid, true);
aahlstrom@google.com6c6fa242017-08-17 06:51:5832 xhr.send();
33 }
34
35 function secondRequest() {
36 xhr.onload = test.step_func_done(function() {
37 assert_equals(xhr.responseText, "PASS: Second PUT request. Preflight worked.");
38 });
Philip Jägenstedt2cb86af2018-01-06 16:35:2739 xhr.open("PUT", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/access-control-basic-preflight-cache.py?token=" + uuid, true);
aahlstrom@google.com6c6fa242017-08-17 06:51:5840 xhr.send();
41 }
42 }, "Preflight cache should allow second request");
43 </script>
44 </body>
45</html>