Closed Bug 982153 Opened 9 years ago Closed 9 years ago

Wrong stack frame lines for scripts dynamically injected using <script> element

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: Honza, Assigned: simon.lindholm10)

Details

Attachments

(1 file, 1 obsolete file)

Stack frame lines are wrong (should be +1) for script that are dynamically created using <script> element and textContent as follows:

var scriptTag = document.createElement("script");
scriptTag.textContent = "console.log('hello world');";
document.body.appendChild(scriptTag);

Note that line numbers are correct when <script> tag with valid src attribute is appended to the document as follows:

var scriptTag = document.createElement("script");
scriptTag.src = my-file-url.js";
document.body.appendChild(scriptTag);

---

It might be caused by the fact that script.startLine is set to 0

Note that script.startLine is set to 1 for other dynamically created
scripts:
- new Function
- eval
- Appending <script> element to the document (with valid src attribute)
- event handlers

Honza
Or should I rather use DOM: Core & HTML component?

Honza
A try run suggests no further changes necessary: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=ad8321fcb698 (Being completely new to this I'm not sure if there are any other tests relevant to run.)

FWIW Chrome also has 1-indexed line numbers, so I don't expect this to break anything external.
Attachment #8509853 - Flags: review?(bzbarsky)
Comment on attachment 8509853 [details] [diff] [review]
Give dynamically created script elements 1-indexed line numbers. v1

Please move this bug to the appropriate Core component.

There used to be a time when "0" meant "we have no idea, please don't show line numbers here at all because they'll just be lies", but apparently someone broke that at some point and started showing the bogus numbers.  :(

r=me given that.
Attachment #8509853 - Flags: review?(bzbarsky) → review+
Component: Developer Tools: Debugger → DOM: Core & HTML
Product: Firefox → Core
Keywords: checkin-needed
https://hg.mozilla.org/integration/mozilla-inbound/rev/f9f9b79c0aa6
Assignee: nobody → simon.lindholm10
Flags: in-testsuite+
Keywords: checkin-needed
... oh. So this is due to me being a complete beginner at this: the "run-if = os == 'linux'" line affects the test before it, not after.

New try-run: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=7d8fd041d79a
Yes, that syntax is crazy. You're not the first one to make the mistake.
Passes m-1 on Linux and Windows.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/dd1811e791ad
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.