Created attachment 275194 [details] Example to reproduce the bug The source map from a generated script is not loaded. To reproduce: - Unzip the attachment. - Host it by executing 'python -m SimpleHTTPServer 1234' - Go to http://0.0.0.0:1234 - Open the Web Inspector Console (option-cmd-C) - Look at the first error Observed: - The error is reported as originating from the function `anonymous`, not linked to any source. Expected: - The error is reported as originating from app.coffee:1 or at the very least from the 'Extra Script' coffeescript:3 Notes: This might be a duplicate of https://bugs.webkit.org/show_bug.cgi?id=156021
<rdar://problem/25438595>
This is another great reduction! Even after fixing bug 156021, this exposes another issue. We aren't reliably detecting the sourceURL within functions created via `Function`. * TEST <script> console.log(Function("\n//# sourceURL=test.js\nreturn 1+1")()); </script> I'd expect this to always create a Extra Script named "test.js" however it only does it rarely (once or twice) and then never again.
Hmm, the so issue here is the sourceURL/sourceMappingURL do not get added when we skip re-parsing via the CodeCache: When constructing the executable for `Function(str)` we go through: frame #0: JSC::CodeCache::getFunctionExecutableFromGlobalCode frame #1: JSC::UnlinkedFunctionExecutable::fromGlobalCode frame #2: JSC::FunctionExecutable::fromGlobalCode frame #3: JSC::constructFunctionSkippingEvalEnabledCheck frame #4: JSC::constructFunction frame #5: JSC::constructFunction frame #6: JSC::callFunctionConstructor At which point if we do not have it in the CodeCache we parse it. If we do have this in the code cache, we return the cached unlinked function executable skipping parsing. By skipping parsing we don't update the SourceProvider with the sourceURL/sourceMappingURL, because we normally do that under JSC::Parser<>::parse.
Fixing the CodeCache issue then revealed a few more issues. 1. Using CodeCache and skipping loses source directives (Function constructor) 2. Frontend didn't properly handle a top level sourceMappingURL being a dataURL 3. Exceptions thrown in non-resource scripts would not have resource links in the console, because we couldn't map them back to a resource. (no url) Fixing all of these gets this working. I'm going to first fix the CodeCache issue separately, because I think the JavaScriptCore folks may have some input on that.
Created attachment 276973 [details] [PATCH] Proposed Fix
Created attachment 276974 [details] [IMAGE] After - Test Case
Created attachment 276975 [details] [IMAGE] After - Eval Code console messages with/without sourceURL name
Attachment 276973 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/inspector/ScriptCallFrame.h:44: The parameter name "sourceID" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 22 files If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 276973 [details] [PATCH] Proposed Fix r=me
Comment on attachment 276973 [details] [PATCH] Proposed Fix Clearing flags on attachment: 276973 Committed r199852: <http://trac.webkit.org/changeset/199852>
All reviewed patches have been landed. Closing bug.