blob: f8a99a25560c410a941a4b09501fac5c4d03a2b2 [file] [log] [blame]
aahlstrom@google.com336689d2017-08-09 09:05:561<!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ä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.com336689d2017-08-09 09:05:5624 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-invalidation.py?token=" + uuid, true);
aahlstrom@google.com336689d2017-08-09 09:05:5632 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ägenstedt2cb86af2018-01-06 16:35:2741 xhr.open("XMETHOD", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/access-control-basic-preflight-cache-invalidation.py?token=" + uuid, true);
aahlstrom@google.com336689d2017-08-09 09:05:5642 xhr.send();
43 }
44 }, "Preflight cache should be invalidated by changed method");
45
46 </script>
47 </body>
48</html>