| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script type="text/javascript"> | 3 <script type="text/javascript"> |
| 4 | 4 |
| 5 function log(message) | 5 function log(message) |
| 6 { | 6 { |
| 7 document.getElementById('console').appendChild(document.createTextNode(messa
ge + "\n")); | 7 document.getElementById('console').appendChild(document.createTextNode(messa
ge + "\n")); |
| 8 } | 8 } |
| 9 | 9 |
| 10 if (window.testRunner) { | 10 if (window.testRunner) { |
| 11 testRunner.dumpAsText(); | 11 testRunner.dumpAsText(); |
| 12 testRunner.waitUntilDone(); | 12 testRunner.waitUntilDone(); |
| 13 testRunner.setAlwaysAcceptCookies(true); | |
| 14 } | |
| 15 | |
| 16 var cookieSet = false; | |
| 17 | |
| 18 window.onmessage = function(evt) | |
| 19 { | |
| 20 if (evt.data != "done") { | |
| 21 alert("Unexpected message: " + evt.data); | |
| 22 return; | |
| 23 } | |
| 24 | |
| 25 if (!cookieSet) { | |
| 26 cookieSet = true; | |
| 27 runTest(); | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 function startTest() { | |
| 32 // Set a cookie for localhost:8000. | |
| 33 window.frames[0].postMessage("sendXHR setFooCookie", "*"); | |
| 34 } | 13 } |
| 35 | 14 |
| 36 function stopTest() { | 15 function stopTest() { |
| 37 // Clean up all cookies for localhost:8000. | |
| 38 window.frames[0].postMessage("resetCookiesAndNotifyDone", "*"); | |
| 39 if (window.testRunner) | 16 if (window.testRunner) |
| 40 testRunner.notifyDone(); | 17 testRunner.notifyDone(); |
| 41 } | 18 } |
| 42 | 19 |
| 43 function runTest() { | 20 function runTest() { |
| 44 try { | 21 try { |
| 45 var xhr = new XMLHttpRequest; | 22 var xhr = new XMLHttpRequest; |
| 46 xhr.open("PUT", "http://localhost:8000/xmlhttprequest/resources/basic-au
th/access-control-auth-basic.php?uid=fooUser", false, "fooUser", "barPass"); | 23 xhr.open("PUT", "http://localhost:8000/xmlhttprequest/resources/basic-au
th/access-control-auth-basic.php?uid=fooUser", false, "fooUser", "barPass"); |
| 47 xhr.withCredentials = true; | 24 xhr.withCredentials = true; |
| 48 xhr.onerror = function (e) { | 25 xhr.onerror = function (e) { |
| 49 log("FAILED: received error"); | 26 log("FAILED: received error"); |
| 50 stopTest(); | 27 stopTest(); |
| 51 }; | 28 }; |
| 52 xhr.onreadystatechange = function () { | 29 xhr.onreadystatechange = function () { |
| 53 if (xhr.readyState == 4) { | 30 if (xhr.readyState == 4) { |
| 54 log((xhr.status == 401) ? "PASSED" : "FAILED: credential send!")
; | 31 log((xhr.status == 401) ? "PASSED" : "FAILED: credential send!")
; |
| 55 stopTest(); | 32 stopTest(); |
| 56 } | 33 } |
| 57 }; | 34 }; |
| 58 xhr.send(); | 35 xhr.send(); |
| 59 } catch(e) { | 36 } catch(e) { |
| 60 log("FAILED: got exception " + e.message); | 37 log("FAILED: got exception " + e.message); |
| 61 } | 38 } |
| 62 } | 39 } |
| 63 | 40 |
| 64 </script> | 41 </script> |
| 65 </head> | 42 </head> |
| 66 <body onload="startTest();"> | 43 <body onload="runTest();"> |
| 67 <p>Test case for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=37781">377
81</a>: [XHR] Cross-Origin synchronous request with credential raises NETWORK_ER
R</p> | 44 <p>Test case for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=37781">377
81</a>: [XHR] Cross-Origin synchronous request with credential raises NETWORK_ER
R</p> |
| 68 <pre id='console'></pre> | 45 <pre id='console'></pre> |
| 69 | |
| 70 <iframe id='testFrame' src="http://localhost:8000/cookies/resources/third-party-
cookie-relaxing-iframe.html"></iframe> | |
| 71 | |
| 72 </body> | 46 </body> |
| 73 </html> | 47 </html> |
| OLD | NEW |