| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <body> | |
| 3 <p>Tests for XMLHttpRequest authentication. | |
| 4 <script> | |
| 5 if (window.testRunner) { | |
| 6 testRunner.dumpAsText(); | |
| 7 testRunner.waitUntilDone(); | |
| 8 } | |
| 9 | |
| 10 var console_messages = document.createElement("ol"); | |
| 11 document.body.appendChild(console_messages); | |
| 12 | |
| 13 function log(message) | |
| 14 { | |
| 15 var item = document.createElement("li"); | |
| 16 item.appendChild(document.createTextNode(message)); | |
| 17 console_messages.appendChild(item); | |
| 18 } | |
| 19 | |
| 20 function sendAndLogResponse(uid, req) | |
| 21 { | |
| 22 try { | |
| 23 req.send(""); | |
| 24 log(uid + ': ' + req.responseText); | |
| 25 } catch (e) { | |
| 26 log(uid + ": req.send raised exception: " + e); | |
| 27 log(uid + ": req.readyState: " + req.readyState); | |
| 28 log(uid + ": req.status: " + req.status); | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 // sync | |
| 33 req = new XMLHttpRequest; | |
| 34 req.open("GET", "resources/basic-auth/basic-auth.php?uid=sync", false, "sync
", "123"); | |
| 35 sendAndLogResponse("sync", req); | |
| 36 | |
| 37 req.open("GET", document.URL.replace("basic-auth.html", "resources/basic-aut
h/basic-auth.php?uid=sync2"), false, "sync2", "123"); | |
| 38 sendAndLogResponse("sync2", req); | |
| 39 | |
| 40 req.open("GET", document.URL.replace("basic-auth.html", "resources/basic-aut
h/basic-auth.php?uid=sync3").replace("http://", "http://sync3:123@"), false); | |
| 41 sendAndLogResponse("sync3", req); | |
| 42 | |
| 43 req.open("GET", document.URL.replace("basic-auth.html", "resources/basic-aut
h/basic-auth.php?uid=sync4").replace("http://", "http://incorrect:incorrect@"),
false, "sync4", "123"); | |
| 44 sendAndLogResponse("sync4", req); | |
| 45 | |
| 46 req.open("GET", document.URL.replace("basic-auth.html", "resources/basic-aut
h/basic-auth.php?uid=sync5").replace("http://", "http://sync5:123@"), false, und
efined, undefined); | |
| 47 sendAndLogResponse("sync5", req); | |
| 48 | |
| 49 req.open("GET", document.URL.replace("basic-auth.html", "resources/basic-aut
h/basic-auth.php?uid=sync6").replace("http://", "http://sync6:123@"), false, und
efined); | |
| 50 sendAndLogResponse("sync6", req); | |
| 51 | |
| 52 req.open("GET", document.URL.replace("basic-auth.html", "resources/basic-aut
h/basic-auth.php?uid=sync7").replace("http://", "http://sync7:123@"), false, und
efined, "incorrect"); | |
| 53 sendAndLogResponse("sync7", req); | |
| 54 | |
| 55 // async | |
| 56 var asyncStep = 1; | |
| 57 | |
| 58 req.onreadystatechange = processStateChange; | |
| 59 req.open("GET", "resources/basic-auth/basic-auth.php?uid=async", true, "asyn
c", "123"); | |
| 60 req.send(""); | |
| 61 | |
| 62 function processStateChange() { | |
| 63 | |
| 64 if (req.readyState == 4){ | |
| 65 if (req.status == 200){ | |
| 66 if (asyncStep == 1) { | |
| 67 asyncStep = 2; | |
| 68 log('async: ' + req.responseText); | |
| 69 req.onreadystatechange = processStateChange; | |
| 70 req.open("GET", document.URL.replace("basic-auth.html", "resources/b
asic-auth/basic-auth.php?uid=async2"), true, "async2", "123"); | |
| 71 req.send(""); | |
| 72 } else if (asyncStep == 2) { | |
| 73 asyncStep = 3; | |
| 74 log('async2: ' + req.responseText); | |
| 75 req.onreadystatechange = processStateChange; | |
| 76 req.open("GET", document.URL.replace("basic-auth.html", "resources/b
asic-auth/basic-auth.php?uid=async3").replace("http://", "http://async3:123@"),
true, "async3", "123"); | |
| 77 req.send(""); | |
| 78 } else if (asyncStep == 3) { | |
| 79 asyncStep = 4; | |
| 80 log('async3: ' + req.responseText); | |
| 81 req.onreadystatechange = processStateChange; | |
| 82 req.open("GET", document.URL.replace("basic-auth.html", "resources/b
asic-auth/basic-auth.php?uid=async4").replace("http://", "http://incorrect:incor
rect@"), true, "async4", "123"); | |
| 83 req.send(""); | |
| 84 } else if (asyncStep == 4) { | |
| 85 asyncStep = 5; | |
| 86 log('async4: ' + req.responseText); | |
| 87 req.onreadystatechange = processStateChange; | |
| 88 req.open("GET", document.URL.replace("basic-auth.html", "resources/b
asic-auth/basic-auth.php?uid=async5").replace("http://", "http://async5:123@"),
true, undefined, undefined); | |
| 89 req.send(""); | |
| 90 } else if (asyncStep == 5) { | |
| 91 asyncStep = 6; | |
| 92 log('async5: ' + req.responseText); | |
| 93 req.onreadystatechange = processStateChange; | |
| 94 req.open("GET", document.URL.replace("basic-auth.html", "resources/b
asic-auth/basic-auth.php?uid=async6").replace("http://", "http://async6:123@"),
true, undefined); | |
| 95 req.send(""); | |
| 96 } else if (asyncStep == 6) { | |
| 97 asyncStep = 7; | |
| 98 log('async6: ' + req.responseText); | |
| 99 req.onreadystatechange = processStateChange; | |
| 100 req.open("GET", document.URL.replace("basic-auth.html", "resources/b
asic-auth/basic-auth.php?uid=async7").replace("http://", "http://async7:123@"),
true, undefined, "incorrect"); | |
| 101 req.send(""); | |
| 102 } else if (asyncStep == 7) { | |
| 103 log('async7: ' + req.responseText); | |
| 104 if (window.testRunner) | |
| 105 testRunner.notifyDone(); | |
| 106 } | |
| 107 } else { | |
| 108 log("async" + asyncStep + " failed with unexpected status: " + req.s
tatus); | |
| 109 } | |
| 110 } | |
| 111 } | |
| 112 </script> | |
| 113 </body> | |
| 114 </html> | |
| OLD | NEW |