Closed Bug 1579994 Opened Last month Closed 23 days ago

Debugger's pretty print shows old script

Categories

(DevTools :: Debugger, defect, P1)

defect

Tracking

(firefox-esr60 wontfix, firefox-esr68 wontfix, firefox69 wontfix, firefox70 wontfix, firefox71 fixed)

RESOLVED FIXED
Firefox 71
Tracking Status
firefox-esr60 --- wontfix
firefox-esr68 --- wontfix
firefox69 --- wontfix
firefox70 --- wontfix
firefox71 --- fixed

People

(Reporter: Oriol, Assigned: arosenfeld2003)

References

(Blocks 1 open bug)

Details

(Whiteboard: [debugger-reserve])

Attachments

(1 file)

  1. Open web console
  2. Run "foo"; debugger;
  3. The debugger shows a SOURCEsource77 script with "foo"; debugger;
  4. Click 'Pretty print source'. The debugger shows a {} SOURCEsource77 script with
    'foo';
    debugger;
    
  5. Resume the debugger, go back to the console.
  6. Run "bar"; debugger;
  7. The debugger shows a SOURCEsource91 script with "bar"; debugger;
  8. Click 'Pretty print source'.

Expected result: the debugger shows a {} SOURCEsource91 script with

'bar';
debugger;

Actual result: the debugger shows the previous {} SOURCEsource77 script with

'foo';
debugger;
Priority: -- → P1
Blocks: dbg-71
Whiteboard: [debugger-reserve]
Whiteboard: [debugger-reserve] → [debugger-mvp]

It looks like the url for both sources created in the console is null, even though they have different source.id values.

In prettyPrint.js ( togglePrettyPrint method), we have:

const url = getPrettySourceURL(source.url);  
const prettySource = getSourceByURL(getState(), url);

if (prettySource) {
      return dispatch(selectPrettyLocation(cx, prettySource));
    }

getSourceByURL returns :formatted for both sources with null URL.

The pretty printed source is created when the first source is passed in, but getSourceByURL returns the same prettySource when we prettyPrint the second source.

Are there other instances (besides creating sources in the console) where we would have two different sources with the same url? Does it make sense to create a unique URL for every source created in the console?

nice find! is there any way we can use source id here?

Yeah - I think I found a straightforward solution using the source id to create a URL if the URL is null, which seems to solve the issue.
Later today I'll go ahead and submit a patch for you to check out.

use the source id to create a url when pretty printing if the url is null.

Assignee: nobody → arosenfeld2003
Status: NEW → ASSIGNED
Whiteboard: [debugger-mvp] → [debugger-reserve]
Attachment #9094265 - Attachment description: Bug 1579994 - Handle null source value in prettyPrint r=jlast → Bug 1579994 - Handle null source value in prettyPrint r=davidwalsh

(In reply to Alex R. from comment #1)

Are there other instances (besides creating sources in the console) where we would have two different sources with the same url? Does it make sense to create a unique URL for every source created in the console?

Maybe you can have 2 <script> pointing to the same url without caching, and the server response is different each time?

Without knowing much about the debugger, would it be a problem to always use the source id, even if there is an url? Seems more robust

Pushed by dwalsh@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cb54e53665de
Handle null source value in prettyPrint r=davidwalsh
Status: ASSIGNED → RESOLVED
Closed: 23 days ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 71
You need to log in before you can comment on or make changes to this bug.