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>
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");
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
) }
20 function testSameOrigin()
22 frames
[0].postMessage("", "http://localhost:8000");
25 function receivedResponse(text
)
27 window
.responseText
= text
;
30 shouldBe("responseText", "'Cross origin response'");
35 shouldBe("responseText", "'Same origin response'");
40 shouldBe("responseText", "'Cross origin response'");
48 delete window
.responseText
;
51 window
.onmessage = function(msg
) { receivedResponse(msg
.data
) }
52 window
.onload
= testCrossOrigin
;
56 <button onclick=
"testCrossOrigin()">Make cross origin request
</button>
58 <iframe src=
"http://localhost:8000/cache/resources/xhr-vary-header-subframe.html" frameborder=
0 height=
50></iframe>
59 <pre id=console
></pre>