From 6f19b0cd8209252541109108b09a47badfc9995e Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 13 Jan 2017 17:49:46 -0500 Subject: [PATCH] Do not use the script element's line number for external scripts. --- components/script/dom/htmlscriptelement.rs | 3 ++- tests/wpt/mozilla/tests/mozilla/resources/external.js | 4 ++++ tests/wpt/mozilla/tests/mozilla/track_line.html | 10 ++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 tests/wpt/mozilla/tests/mozilla/resources/external.js diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 52935e32dcf2..ed8bdfaa886b 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -510,9 +510,10 @@ impl HTMLScriptElement { // Step 5.a.2. let window = window_from_node(self); + let line_number = if script.external { 1 } else { self.line_number as u32 }; rooted!(in(window.get_cx()) let mut rval = UndefinedValue()); window.upcast::().evaluate_script_on_global_with_result( - &script.text, script.url.as_str(), rval.handle_mut(), self.line_number as u32); + &script.text, script.url.as_str(), rval.handle_mut(), line_number); // Step 6. document.set_current_script(old_script.r()); diff --git a/tests/wpt/mozilla/tests/mozilla/resources/external.js b/tests/wpt/mozilla/tests/mozilla/resources/external.js new file mode 100644 index 000000000000..5f0242874cfa --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/resources/external.js @@ -0,0 +1,4 @@ + + + +this_is_a_js_error diff --git a/tests/wpt/mozilla/tests/mozilla/track_line.html b/tests/wpt/mozilla/tests/mozilla/track_line.html index 1e6b12e5cad6..b181b703897f 100644 --- a/tests/wpt/mozilla/tests/mozilla/track_line.html +++ b/tests/wpt/mozilla/tests/mozilla/track_line.html @@ -6,12 +6,18 @@ +