Skip to main content

Bug Tracker

Side navigation

#11484 closed feature (migrated)

Opened March 16, 2012 10:25PM UTC

Closed October 20, 2014 11:47PM UTC

SourceURL support for scripts loaded by domManip using XHRs.

Reported by: vsevik@chromium.org Owned by: jaubourg
Priority: low Milestone: 1.12/2.2
Component: ajax Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

This ticket is inspired by discussion in Chrome Developer Tools mailing group: https://groups.google.com/group/google-chrome-developer-tools/browse_thread/thread/e22f4cb5b0685dbd

SourceURL is a way to give a name to the script executed by eval() for debugging purposes.

See http://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/

Adding sourceURL to scripts loaded by domManip would make debugging easier.

example: $('head').append('<script src="test.js'></script>');

Similar (but different) request http://bugs.jquery.com/ticket/8292 was closed as wontfix earlier, so some comments on the reasons mentioned there:

This is a functionality that: - only developers will need while debugging

Yes, but is very valuable for developers and it comes with virtually zero cost for users.

- is only useful for Chrome users

sourceURL is supported by Firefox and WebKit (Chrome, Safari) which makes together more than 60% of browser market share.

- is of limited use as the names would need to be randomly generated

In the example mentioned above the url could and should be taken from the src attribute of the script tag. This is the same url the script was loaded from.

Vsevolod Vlasov, webkit reviewer

Attachments (0)
Change History (12)

Changed April 23, 2012 04:12PM UTC by rwaldron comment:1

component: unfiledajax
priority: undecidedlow

Changed May 05, 2012 04:31PM UTC by dmethvin comment:2

milestone: None1.next
status: newopen

Worth investigating.

Changed May 05, 2012 10:07PM UTC by jaubourg comment:3

owner: → jaubourg
status: openassigned

I'll look into it

Changed September 09, 2012 01:10AM UTC by dmethvin comment:4

type: enhancementfeature

Bulk change from enhancement to feature.

Changed December 23, 2012 04:26PM UTC by dmethvin comment:5

Changed April 04, 2013 08:29PM UTC by dmethvin comment:6

Just a note after a quick look at that pull request. It's possible we might open up security holes by adding this if we're not careful with the sourceURL string and it has a newline. We also need to be alert for the IE conditional javascript bug, see #13274.

Changed September 16, 2013 08:08PM UTC by m_gol comment:7

As for the IE conditional compilation bug, fortunately that's behind us - the recent sourcemap specification changes also changed the //@ sourceURL= to //# sourceURL=.

Changed September 16, 2013 08:54PM UTC by m_gol comment:8

milestone: 1.next1.next/2.next

Changed March 01, 2014 10:09PM UTC by dmethvin comment:9

If we switch to always using <script> tags for running code, we get this for free. I don't think the remaining use cases warrant a change to globalEval. See https://github.com/jquery/jquery/pull/1449 for tradeoffs.

Changed April 24, 2014 06:42AM UTC by paul.irish comment:10

This one just came up again: https://code.google.com/p/chromium/issues/detail?id=365645

I believe that with wither globalEval or a script tag the script will not have a real name that's debuggable in browser devtools. @sourceURL has strong x-browser support and would allow you to inject a filename for all injected scripts which would allow them to participate like real files.

Changed April 30, 2014 01:34PM UTC by dmethvin comment:11

milestone: 1.next/2.next1.12/2.2

See #14757, but since it's a feature I'll leave it open separately. I don't think we'd retain the globalEval method just so we could inject a #sourceURL comment, but if the user has added one the script tag method should use it.

Changed October 20, 2014 11:47PM UTC by m_gol comment:12

resolution: → migrated
status: assignedclosed