Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / access-control-preflight-credential-async.html
blobba707d2d58b8410fc2dd8b0f6cad3965ca11cdc4
1 <html>
2 <head>
3 <script type="text/javascript">
5 function log(message)
7 document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
10 if (window.testRunner) {
11 testRunner.dumpAsText();
12 testRunner.waitUntilDone();
15 function stopTest() {
16 if (window.testRunner)
17 testRunner.notifyDone();
20 function runTest() {
21 try {
22 var xhr = new XMLHttpRequest;
23 xhr.open("PUT", "http://localhost:8000/xmlhttprequest/resources/basic-auth/access-control-auth-basic.php?uid=fooUser", true, "fooUser", "barPass");
24 xhr.withCredentials = true;
25 xhr.onerror = function (e) {
26 log("FAILED: received error");
27 stopTest();
29 xhr.onreadystatechange = function () {
30 if (xhr.readyState == 4) {
31 log((xhr.status == 401) ? "PASSED" : "FAILED: credential send!");
32 stopTest();
35 xhr.send();
36 } catch(e) {
37 log("FAILED: got exception " + e.message);
41 </script>
42 </head>
43 <body onload="runTest();">
44 <p>Test case for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=37781">37781</a>: [XHR] Cross-Origin asynchronous request with credential raises NETWORK_ERR</p>
45 <pre id='console'></pre>
46 </body>
47 </html>