Skip to content

Commit

Permalink
HTML: self.reportError()
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk authored Jul 27, 2021
1 parent da6bac9 commit c3cb110
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions html/webappapis/scripting/reporterror.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
setup({ allow_uncaught_exception:true });

[
1,
new TypeError(),
undefined
].forEach(throwable => {
test(t => {
let happened = false;
self.addEventListener("error", t.step_func(e => {
assert_true(e.message !== "");
assert_equals(e.filename, new URL("reporterror.any.js", location.href).href);
assert_greater_than(e.lineno, 0);
assert_greater_than(e.colno, 0);
assert_equals(e.error, throwable);
happened = true;
}), { once:true });
self.reportError(throwable);
assert_true(happened);
}, `self.reportError(${throwable})`);
});

test(() => {
assert_throws_js(TypeError, () => self.reportError());
}, `self.reportError() (without arguments) throws`);

0 comments on commit c3cb110

Please sign in to comment.