blob: 99db1d288528ac26449af51d7be0e0f0c6938f2c [file] [log] [blame]
<html>
<body>
<p>Tests the properties of XMLHttpRequest exceptions.</p>
<pre id="console"></pre>
<script>
function shouldBeEqualToString(__a, __b)
{
var _a = eval(__a);
var _message;
if (_a == __b) {
_message = "PASS " + __a + " is \"" + __b + "\"";
} else {
_message = "FAIL " + __a + " is not \"" + __b + "\". Was \"" + _a + "\"";
}
document.getElementById('console').appendChild(document.createTextNode(_message + "\n"));
}
function shouldBe(__a, __b)
{
var _a = eval(__a);
var _b = eval(__b);
var _message;
if (_a == _b) {
_message = "PASS " + __a + " is " + __b;
} else {
_message = "FAIL " + __a + " is not " + __b + ". Was " + _a;
}
document.getElementById('console').appendChild(document.createTextNode(_message + "\n"));
}
if (window.testRunner)
testRunner.dumpAsText();
var e;
try {
var req = new XMLHttpRequest;
req.open('GET', '../resources/infinite-loop.php', false);
req.send(null);
// raises NETWORK_ERR
} catch (err) {
e = err;
}
shouldBeEqualToString("e.toString()", "NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://127.0.0.1:8000/resources/infinite-loop.php'.");
shouldBeEqualToString("Object.prototype.toString.call(e)", "[object DOMException]");
shouldBeEqualToString("Object.prototype.toString.call(e.__proto__)", "[object DOMExceptionPrototype]");
shouldBeEqualToString("e.constructor.toString()", "function DOMException() { [native code] }");
shouldBe("e.constructor", "window.DOMException");
shouldBe("e.NETWORK_ERR", "e.constructor.NETWORK_ERR");
shouldBe("e.NETWORK_ERR", "19");
</script>
</body>
</html>