blob: 3e11b5a9bf1da31b640f0f53239320bf16a64944 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/2012/WD-XMLHttpRequest-20121206/#request-error"/>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test to validate the order in which the events are fired in case of a request error.");
window.jsTestIsAsync = true;
expectedOrder = "rsdone,upload.onerror,upload.onloadend,onerror,onloadend,";
actualOrder = "";
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:8000/xmlhttprequest/resources/cross-site-progress-events.cgi", true);
xhr.setRequestHeader("Content-Type", "text/plain");
xhr.onreadystatechange = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
actualOrder += "rsdone,";
}
};
xhr.upload.onerror = function (evt) {
actualOrder += "upload.onerror,";
};
xhr.upload.onloadend = function () {
actualOrder += "upload.onloadend,";
};
xhr.onerror = function (evt) {
actualOrder += "onerror,";
};
xhr.onloadend = function () {
actualOrder += "onloadend,";
shouldBeEqualToString('actualOrder', '' + expectedOrder);
finishJSTest();
};
xhr.send("test");
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>