Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / cache / xhr-vary-header.html
blob5d183d9f19f7515519ec7705ab344db9659f3a23
1 <p>Test that XMLHttpRequest doesn't return a wrong cached answer when there is a Vary header in response.</p>
3 <script src="/js-test-resources/js-test.js"></script>
4 <script>
5 window.jsTestIsAsync = true;
7 if (location.protocol != "http:" || location.host != "127.0.0.1:8000")
8 debug("This test must be run from http://127.0.0.1:8000");
10 var testStep = 1;
12 function testCrossOrigin()
14 var req = new XMLHttpRequest;
15 req.open("get", "http://localhost:8000/cache/resources/xhr-vary-header-response.php");
16 req.onload=function() { receivedResponse(req.responseText) }
17 req.send();
20 function testSameOrigin()
22 frames[0].postMessage("", "http://localhost:8000");
25 function receivedResponse(text)
27 window.responseText = text;
28 switch (testStep) {
29 case 1:
30 shouldBe("responseText", "'Cross origin response'");
31 testStep++;
32 testSameOrigin();
33 break;
34 case 2:
35 shouldBe("responseText", "'Same origin response'");
36 testStep++;
37 testCrossOrigin();
38 break;
39 case 3:
40 shouldBe("responseText", "'Cross origin response'");
41 finishJSTest();
42 testStep++;
43 break;
44 default:
45 debug(responseText);
46 break;
48 delete window.responseText;
51 window.onmessage = function(msg) { receivedResponse(msg.data) }
52 window.onload = testCrossOrigin;
54 </script>
56 <button onclick="testCrossOrigin()">Make cross origin request</button>
57 <br>
58 <iframe src="http://localhost:8000/cache/resources/xhr-vary-header-subframe.html" frameborder=0 height=50></iframe>
59 <pre id=console></pre>