chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/upload-request-error-event-order.html

<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/2012/WD-XMLHttpRequest-20121206/#request-error"/>
<script src="/js-test-resources/js-test.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>
</body>
</html>