tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / xmlhttprequest / resources / xmlhttprequest-nonexistent-file-real.html
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)
7         {
8             var console = document.getElementById('console');
9             console.appendChild(document.createTextNode(message));
10             console.appendChild(document.createElement('br'));
11         }
12
13         function errorHandler()
14         {
15             log("Error handler: readyState = " + xhr.readyState);
16             var results = window.top.document.getElementById('results');
17             results.innerHTML = document.body.innerHTML;
18         }
19
20         function readyStateHandlerDirectory()
21         {
22             log("ReadyState handler: readyState = " + xhr.readyState);
23
24             if (xhr.readyState == 4 && window.layoutTestController) {
25                 var results = window.top.document.getElementById('results');
26                 results.innerHTML = document.body.innerHTML;
27
28                 setTimeout("layoutTestController.notifyDone()", 0);
29             }
30         }
31
32         function testXHRDirectory()
33         {
34             log("");
35             log("Doing an XHR to a directory.");
36             xhr = new XMLHttpRequest();
37             xhr.onerror = errorHandler;
38             xhr.onreadystatechange = readyStateHandlerDirectory;
39
40             try {
41                 xhr.open("GET", "../resources/", false);
42                 xhr.send("");
43             } catch(e) {
44                 log("Exception: " + e.message);
45             }
46         }
47
48         function readyStateHandlerNonExistent()
49         {
50             log("ReadyState handler: readyState = " + xhr.readyState);
51             if (xhr.readyState == 4)
52                 setTimeout("testXHRDirectory()", 0);
53         }
54
55         function testXHRNonExistentFile()
56         {
57             log("Doing an XHR to a nonexistent file.");
58             xhr = new XMLHttpRequest();
59             xhr.onerror = errorHandler;
60             xhr.onreadystatechange = readyStateHandlerNonExistent;
61
62             try {
63                 xhr.open("GET", "nonexistent.html", true);
64                 xhr.send("");
65             } catch(e) {
66                 log("Exception: " + e.message);
67                 testXHRDirectory();
68             }
69         }
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>