4 <title>Synchronous XMLHttpRequest and caching during document load
</title>
7 <script src=
"../resources/testharness.js"></script>
8 <script src=
"../resources/testharnessreport.js"></script>
9 <script type=
"text/javascript">
11 // Test what caching XMLHttpRequest performs when issuing sync
12 // requests over various verbs and with various kinds of query
13 // portions. Without any cache control headers.
14 var verbs
= [ "GET", "POST" ];
18 name
: "constant query"},
21 {query
: "'?' + (Math.random() + Date.now()).toString()",
22 name
: "unique query string"}];
24 var base_url
= "resources/echo-random.php";
26 function fetchSyncTextResponse(verb
, url
) {
27 var xhr
= new XMLHttpRequest();
28 xhr
.open(verb
, url
, false);
30 return xhr
.responseText
;
34 for (var i
= 0; i
< verbs
.length
; i
++) {
36 for (var j
= 0; j
< query_kinds
.length
; j
++) {
38 var q1
= eval(query_kinds
[j
].query
) || "";
39 var q2
= eval(query_kinds
[j
].query
) || "";
40 var result1
= fetchSyncTextResponse(verb
, base_url
+ q1
);
41 var result2
= fetchSyncTextResponse(verb
, base_url
+ q2
);
42 assert_false(result1
=== result2
);
43 }, "Test repeated sync requests using verb '" + verb
+ "' with " + query_kinds
[j
].name
);
48 test(runTest
, document
.title
);