Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/webappapis/scripting/reporterror-cross-realm-method.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8">
<title>self.reportError() dispatches an "error" event for this's relevant global object</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
setup({ allow_uncaught_exception: true });
async_test(t => {
window.addEventListener("error", t.unreached_func("'error' event should not be dispatched for top window!"));
const iframe = document.createElement("iframe");
iframe.onload = t.step_func_done(() => {
let eventFired = false;
const error = new TypeError("foo");
const otherWindow = iframe.contentWindow;
otherWindow.addEventListener("error", t.step_func(event => {
assert_equals(event.error, error);
eventFired = true;
}));
window.reportError.call(otherWindow, error);
assert_true(eventFired);
});
document.body.append(iframe);
});
</script>