Scripts added to a page via createElement and appendChild do not appear in the debugger UI



6 years ago
7 months ago


(Reporter: rcampbell, Unassigned)


Firefox Tracking Flags

(Not tracked)



(2 attachments, 1 obsolete attachment)



6 years ago
Created attachment 702225 [details]


1. Open a Scratchpad
2. Load the attached script
3. Open the Debugger
4. Run the script

Expected results:

Script appears in the <head> of the document.


No script visible.

For bonus points, trigger the contents of the script and watch the breakpoint hit on the <head> element in the source view.


6 years ago
OS: Mac OS X → All
Hardware: x86 → All
Created attachment 702258 [details]
script-loader.js v2

Fixed a typo and added a trigger for the pause.

This is the newScript packet the server sent:

  "type": "newScript",
  "url": "",
  "startLine": 0,
  "lineCount": 3,
  "source": "conn4.source28"

Gecko or SpiderMonkey use the URL of the document where the dynamic script was created, which is to be expected, but with a starting line number of 0.
Attachment #702225 - Attachment is obsolete: true
So I tried it on a URL without any scripts, and the debugger does the right thing and display a single script with the page URL and the contents of the scratchpad (which may not be what you'd expect, but it's better than nothing!).

Bug 566446 mentions that JSD has the same issue (and it affects Firebug) only worse, because it treats scripts with startLine == 0 as errors. It is also quite similar to bug 332176, which we already know.

I don't know how or if Gecko/SM could relate the dynamically-added script's starting line to the modified markup of the page. The only shred of evidence that something like that is possible, is the View Selected Source context menu item in the modified page. We need to find out how View Source gets this update markup, and whether this is something the debugger should do as well, or it can be somehow provided by SpiderMonkey. And by the latter I mean to have the Debugger API return a startLine that correponds to the updated markup through onNewScript.

Comment 3

6 years ago
Jim, we could probably use a consult here. This would allow us to do some interesting things with scratchpads and dynamic scripts.
Priority: -- → P3
Depends on: 905700
Created attachment 8894984 [details]

Just putting this into a simple html page you can run.  The new debugger still doesn't handle this properly.  We likely need to change the server here.


7 months ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.