-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb/HTML: Include better information in 'report an exception' event
Instead of always reporting a colno and lineno of zero try and use the values from the Error object that may be provided, falling back to the source location of the invocation if not provided. We can definitely improve the reporting even more, but this is a start! Also update this function to latest spec while we're in the area.
- Loading branch information
1 parent
fef1f62
commit 3df843e
Showing
5 changed files
with
198 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/reporterror.any.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Harness status: OK | ||
|
||
Found 5 tests | ||
|
||
5 Pass | ||
Pass self.reportError(1) | ||
Pass self.reportError(TypeError) | ||
Pass self.reportError(undefined) | ||
Pass self.reportError() (without arguments) throws | ||
Pass self.reportError() doesn't invoke getters |
15 changes: 15 additions & 0 deletions
15
Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/reporterror.any.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
|
||
<script> | ||
self.GLOBAL = { | ||
isWindow: function() { return true; }, | ||
isWorker: function() { return false; }, | ||
isShadowRealm: function() { return false; }, | ||
}; | ||
</script> | ||
<script src="../../../resources/testharness.js"></script> | ||
<script src="../../../resources/testharnessreport.js"></script> | ||
|
||
<div id=log></div> | ||
<script src="../../../html/webappapis/scripting/reporterror.any.js"></script> |
49 changes: 49 additions & 0 deletions
49
Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/reporterror.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
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`); | ||
|
||
test(() => { | ||
// Workaround for https://github.com/web-platform-tests/wpt/issues/32105 | ||
let invoked = false; | ||
self.reportError({ | ||
get name() { | ||
invoked = true; | ||
assert_unreached('get name') | ||
}, | ||
get message() { | ||
invoked = true; | ||
assert_unreached('get message'); | ||
}, | ||
get fileName() { | ||
invoked = true; | ||
assert_unreached('get fileName'); | ||
}, | ||
get lineNumber() { | ||
invoked = true; | ||
assert_unreached('get lineNumber'); | ||
} | ||
}); | ||
assert_false(invoked); | ||
}, `self.reportError() doesn't invoke getters`); |