Closed Bug 1470768 Opened 6 years ago Closed 5 years ago

//# sourceURL= pragma does not work in JS-inserted <script>s w/ "src" attr

Categories

(DevTools :: Debugger, defect, P3)

defect

Tracking

(firefox61 wontfix, firefox62 wontfix, firefox63 wontfix, firefox77 verified)

VERIFIED FIXED
Firefox 77
Tracking Status
firefox61 --- wontfix
firefox62 --- wontfix
firefox63 --- wontfix
firefox77 --- verified

People

(Reporter: jochen.kuehner, Assigned: loganfsmyth)

References

(Blocks 2 open bugs)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36 Steps to reproduce: Look at https://shop.polymer-project.org/ with current Firefox. You will see in the script debugger when you look at "no domain", there are javascripts with "sourceurls" but that name is not used! Actual results: SourceUrl is not used Expected results: SourceUrl should be used
I have managed to reproduce this issue on Firefox 61.0 2018-06-21 Firefox beta 62.0b3 2018-06-25 Firefox nightly 63.0a1 2018-06-26 -Windows 10 Pro x64 But, I'm not sure that I understand the issue, therefore initially triaging this issue to devtools component.
Status: UNCONFIRMED → NEW
Component: Untriaged → Debugger
Ever confirmed: true
Product: Firefox → DevTools
This one seems like it is probably a dup, but I didn't search out the other bug.
Blocks: source-maps

Could you look again Jochen? I can't reproduce in Firefox Nightly.

Yes is still an issue...

For example look at https://www.webcomponents.org/element/@polymer/iron-demo-helpers/demo/demo/index.html

Open Developer Tools, go to "Debugger", Expand "No Domain", klick on first file. It has a SOurceUrl comment but it is not used

Here is little test case that uses //# sourceURL in evaluated script (using eval)
http://janodvarko.cz/tests/bugzilla/1470768/

  1. Load the page
  2. Check that https://www.webcomponents.org/src/lazy-resources.html-5.js file is in the Sources panel
  3. See also the (index) file that does the eval

It works just fine.
But, the provided test case is using data: URI, might the issue?

Related MDN page:
https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Debug_eval_sources

Honza

Flags: needinfo?(jochen.kuehner)
Priority: -- → P3
Summary: SourceUrl comment for generated js code does not work → SourceUrl pragma does not work for sources with a data url

If you have a <script> with a data: URL, //# sourceURL= can still be very useful for setting the location, but we current limit it's effects to things that we see as "eval-like". This means the pragma works for code evalled as a string, e.g. eval, new Function, setTimeout("console.log(42);", 0) and such, including

const s = document.createElement("script"); 
s.text = "code; //# sourceURL=";

but it will not work if you take that same code, encode it as a data: URL, and then put it as the src of a script, e.g.

const s = document.createElement("script"); 
s.src = "data:application/javascript;base64," + encodeBase64("code; //# sourceURL=");

I don't see a reason for us to have this logic be restricted to eval sources when we could instead make this logic essentially source.displayURL || source.url. It appears that one of the only reasons we bother right now is to try to make displayURL relative to a specific URL, but depending on how we deal with https://bugzilla.mozilla.org/show_bug.cgi?id=1192882, we may want to stop doing that anyway? I'll have to do some more research.

Flags: needinfo?(jochen.kuehner)
Summary: SourceUrl pragma does not work for sources with a data url → //# sourceURL= pragma does not work in JS-inserted <script>s w/ "src" a attr
Summary: //# sourceURL= pragma does not work in JS-inserted <script>s w/ "src" a attr → //# sourceURL= pragma does not work in JS-inserted <script>s w/ "src" attr
Assignee: nobody → loganfsmyth
Status: NEW → ASSIGNED
Pushed by loganfsmyth@gmail.com: https://hg.mozilla.org/integration/autoland/rev/70aa92ce25b7 Allow sourceURL to apply generally across all types of scripts. r=jlast
Backout by csabou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1f5dca62d402 Backed out 6 changesets (bug 1470768, bug 1607639) for causing xpc failures on xpcshell/test_objectgrips-13.js. CLOSED TREE
Pushed by loganfsmyth@gmail.com: https://hg.mozilla.org/integration/autoland/rev/7136265fbb0f Allow sourceURL to apply generally across all types of scripts. r=jlast
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 77

Confirmed with 77.0b2 on Windows 10, macOS 10.15.3, Ubuntu 18.04 based on comment 8.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: