blob: 44589aedb8956b0401dbcd924ffe75122662e7a4 [file] [log] [blame] [edit]
<!DOCTYPE html>
<meta charset="utf-8">
<title>requestAnimationFrame callback exception reported to error handler</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#run-the-animation-frame-callbacks">
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="navigate-me" src="callback-exception-support-1.html"></iframe>
<script>
"use strict";
setup({ allow_uncaught_exception: true });
const exceptionMessage = "requestAnimationFrameException";
async_test(t => {
window.addEventListener("error", t.step_func_done(ev => {
assert_equals(ev.constructor, ErrorEvent);
assert_equals(ev.error.message, exceptionMessage);
}));
requestAnimationFrame(() => {
throw new Error(exceptionMessage);
});
}, "requestAnimationFrame errors in an active document should fire an error event");
async_test(t => {
const iframe = document.querySelector("#navigate-me");
const windowProxy = iframe.contentWindow;
window.onload = t.step_func(() => {
windowProxy.onerror = t.unreached_func("The pre-navigation Window's onerror must not be called");
const oldRAF = windowProxy.requestAnimationFrame;
iframe.addEventListener("load", t.step_func(() => {
const newRAF = windowProxy.requestAnimationFrame;
assert_not_equals(oldRAF, newRAF, "Sanity check: navigation changed the requestAnimationFrame");
assert_equals(windowProxy.onerror, null, "Sanity check: after navigation reset onerror");
windowProxy.onerror = t.unreached_func("The post-navigation Window's onerror must not be called");
oldRAF(() => {
throw new Error(exceptionMessage);
});
// The test passes if no error events have been fired within this time.
t.step_timeout(t.step_func_done(), 2000);
}));
windowProxy.location.href = "callback-exception-support-2.html";
});
}, "requestAnimationFrame errors in navigated-away-from documents should not fire any error events");
</script>