blob: 9a163f334c69094b0cd5e506261f649ccaee1642 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script>
function log(message)
{
var console = document.getElementById('console');
console.appendChild(document.createTextNode(message));
console.appendChild(document.createElement('br'));
}
function errorHandler()
{
log("Error handler: readyState = " + xhr.readyState);
var results = window.top.document.getElementById('results');
results.innerHTML = document.body.innerHTML;
}
function readyStateHandlerDirectory()
{
log("ReadyState handler: readyState = " + xhr.readyState);
if (xhr.readyState == 4 && window.layoutTestController) {
var results = window.top.document.getElementById('results');
results.innerHTML = document.body.innerHTML;
setTimeout("layoutTestController.notifyDone()", 0);
}
}
function testXHRDirectory()
{
log("");
log("Doing an XHR to a directory.");
xhr = new XMLHttpRequest();
xhr.onerror = errorHandler;
xhr.onreadystatechange = readyStateHandlerDirectory;
try {
xhr.open("GET", "../resources/", false);
xhr.send("");
} catch(e) {
log("Exception: " + e.message);
}
}
function readyStateHandlerNonExistent()
{
log("ReadyState handler: readyState = " + xhr.readyState);
if (xhr.readyState == 4)
setTimeout("testXHRDirectory()", 0);
}
function testXHRNonExistentFile()
{
log("Doing an XHR to a nonexistent file.");
xhr = new XMLHttpRequest();
xhr.onerror = errorHandler;
xhr.onreadystatechange = readyStateHandlerNonExistent;
try {
xhr.open("GET", "nonexistent.html", true);
xhr.send("");
} catch(e) {
log("Exception: " + e.message);
testXHRDirectory();
}
}
</script>
</head>
<body onload="testXHRNonExistentFile()">
<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>
<p> In both cases, readyState 4 should be reached, and error handler should be invoked. </p>
<div id="console"/>
</body>
</html>
|