Store parser's current line when script elements are created.

Use the newly stored line as the starting line number when
evaluating JS. This ensures that inline scripts will report
errors with meaningful line numbers.
This commit is contained in:
karenher 2016-12-21 10:40:13 -05:00 committed by Josh Matthews
parent d1bc1a4f1b
commit db2082bc6e
11 changed files with 61 additions and 22 deletions

View file

@ -1,5 +0,0 @@
[window-onerror-parse-error.html]
type: testharness
[correct line number passed to window.onerror]
expected: FAIL

View file

@ -1,5 +0,0 @@
[window-onerror-runtime-error.html]
type: testharness
[correct line number passed to window.onerror]
expected: FAIL

View file

@ -15200,6 +15200,12 @@
"url": "/_mozilla/mozilla/trace_null.html"
}
],
"mozilla/track_line.html": [
{
"path": "mozilla/track_line.html",
"url": "/_mozilla/mozilla/track_line.html"
}
],
"mozilla/union.html": [
{
"path": "mozilla/union.html",

View file

@ -0,0 +1,17 @@
<!doctype html>
<meta charset="utf-8">
<title>Test that errors from inline scripts report meaningful line numbers</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({allow_uncaught_exception:true});
var t = async_test("error event has proper line number");
window.addEventListener('error', t.step_func(function(e) {
assert_true(e instanceof ErrorEvent);
assert_equals(e.lineno, 16);
t.done();
}), true);
</script>
<script>
this_is_a_js_error
</script>