Closed Bug 1333282 Opened 7 years ago Closed 5 years ago

Cannot debug scripts injected into the document

Categories

(DevTools :: Debugger, defect, P3)

52 Branch
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: matthew, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20170121004004

Steps to reproduce:

<!doctype html>

<script>
  (function(){

    var script = document.createElement('script');
    script.textContent = `
      console.log('some text');

      debugger;
    `;

    document.documentElement.appendChild(script);

  })();
</script>



Actual results:

The debugger statement is hit, but the devtools shows the wrong source.


Expected results:

Should show the evaled script as its own source, and the breakpoint should be at the right place.
Note that adding a fake #sourceURL doesn't fix it.
Component: Untriaged → Developer Tools: Debugger
I am seeing something similar with 53.0a2 (2017-01-30) Aurora. This only occurs in Aurora.

When I have JavaScript inside of a <script> tag in HTML and I change that JavaScript source, I never see my changes reflected in my browser. I have tried a hard refresh with no luck. JavaScript changes are picked up when in their own JS files, but not when they are in an HTML file inside. HTML changes work fine, they are refreshed, but not JavaScript changes.
Regarding my last comment, I am using the Firefox Developer Edition on Ubuntu 16.04 and Gnome 3. I am not certain if it is called "Aurora." I am using it as my desktop browser for debugging HTML/CSS/JS etc.
DE = Aurora, same version.
Can you offer a screenshot of what you're seeing?

I'm guessing it says: SOURCE as this is an dynamic source.  It should probably better relate to the original source.
Priority: -- → P3
It's not about the name in the sources sidebar, it's that the evaled code is not shown as its own script at all.  Will upload a screenshot.
This is stopped inside of my dynamic script, where `debugger` happens, but doesn't show this script as its own script, but rather shows the HTML file from which it was created. 

This makes it impossible to step through this dynamically created script.
Product: Firefox → DevTools

Matthew, could you try again in the new debugger? We have a test for this and it should work.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: