Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / sync-repeated-and-caching.html
blobbe4886edd1bd4dda9d20347b46690b7ee3a5d3c7
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Synchronous XMLHttpRequest and caching during document load</title>
5 </head>
6 <body>
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" ];
16 var query_kinds = [
17 {query: "'?random'",
18 name: "constant query"},
19 {query: "",
20 name: "no 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);
29 xhr.send();
30 return xhr.responseText;
33 function runTest() {
34 for (var i = 0; i < verbs.length; i++) {
35 var verb = verbs[i];
36 for (var j = 0; j < query_kinds.length; j++) {
37 test(function () {
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);
49 </script>
50 </body>
51 </html>