| <p>Test that XMLHttpRequest doesn't return a wrong cached answer when there is a Vary header in response.</p> |
| |
| <script src="/js-test-resources/js-test-pre.js"></script> |
| <script> |
| window.jsTestIsAsync = true; |
| |
| if (location.protocol != "http:" || location.host != "127.0.0.1:8000") |
| debug("This test must be run from http://127.0.0.1:8000"); |
| |
| var testStep = 1; |
| |
| function testCrossOrigin() |
| { |
| var req = new XMLHttpRequest; |
| req.open("get", "http://localhost:8000/cache/resources/xhr-vary-header-response.py"); |
| req.onload=function() { receivedResponse(req.responseText) } |
| req.send(); |
| } |
| |
| function testSameOrigin() |
| { |
| frames[0].postMessage("", "http://localhost:8000"); |
| } |
| |
| function receivedResponse(text) |
| { |
| window.responseText = text; |
| switch (testStep) { |
| case 1: |
| shouldBe("responseText", "'Cross origin response'"); |
| testStep++; |
| testSameOrigin(); |
| break; |
| case 2: |
| shouldBe("responseText", "'Same origin response'"); |
| testStep++; |
| testCrossOrigin(); |
| break; |
| case 3: |
| shouldBe("responseText", "'Cross origin response'"); |
| finishJSTest(); |
| testStep++; |
| break; |
| default: |
| debug(responseText); |
| break; |
| } |
| delete window.responseText; |
| } |
| |
| window.onmessage = function(msg) { receivedResponse(msg.data) } |
| window.onload = testCrossOrigin; |
| |
| </script> |
| |
| <button onclick="testCrossOrigin()">Make cross origin request</button> |
| <br> |
| <iframe src="http://localhost:8000/cache/resources/xhr-vary-header-subframe.html" frameborder=0 height=50></iframe> |
| <pre id=console></pre> |
| <script src="/js-test-resources/js-test-post.js"></script> |