New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report meaningful line numbers for inline script errors #14963
Merged
+61
−22
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
| @@ -60,6 +60,9 @@ pub struct HTMLScriptElement { | ||
|
|
||
| /// Document of the parser that created this element | ||
| parser_document: JS<Document>, | ||
|
|
||
| /// Track line line_number | ||
| line_number: u64, | ||
| } | ||
|
|
||
| impl HTMLScriptElement { | ||
| @@ -69,10 +72,11 @@ impl HTMLScriptElement { | ||
| htmlelement: | ||
| HTMLElement::new_inherited(local_name, prefix, document), | ||
| already_started: Cell::new(false), | ||
| parser_inserted: Cell::new(creator == ElementCreator::ParserCreated), | ||
| non_blocking: Cell::new(creator != ElementCreator::ParserCreated), | ||
| parser_inserted: Cell::new(creator.is_parser_created()), | ||
| non_blocking: Cell::new(!creator.is_parser_created()), | ||
| ready_to_be_parser_executed: Cell::new(false), | ||
| parser_document: JS::from_ref(document), | ||
| line_number: creator.return_line_number(), | ||
| } | ||
| } | ||
|
|
||
| @@ -508,7 +512,7 @@ impl HTMLScriptElement { | ||
| let window = window_from_node(self); | ||
| rooted!(in(window.get_cx()) let mut rval = UndefinedValue()); | ||
| window.upcast::<GlobalScope>().evaluate_script_on_global_with_result( | ||
| &script.text, script.url.as_str(), rval.handle_mut()); | ||
| &script.text, script.url.as_str(), rval.handle_mut(), self.line_number as u32); | ||
jdm
Author
Member
|
||
|
|
||
| // Step 6. | ||
| document.set_current_script(old_script.r()); | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
| "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", |
| @@ -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> |
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Can we avoid this cast?