Jacek Caban (@jacek) commented about dlls/mshtml/tests/xhr.js:
if(sync_xhr.readyState < 4)return;window.setTimeout(function() { a.push("timeout_sync"); }, 0);window.postMessage("_sync", "*");sync_xhr_nested = new XMLHttpRequest();sync_xhr_nested.open("POST", "echo.php", false);sync_xhr_nested.onreadystatechange = function() {a.push("nested(" + sync_xhr_nested.readyState + ")");if(sync_xhr_nested.readyState == 4) {window.setTimeout(function() { a.push("timeout_nested"); }, 0);window.postMessage("_nested", "*");var e = document.createEvent("Event");e.initEvent("click", true, false);async_xhr.dispatchEvent(e);
I'd suggest to verify that dispatchEvent indeed dispatched the event immediately. The way it's currently written, it would pass if the event was delayed.