OLD | NEW |
1 <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=13075">bug 13075</a>
: | 1 <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=13075">bug 13075</a>
: |
2 XMLHttpRequest with failed authentication should set status to 401.</p> | 2 XMLHttpRequest with failed authentication should set status to 401.</p> |
3 <ol> | 3 <ol> |
4 <li>Sync, no credentials: | 4 <li>Sync, no credentials: |
5 <li>Sync, incorrect credentials: | 5 <li>Sync, incorrect credentials: |
6 <li>Async, no credentials: | 6 <li>Async, no credentials: |
7 <li>Async, incorrect credentials: | 7 <li>Async, incorrect credentials: |
8 </ol> | 8 </ol> |
9 <script> | 9 <script> |
10 function checkResult(n, code) { | 10 function checkResult(n, code) { |
11 document.getElementsByTagName("li")[n - 1].firstChild.nodeValue += | 11 document.getElementsByTagName("li")[n - 1].firstChild.nodeValue += |
12 ((code == 401) ? " OK" : (" " + code + " != 401")); | 12 ((code == 401) ? " OK" : (" " + code + " != 401")); |
13 } | 13 } |
14 | 14 |
15 function checkFailure(n, code) { | |
16 document.getElementsByTagName("li")[n - 1].firstChild.nodeValue += | |
17 ((code == 0) ? " OK" : (" " + code + " != 0")); | |
18 } | |
19 | |
20 function log(n, message) { | 15 function log(n, message) { |
21 document.getElementsByTagName("li")[n - 1].firstChild.nodeValue += | 16 document.getElementsByTagName("li")[n - 1].firstChild.nodeValue += |
22 " " + message; | 17 " " + message; |
23 } | 18 } |
24 | 19 |
25 | 20 |
26 if (window.testRunner) { | 21 if (window.testRunner) { |
27 testRunner.dumpAsText(); | 22 testRunner.dumpAsText(); |
28 testRunner.waitUntilDone(); | 23 testRunner.waitUntilDone(); |
29 } else { | 24 } else { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 log(3, ex); | 57 log(3, ex); |
63 test4(); | 58 test4(); |
64 } | 59 } |
65 | 60 |
66 function test4() { | 61 function test4() { |
67 try { | 62 try { |
68 var r = new XMLHttpRequest(); | 63 var r = new XMLHttpRequest(); |
69 r.open("GET", "resources/basic-auth/basic-auth.php?uid=login4", true, "b
adname", "passpw"); | 64 r.open("GET", "resources/basic-auth/basic-auth.php?uid=login4", true, "b
adname", "passpw"); |
70 r.onreadystatechange = function() { | 65 r.onreadystatechange = function() { |
71 if (r.readyState == 4) { | 66 if (r.readyState == 4) { |
72 checkFailure(4, r.status); | 67 checkResult(4, r.status); |
73 testRunner.notifyDone(); | 68 testRunner.notifyDone(); |
74 } | 69 } |
75 }; | 70 }; |
76 r.send(); | 71 r.send(); |
77 } catch (ex) { | 72 } catch (ex) { |
78 log(4, ex); | 73 log(4, ex); |
79 testRunner.notifyDone(); | 74 testRunner.notifyDone(); |
80 } | 75 } |
81 } | 76 } |
82 </script> | 77 </script> |
OLD | NEW |