RESOLVED FIXED 114969
Web Inspector: //@ sourceURL does not work in new Function
https://bugs.webkit.org/show_bug.cgi?id=114969
Summary Web Inspector: //@ sourceURL does not work in new Function
Timothy Hatcher
Reported 2013-04-22 11:01:19 PDT
This does not work: new Function("console.log(1)//@ sourceURL=test1.js"); While this does: eval("console.log(1)//@ sourceURL=test2.js"); From: https://twitter.com/PeterTheFace/status/326392487612657664
Attachments
Timothy Hatcher
Comment 1 2013-04-22 11:01:38 PDT
It works in Chrome/V8.
Radar WebKit Bug Importer
Comment 2 2013-04-22 11:02:45 PDT
Peter Josling
Comment 3 2013-04-22 11:20:57 PDT
If the inspector is opened after the page has loaded then sourceURLs load fine, but if the page is refreshed when the inspector is already open, nothing. Similarly "new Function()" calls in the console have no effect (but eval() does).
Timothy Hatcher
Comment 4 2013-04-22 11:25:36 PDT
It turns out this is hitting an optimization of the engine. We don't parse the script in the function until the function is called. So to trigger it in the console you need to do: new Function("console.log(1)//@ sourceURL=test1.js")(); I think this behaves correctly, even if there is a slight difference between Blink and WebKit. Do you see this working in real life once the functions get called?
Peter Josling
Comment 5 2013-04-22 11:30:05 PDT
If I paste that into my console I still don't see an entry for it in the resources pane, and on my test site none of the sourceURLs work even after the functions have been executed.
Timothy Hatcher
Comment 6 2013-04-22 11:33:00 PDT
You are right. I was testing in Safari 6. This seems to have regressed since then and no longer works in the nightly.
Timothy Hatcher
Comment 7 2013-06-27 05:05:10 PDT
Note You need to log in before you can comment on or make changes to this bug.