Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / xmlhttprequest / resources / xmlhttprequest-nonexistent-file-real.html
blob86a9b174bb566dce419067c77fa0b8985f659122
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <script>
6 function log(message)
8 var console = document.getElementById('console');
9 console.appendChild(document.createTextNode(message));
10 console.appendChild(document.createElement('br'));
13 function errorHandler()
15 log("Error handler: readyState = " + xhr.readyState);
16 var results = window.top.document.getElementById('results');
17 results.innerHTML = document.body.innerHTML;
20 function readyStateHandlerDirectory()
22 log("ReadyState handler: readyState = " + xhr.readyState);
24 if (xhr.readyState == 4 && window.testRunner) {
25 var results = window.top.document.getElementById('results');
26 results.innerHTML = document.body.innerHTML;
28 setTimeout("testRunner.notifyDone()", 0);
32 function testXHRDirectory()
34 log("");
35 log("Doing an XHR to a directory.");
36 xhr = new XMLHttpRequest();
37 xhr.onerror = errorHandler;
38 xhr.onreadystatechange = readyStateHandlerDirectory;
40 try {
41 xhr.open("GET", "../resources/", false);
42 xhr.send("");
43 } catch(e) {
44 log("Exception: " + e.message);
48 function readyStateHandlerNonExistent()
50 log("ReadyState handler: readyState = " + xhr.readyState);
51 if (xhr.readyState == 4)
52 setTimeout("testXHRDirectory()", 0);
55 function testXHRNonExistentFile()
57 log("Doing an XHR to a nonexistent file.");
58 xhr = new XMLHttpRequest();
59 xhr.onerror = errorHandler;
60 xhr.onreadystatechange = readyStateHandlerNonExistent;
62 try {
63 xhr.open("GET", "nonexistent.html", true);
64 xhr.send("");
65 } catch(e) {
66 log("Exception: " + e.message);
67 testXHRDirectory();
70 </script>
71 </head>
72 <body onload="testXHRNonExistentFile()">
73 <p> Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=22475">22475</a>: REGRESSION: Async XMLHttpRequest never finishes on nonexistent files anymore </p>
74 <p> In both cases, readyState 4 should be reached, and error handler should be invoked. </p>
75 <div id="console"/>
76 </body>
77 </html>