Open Bug 1643061 Opened 4 years ago Updated 2 years ago

dynamically loaded js file incorrectly identified as part of jquery

Categories

(DevTools :: Debugger, defect, P2)

76 Branch
defect

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: r.ribas.jaume, Unassigned, NeedInfo)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Attached image JumpToDefinition.png

User Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0

Steps to reproduce:

Load js file dynamically using jquery ajax request. Write name of function defined in this file in console and double click to go to source.

Actual results:

Instead of opening the correct file, the jquery source file is opened.
I also noticed that when debugging one of this functions it is grouped under jquery in the call stack.

Expected results:

Open the dynamically loaded file containing the function definition.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Component: JavaScript Engine → General
Product: Core → DevTools

r.ribas.jaume, do you have a test case or could create one to see how this source is loaded?

Component: General → Debugger
Flags: needinfo?(r.ribas.jaume)

I've tried to isolate the error in a test case but apparently it's not as simple as I thought to get this error.
I still can't reproduce it outside of the project where I found it.
Unfortunately I can't give access to that particular project because it is not a public facing site.
I might try to isolate it again in the future.

Flags: needinfo?(r.ribas.jaume)

The severity field is not set for this bug.
:jlast, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jlaster)

I was pretty sure I knew why this was happening, so just verified.

Here's repro steps without needing jQuery

  1. Make an HTML file containing:
<script>
  (async () => {
    const res = await fetch("random.js");
    const text = await res.text();

    var s = document.createElement("script");
    s.text = text;
    document.head.append(s);
})();
</script>

and a "random.js" file containing

function fn(){}
console.log(fn);

jQuery doesn't use eval to actually run scripts, it inserts script tags either with text content or a "src".

Because an injected inline script has no useful URL it currently ends up with the URL of the file that did the injecting of the element. This all ties back to https://bugzilla.mozilla.org/show_bug.cgi?id=1641121 because this "Jump to Definition" logic is one of the cases where we don't currently send a source actor ID along with the location information, so all "Jump to Definition" has to work with is a URL that is wrong. We should really be sending the source actor ID along with the function URL data.

Blocks: dbg-sources
Flags: needinfo?(jlaster)
Priority: -- → P2

The severity field is not set for this bug.
:jlast, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jlaster)
Attachment #9159268 - Attachment is obsolete: true

I assume this will be fixed via Bug 1641121, let's keep both open for now.

Severity: -- → S3
Depends on: 1641121
Flags: needinfo?(jlaster)

Redirect a needinfo that is pending on an inactive user to the triage owner.
:bomsy, since the bug has high priority and recent activity, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(r.ribas.jaume) → needinfo?(hmanilla)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: