blob: 2d47ec6d47f952b4e09df4d3ea7800c39a067904 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Tests aborting XMLHttpRequest 'arraybuffer' loading with the .responseType and .response attributes.");
var xhr = 0;
function abort() {
testPassed("abort() was called.");
// For aborted 'arraybuffer' the .response should not yet exist.
if (!xhr.response)
testPassed("'arraybuffer' .response does not exist after aborted load.");
else
testFailed("'arraybuffer' .response should not exist after aborted load.");
xhr = null;
finishJSTest();
}
function load() {
testFailed("onload() should not be called since loading was aborted.");
xhr = null;
finishJSTest();
}
function runTest() {
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
xhr = new XMLHttpRequest();
xhr.onload = load;
xhr.onabort = abort;
xhr.open("GET", "../../http/tests/resources/balls-of-the-orient.aif", true);
try {
if ("responseType" in xhr)
testPassed("responseType property exists.");
if ("response" in xhr)
testPassed("response property exists.");
// Make sure we can set responseType to "arraybuffer" before send() is called.
try {
xhr.responseType = "arraybuffer";
if (xhr.responseType == "arraybuffer")
testPassed("xhr.responseType has been correctly set to 'arraybuffer'.");
} catch(e) {
testFailed("unable to set xhr.responseType to 'arraybuffer' " + e + ".");
}
} catch(e) {
testFailed("Caught exception " + e + ".");
}
xhr.send(null);
xhr.abort();
window.jsTestIsAsync = true;
}
runTest();
</script>
</body>
</html>