<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script>
function loadScript(url, async, onload, onerror) {
var script = document.createElement("script");
script.async = async;
script.onload = onload;
if (onerror)
script.onerror = onerror;
script.src = url;
document.head.appendChild(script);
}
</script>
</head>
<body>
<script>
description("Script that fails to load should not dispatch multiple error events");
window.jsTestIsAsync = true;
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var numberOfTimesOnErrorHandlerHasRun = 0;
function step2() {
shouldBeZero("numberOfTimesOnErrorHandlerHasRun");
numberOfTimesOnErrorHandlerHasRun++;
// Issue another script load so as to have the script runner
// revisit its script queue. It must not include the sync script
// that triggered the dispatch of an error event and the running of
// this handler.
loadScript("resources/script-load.js", true, finishJSTest);
}
function unexpectedLoad() {
testFailed("Script should not have loaded");
finishJSTest();
}
loadScript("non-existing.js", false, unexpectedLoad, step2);
</script>
</body>
</html>