blob: 131f58a45bc410e800113e483784be993b0af43d [file] [log] [blame]
<!DOCTYPE html>
<meta http-equiv="Content-Security-Policy" content="connect-src">
<script src="../../resources/js-test.js"></script>
description("This tests that exceptions thrown by have reasonable messages.");
var xhrException;
try {
var xhr = new XMLHttpRequest();"TRACE", "");
testFailed(" should throw an exception with a forbidden method type.");
} catch (e) {
xhrException = e;
shouldBeEqualToString("xhrException.message", "Failed to execute 'open' on 'XMLHttpRequest': 'TRACE' HTTP method is unsupported.");
var badString = { toString: function() { throw "Exception in toString()"; } };
var xhr = new XMLHttpRequest();
shouldBe("xhr.readyState", "XMLHttpRequest.UNSENT");
shouldThrow("'GET', 'resources/xmlhttprequest-get-data.xml', true, badString, 'password');", "'Exception in toString()'");
shouldBe("xhr.readyState", "XMLHttpRequest.UNSENT");
shouldThrow("'GET', 'resources/xmlhttprequest-get-data.xml', true, 'username', badString);", "'Exception in toString()'");
shouldBe("xhr.readyState", "XMLHttpRequest.UNSENT");