chromium/third_party/blink/web_tests/fast/harness/expected-error-in-async-test.html

<!DOCTYPE html>

<script src="../../resources/js-test.js"></script>
<script>
description('Test that the window.onerror handler in resources/js-test.js ' +
    'stops asynchronous tests');

function errorThrower()
{
    setTimeout(errorExpecter, 0);
    debug("Throwing an expected error");
    throw new Error("An expected error");
}

function errorExpecter()
{
    shouldHaveHadError("expected error");
    finishJSTest();
}

window.jsTestIsAsync = true;
debug("Will throw an error soon");
expectError();
setTimeout(errorThrower, 0);
</script>