OLD | NEW |
1 <html> | 1 <html> |
2 <body> | 2 <body> |
3 <p>Tests the properties of XMLHttpRequest exceptions.</p> | 3 <p>Tests the properties of XMLHttpRequest exceptions.</p> |
4 <pre id="console"></pre> | 4 <pre id="console"></pre> |
5 <script> | 5 <script> |
6 function shouldBeEqualToString(__a, __b) | 6 function shouldBeEqualToString(__a, __b) |
7 { | 7 { |
8 var _a = eval(__a); | 8 var _a = eval(__a); |
9 | 9 |
10 var _message; | 10 var _message; |
11 if (_a == __b) { | 11 if (_a == __b) { |
12 _message = "PASS " + __a + " is \"" + __b + "\""; | 12 _message = "PASS " + __a + " is \"" + __b + "\""; |
13 } else { | 13 } else { |
14 _message = "FAIL " + __a + " is not \"" + __b + "\". Was \"" + _a +
"\""; | 14 _message = "FAIL " + __a + " is not \"" + __b + "\". Was \"" + _a +
"\""; |
15 } | 15 } |
16 document.getElementById('console').appendChild(document.createTextNode(_
message + "\n")); | 16 document.getElementById('console').appendChild(document.createTextNode(_
message + "\n")); |
17 } | 17 } |
18 | 18 |
19 function shouldBe(__a, __b) | 19 function shouldBe(__a, __b) |
20 { | 20 { |
21 var _a = eval(__a); | 21 var _a = eval(__a); |
22 var _b = eval(__b); | 22 var _b = eval(__b); |
23 | 23 |
24 var _message; | 24 var _message; |
25 if (_a == _b) { | 25 if (_a == _b) { |
26 _message = "PASS " + __a + " is " + __b; | 26 _message = "PASS " + __a + " is " + __b; |
27 } else { | 27 } else { |
28 _message = "FAIL " + __a + " is not " + __b + ". Was " + _a; | 28 _message = "FAIL " + __a + " is not " + __b + ". Was " + _a; |
29 } | 29 } |
30 document.getElementById('console').appendChild(document.createTextNode(_
message + "\n")); | 30 document.getElementById('console').appendChild(document.createTextNode(_
message + "\n")); |
31 } | 31 } |
32 | 32 |
33 if (window.testRunner) | 33 if (window.testRunner) |
34 testRunner.dumpAsText(); | 34 testRunner.dumpAsText(); |
35 | 35 |
36 var e; | 36 var e; |
37 try { | 37 try { |
38 var req = new XMLHttpRequest; | 38 var req = new XMLHttpRequest; |
39 req.open('GET', 'resources/infinite-loop.php', false); | 39 req.open('GET', 'resources/infinite-loop.php', false); |
40 req.send(null); | 40 req.send(null); |
41 // raises NETWORK_ERR | 41 // raises NETWORK_ERR |
42 } catch (err) { | 42 } catch (err) { |
43 e = err; | 43 e = err; |
44 } | 44 } |
45 | 45 |
46 shouldBeEqualToString("e.toString()", "NetworkError: Failed to execute 'send
' on 'XMLHttpRequest': Failed to load 'http://127.0.0.1:8000/xmlhttprequest/reso
urces/infinite-loop.php'."); | 46 shouldBeEqualToString("e.toString()", "NetworkError: Failed to execute 'send
' on 'XMLHttpRequest': Failed to load 'http://127.0.0.1:8000/xmlhttprequest/reso
urces/infinite-loop.php'."); |
47 shouldBeEqualToString("Object.prototype.toString.call(e)", "[object DOMExcep
tion]"); | 47 shouldBeEqualToString("Object.prototype.toString.call(e)", "[object DOMExcep
tion]"); |
48 shouldBeEqualToString("Object.prototype.toString.call(e.__proto__)", "[objec
t DOMExceptionPrototype]"); | 48 shouldBeEqualToString("Object.prototype.toString.call(e.__proto__)", "[objec
t DOMException]"); |
49 shouldBeEqualToString("e.constructor.toString()", "function DOMException() {
[native code] }"); | 49 shouldBeEqualToString("e.constructor.toString()", "function DOMException() {
[native code] }"); |
50 shouldBe("e.constructor", "window.DOMException"); | 50 shouldBe("e.constructor", "window.DOMException"); |
51 shouldBe("e.NETWORK_ERR", "e.constructor.NETWORK_ERR"); | 51 shouldBe("e.NETWORK_ERR", "e.constructor.NETWORK_ERR"); |
52 shouldBe("e.NETWORK_ERR", "19"); | 52 shouldBe("e.NETWORK_ERR", "19"); |
53 </script> | 53 </script> |
54 </body> | 54 </body> |
55 </html> | 55 </html> |
OLD | NEW |