| OLD | NEW | 
|---|
| 1 <p>Test that XMLHttpRequest doesn't return a wrong cached answer when there is a
     Vary header in response.</p> | 1 <p>Test that XMLHttpRequest doesn't return a wrong cached answer when there is a
     Vary header in response.</p> | 
| 2 | 2 | 
| 3 <script src="/js-test-resources/js-test.js"></script> | 3 <script src="/js-test-resources/js-test.js"></script> | 
| 4 <script> | 4 <script> | 
| 5 window.jsTestIsAsync = true; | 5 window.jsTestIsAsync = true; | 
| 6 | 6 | 
| 7 if (location.protocol != "http:" || location.host != "127.0.0.1:8000") | 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"); | 8     debug("This test must be run from http://127.0.0.1:8000"); | 
| 9 | 9 | 
| 10 var testStep = 1; | 10 var testStep = 1; | 
| 11 | 11 | 
| 12 function testCrossOrigin() | 12 function testCrossOrigin() | 
| 13 { | 13 { | 
| 14     var req = new XMLHttpRequest; | 14     var req = new XMLHttpRequest; | 
| 15     req.open("get", "http://localhost:8000/cache/resources/xhr-vary-header-respo
    nse.php"); | 15     req.open("GET", "http://localhost:8080/cache/resources/xhr-vary-header-respo
    nse.php"); | 
| 16     req.onload=function() { receivedResponse(req.responseText) } | 16     req.onload=function() { receivedResponse(req.responseText) } | 
| 17     req.send(); | 17     req.send(); | 
| 18 } | 18 } | 
| 19 | 19 | 
| 20 function testSameOrigin() | 20 function testSameOrigin() | 
| 21 { | 21 { | 
| 22     frames[0].postMessage("", "http://localhost:8000"); | 22     frames[0].postMessage("", "http://localhost:8000"); | 
| 23 } | 23 } | 
| 24 | 24 | 
| 25 function receivedResponse(text) | 25 function receivedResponse(text) | 
| 26 { | 26 { | 
| 27     window.responseText = text; | 27     window.responseText = text; | 
| 28     switch (testStep) { | 28     switch (testStep) { | 
| 29         case 1: | 29         case 1: | 
| 30             shouldBe("responseText", "'Cross origin response'"); | 30             shouldBe("responseText", "'Origin header value is http://127.0.0.1:8
    000'"); | 
| 31             testStep++; | 31             testStep++; | 
| 32             testSameOrigin(); | 32             testSameOrigin(); | 
| 33             break; | 33             break; | 
| 34         case 2: | 34         case 2: | 
| 35             shouldBe("responseText", "'Same origin response'"); | 35             shouldBe("responseText", "'Origin header value is http://localhost:8
    000'"); | 
| 36             testStep++; | 36             testStep++; | 
| 37             testCrossOrigin(); | 37             testCrossOrigin(); | 
| 38             break; | 38             break; | 
| 39         case 3: | 39         case 3: | 
| 40             shouldBe("responseText", "'Cross origin response'"); | 40             shouldBe("responseText", "'Origin header value is http://127.0.0.1:8
    000'"); | 
| 41             finishJSTest(); | 41             finishJSTest(); | 
| 42             testStep++; | 42             testStep++; | 
| 43             break; | 43             break; | 
| 44         default: | 44         default: | 
| 45             debug(responseText); | 45             debug(responseText); | 
| 46             break; | 46             break; | 
| 47     } | 47     } | 
| 48     delete window.responseText; | 48     delete window.responseText; | 
| 49 } | 49 } | 
| 50 | 50 | 
| 51 window.onmessage = function(msg) { receivedResponse(msg.data) } | 51 window.onmessage = function(msg) { receivedResponse(msg.data) } | 
| 52 window.onload = testCrossOrigin; | 52 window.onload = testCrossOrigin; | 
| 53 | 53 | 
| 54 </script> | 54 </script> | 
| 55 | 55 | 
| 56 <button onclick="testCrossOrigin()">Make cross origin request</button> | 56 <button onclick="testCrossOrigin()">Make cross origin request</button> | 
| 57 <br> | 57 <br> | 
| 58 <iframe src="http://localhost:8000/cache/resources/xhr-vary-header-subframe.html
    " frameborder=0 height=50></iframe> | 58 <iframe src="http://localhost:8000/cache/resources/xhr-vary-header-subframe.html
    " frameborder=0 height=50></iframe> | 
| 59 <pre id=console></pre> | 59 <pre id=console></pre> | 
| OLD | NEW | 
|---|