Title: [199852] trunk
Revision
199852
Author
[email protected]
Date
2016-04-21 17:50:09 -0700 (Thu, 21 Apr 2016)

Log Message

Web Inspector: sourceMappingURL not loaded in generated script
https://bugs.webkit.org/show_bug.cgi?id=156022
<rdar://problem/25438595>

Patch by Joseph Pecoraro <[email protected]> on 2016-04-21
Reviewed by Geoffrey Garen.

Source/_javascript_Core:

* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace):
Synthetic CallFrames for native code will not have script identifiers.

* inspector/ScriptCallFrame.cpp:
(Inspector::ScriptCallFrame::ScriptCallFrame):
(Inspector::ScriptCallFrame::isEqual):
(Inspector::ScriptCallFrame::buildInspectorObject):
* inspector/ScriptCallFrame.h:
* inspector/protocol/Console.json:
Include the script identifier in ScriptCallFrame so we can correlate this
to the exactly script, even if there isn't a URL. The Script may have a
sourceURL, so the Web Inspector frontend may decide to show / link to it.

* inspector/ScriptCallStackFactory.cpp:
(Inspector::CreateScriptCallStackFunctor::operator()):
(Inspector::createScriptCallStackFromException):
Include SourceID when we have it.

* interpreter/Interpreter.cpp:
(JSC::GetStackTraceFunctor::operator()):
* interpreter/Interpreter.h:
* interpreter/StackVisitor.cpp:
(JSC::StackVisitor::Frame::sourceID):
* interpreter/StackVisitor.h:
Access the SourceID when we have it.

Source/WebInspectorUI:

* UserInterface/Controllers/SourceMapManager.js:
(WebInspector.SourceMapManager.prototype.downloadSourceMap):
If the sourceMapURL is a dataURL at this point, we can just pass it on,
otherwise we would have returned and skipped it.

* UserInterface/Models/CallFrame.js:
(WebInspector.CallFrame.fromPayload):
Add handling for "scriptId" if it is available in the Console.CallFrame.
Don't automatically mark CallFrames that didn't have a "url" as native,
instead try to get a SourceCode.

* UserInterface/Models/Script.js:
(WebInspector.Script.prototype.get displayURL):
Used by SourceCodeLocation formatting, so behave more like Resources
when we have only have a sourceURL name. This produces output like:
"foo.js:#:#" instead of "foo.js (line #:#)"

(WebInspector.Script.prototype.get anonymous):
Easy accessor to see if this would be treated as anonymous or not.

* UserInterface/Models/SourceMap.js:
(WebInspector.SourceMap.prototype.get sourceMappingBasePathURLComponents):
Gracefully handle no path.

* UserInterface/Models/StackTrace.js:
(WebInspector.StackTrace.prototype.get firstNonNativeCallFrame):
(WebInspector.StackTrace.prototype.get firstNonNativeNonAnonymousCallFrame):
* UserInterface/Views/ConsoleMessageView.js:
(WebInspector.ConsoleMessageView.prototype._appendLocationLink):
Now that "Eval Code" with a sourceURL is no longer native, we still don't
want to show it in the Web Inspector if it is anonymous. So include a stricter
version that skips native and anonymous call frames.

LayoutTests:

* inspector/console/messageAdded-from-named-evaluations-expected.txt: Added.
* inspector/console/messageAdded-from-named-evaluations.html: Added.
* inspector/debugger/js-stacktrace-expected.txt:
* inspector/model/stack-trace-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (199851 => 199852)


--- trunk/LayoutTests/ChangeLog	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/LayoutTests/ChangeLog	2016-04-22 00:50:09 UTC (rev 199852)
@@ -1,3 +1,16 @@
+2016-04-21  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: sourceMappingURL not loaded in generated script
+        https://bugs.webkit.org/show_bug.cgi?id=156022
+        <rdar://problem/25438595>
+
+        Reviewed by Geoffrey Garen.
+
+        * inspector/console/messageAdded-from-named-evaluations-expected.txt: Added.
+        * inspector/console/messageAdded-from-named-evaluations.html: Added.
+        * inspector/debugger/js-stacktrace-expected.txt:
+        * inspector/model/stack-trace-expected.txt:
+
 2016-04-21  Simon Fraser  <[email protected]>
 
         ASSERTION FAILED: accumulation == TransformState::FlattenTransform in WebCore::GraphicsLayerCA::computeVisibleAndCoverageRect

Added: trunk/LayoutTests/inspector/console/messageAdded-from-named-evaluations-expected.txt (0 => 199852)


--- trunk/LayoutTests/inspector/console/messageAdded-from-named-evaluations-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/messageAdded-from-named-evaluations-expected.txt	2016-04-22 00:50:09 UTC (rev 199852)
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 2: inside named-eval.js
+CONSOLE MESSAGE: line 3: TypeError: undefined is not an object (evaluating '({}).x.x')
+Console messages in named evaluations should have call frames with the correct name.
+
+
+== Running test suite: Console.messageAdded.messageFromNamedEvaluations
+-- Running test case: TriggerMessageFromNameEvaluation
+PASS: Log ConsoleMessage top call frame should have sourceURL name.
+
+-- Running test case: TriggerExceptionFromNameFunctionConstructorEvaluation
+Uncaught exception in test page: TypeError: undefined is not an object (evaluating '({}).x.x') [undefined:3]
+PASS: Exception ConsoleMessage top call frame should have sourceURL name.
+

Added: trunk/LayoutTests/inspector/console/messageAdded-from-named-evaluations.html (0 => 199852)


--- trunk/LayoutTests/inspector/console/messageAdded-from-named-evaluations.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/messageAdded-from-named-evaluations.html	2016-04-22 00:50:09 UTC (rev 199852)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+TestPage.allowUncaughtExceptions = true;
+
+function triggerMessageFromNamedEvaluation() {
+    eval("//# sourceURL=named-eval.js\nconsole.log('inside named-eval.js')");
+}
+
+function triggerExceptionFromNamedFunctionConstructorEvaluation() {
+    Function("//# sourceURL=named-function-constructor.js\n({}).x.x")();
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Console.messageAdded.messageFromNamedEvaluations");
+
+    suite.addTestCase({
+        name: "TriggerMessageFromNameEvaluation",
+        description: "Message from named evaluation should have a source location.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("triggerMessageFromNamedEvaluation()");
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+                let message = event.data.message;
+                let topCallFrame = message.stackTrace.callFrames[0];
+                InspectorTest.expectThat(topCallFrame.sourceCodeLocation.sourceCode.displayName === "named-eval.js", "Log ConsoleMessage top call frame should have sourceURL name.");
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "TriggerExceptionFromNameFunctionConstructorEvaluation",
+        description: "Exception message from named Function constructor evaluation should have a source location.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("setTimeout(triggerExceptionFromNamedFunctionConstructorEvaluation)");
+            WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+                let message = event.data.message;
+                let topCallFrame = message.stackTrace.callFrames[0];
+                InspectorTest.expectThat(topCallFrame.sourceCodeLocation.sourceCode.displayName === "named-function-constructor.js", "Exception ConsoleMessage top call frame should have sourceURL name.");
+                resolve();
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Console messages in named evaluations should have call frames with the correct name.</p>
+</body>
+</html>

Modified: trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt (199851 => 199852)


--- trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt	2016-04-22 00:50:09 UTC (rev 199852)
@@ -17,10 +17,10 @@
         "programCode": false
     },
     {
-        "lineNumber": null,
-        "columnNumber": null,
+        "lineNumber": 0,
+        "columnNumber": 14,
         "functionName": "Eval Code",
-        "nativeCode": true,
+        "nativeCode": false,
         "programCode": true
     }
 ]
@@ -71,10 +71,10 @@
         "programCode": false
     },
     {
-        "lineNumber": null,
-        "columnNumber": null,
+        "lineNumber": 0,
+        "columnNumber": 28,
         "functionName": "Eval Code",
-        "nativeCode": true,
+        "nativeCode": false,
         "programCode": true
     }
 ]

Modified: trunk/LayoutTests/inspector/model/stack-trace-expected.txt (199851 => 199852)


--- trunk/LayoutTests/inspector/model/stack-trace-expected.txt	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/LayoutTests/inspector/model/stack-trace-expected.txt	2016-04-22 00:50:09 UTC (rev 199852)
@@ -9,15 +9,15 @@
 PASS: CallFrame in StackTrace has no thisObject.
 PASS: CallFrame in StackTrace has no scopeChain.
 StackTrace: 11
-  1: foo - nativeCode (true) programCode (false)
-  2: Eval Code - nativeCode (true) programCode (true)
+  1: foo (Anonymous Script 1 (line 1)) - nativeCode (false) programCode (false)
+  2: Eval Code (Anonymous Script 1 (line 1)) - nativeCode (false) programCode (true)
   3: eval - nativeCode (true) programCode (false)
   4: Global Code (stack-trace.html:2) - nativeCode (false) programCode (true)
   5: appendChild - nativeCode (true) programCode (false)
   6: triggerConsoleMessage (stack-trace.html:9) - nativeCode (false) programCode (false)
-  7: Eval Code - nativeCode (true) programCode (true)
+  7: Eval Code (Anonymous Script 2 (line 1)) - nativeCode (false) programCode (true)
   8: eval - nativeCode (true) programCode (false)
-  9: _evaluateOn - nativeCode (true) programCode (false)
-  10: _evaluateAndWrap - nativeCode (true) programCode (false)
-  11: evaluate - nativeCode (true) programCode (false)
+  9: _evaluateOn (__WebInspectorInjectedScript__:115) - nativeCode (false) programCode (false)
+  10: _evaluateAndWrap (__WebInspectorInjectedScript__:93:106) - nativeCode (false) programCode (false)
+  11: evaluate (__WebInspectorInjectedScript__:83) - nativeCode (false) programCode (false)
 

Modified: trunk/Source/_javascript_Core/ChangeLog (199851 => 199852)


--- trunk/Source/_javascript_Core/ChangeLog	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-04-22 00:50:09 UTC (rev 199852)
@@ -1,3 +1,38 @@
+2016-04-21  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: sourceMappingURL not loaded in generated script
+        https://bugs.webkit.org/show_bug.cgi?id=156022
+        <rdar://problem/25438595>
+
+        Reviewed by Geoffrey Garen.
+
+        * inspector/JSGlobalObjectInspectorController.cpp:
+        (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace):
+        Synthetic CallFrames for native code will not have script identifiers.
+
+        * inspector/ScriptCallFrame.cpp:
+        (Inspector::ScriptCallFrame::ScriptCallFrame):
+        (Inspector::ScriptCallFrame::isEqual):
+        (Inspector::ScriptCallFrame::buildInspectorObject):
+        * inspector/ScriptCallFrame.h:
+        * inspector/protocol/Console.json:
+        Include the script identifier in ScriptCallFrame so we can correlate this
+        to the exactly script, even if there isn't a URL. The Script may have a
+        sourceURL, so the Web Inspector frontend may decide to show / link to it.
+
+        * inspector/ScriptCallStackFactory.cpp:
+        (Inspector::CreateScriptCallStackFunctor::operator()):
+        (Inspector::createScriptCallStackFromException):
+        Include SourceID when we have it.
+
+        * interpreter/Interpreter.cpp:
+        (JSC::GetStackTraceFunctor::operator()):
+        * interpreter/Interpreter.h:
+        * interpreter/StackVisitor.cpp:
+        (JSC::StackVisitor::Frame::sourceID):
+        * interpreter/StackVisitor.h:
+        Access the SourceID when we have it.
+
 2016-04-21  Saam barati  <[email protected]>
 
         Lets do less locking of symbol tables in the BytecodeGenerator where we don't have race conditions

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp (199851 => 199852)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2016-04-22 00:50:09 UTC (rev 199852)
@@ -207,9 +207,9 @@
         if (mangledName)
             cxaDemangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, nullptr);
         if (mangledName || cxaDemangled)
-            callStack->append(ScriptCallFrame(cxaDemangled ? cxaDemangled : mangledName, ASCIILiteral("[native code]"), 0, 0));
+            callStack->append(ScriptCallFrame(cxaDemangled ? cxaDemangled : mangledName, ASCIILiteral("[native code]"), noSourceID, 0, 0));
         else
-            callStack->append(ScriptCallFrame(ASCIILiteral("?"), ASCIILiteral("[native code]"), 0, 0));
+            callStack->append(ScriptCallFrame(ASCIILiteral("?"), ASCIILiteral("[native code]"), noSourceID, 0, 0));
         free(cxaDemangled);
     }
 #else

Modified: trunk/Source/_javascript_Core/inspector/ScriptCallFrame.cpp (199851 => 199852)


--- trunk/Source/_javascript_Core/inspector/ScriptCallFrame.cpp	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/inspector/ScriptCallFrame.cpp	2016-04-22 00:50:09 UTC (rev 199852)
@@ -36,9 +36,10 @@
 
 namespace Inspector {
 
-ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& scriptName, unsigned lineNumber, unsigned column)
+ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& scriptName, JSC::SourceID sourceID, unsigned lineNumber, unsigned column)
     : m_functionName(functionName)
     , m_scriptName(scriptName)
+    , m_sourceID(sourceID)
     , m_lineNumber(lineNumber)
     , m_column(column)
 {
@@ -50,6 +51,8 @@
 
 bool ScriptCallFrame::isEqual(const ScriptCallFrame& o) const
 {
+    // Ignore sourceID in isEqual in case of identical scripts executed multiple times
+    // that would get different script identifiers, but are otherwise the same.
     return m_functionName == o.m_functionName
         && m_scriptName == o.m_scriptName
         && m_lineNumber == o.m_lineNumber
@@ -61,6 +64,7 @@
     return Inspector::Protocol::Console::CallFrame::create()
         .setFunctionName(m_functionName)
         .setUrl(m_scriptName)
+        .setScriptId(String::number(m_sourceID))
         .setLineNumber(m_lineNumber)
         .setColumnNumber(m_column)
         .release();

Modified: trunk/Source/_javascript_Core/inspector/ScriptCallFrame.h (199851 => 199852)


--- trunk/Source/_javascript_Core/inspector/ScriptCallFrame.h	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/inspector/ScriptCallFrame.h	2016-04-22 00:50:09 UTC (rev 199852)
@@ -32,21 +32,23 @@
 #ifndef ScriptCallFrame_h
 #define ScriptCallFrame_h
 
+#include "DebuggerPrimitives.h"
+#include "InspectorProtocolObjects.h"
 #include <wtf/Forward.h>
 #include <wtf/text/WTFString.h>
-#include "InspectorProtocolObjects.h"
 
 namespace Inspector {
 
 class JS_EXPORT_PRIVATE ScriptCallFrame  {
 public:
-    ScriptCallFrame(const String& functionName, const String& scriptName, unsigned lineNumber, unsigned column);
+    ScriptCallFrame(const String& functionName, const String& scriptName, JSC::SourceID sourceID, unsigned lineNumber, unsigned column);
     ~ScriptCallFrame();
 
     const String& functionName() const { return m_functionName; }
     const String& sourceURL() const { return m_scriptName; }
     unsigned lineNumber() const { return m_lineNumber; }
     unsigned columnNumber() const { return m_column; }
+    JSC::SourceID sourceID() const { return m_sourceID; }
 
     bool isEqual(const ScriptCallFrame&) const;
 
@@ -55,6 +57,7 @@
 private:
     String m_functionName;
     String m_scriptName;
+    JSC::SourceID m_sourceID;
     unsigned m_lineNumber;
     unsigned m_column;
 };

Modified: trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp (199851 => 199852)


--- trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/inspector/ScriptCallStackFactory.cpp	2016-04-22 00:50:09 UTC (rev 199852)
@@ -74,7 +74,7 @@
             unsigned line;
             unsigned column;
             visitor->computeLineAndColumn(line, column);
-            m_frames.append(ScriptCallFrame(visitor->functionName(), visitor->sourceURL(), line, column));
+            m_frames.append(ScriptCallFrame(visitor->functionName(), visitor->sourceURL(), static_cast<SourceID>(visitor->sourceID()), line, column));
 
             m_remainingCapacityForFrameCapture--;
             return StackVisitor::Continue;
@@ -143,7 +143,7 @@
         unsigned column;
         stackTrace[i].computeLineAndColumn(line, column);
         String functionName = stackTrace[i].friendlyFunctionName(exec);
-        frames.append(ScriptCallFrame(functionName, stackTrace[i].friendlySourceURL(), line, column));
+        frames.append(ScriptCallFrame(functionName, stackTrace[i].friendlySourceURL(), static_cast<SourceID>(stackTrace[i].sourceID), line, column));
     }
 
     // Fallback to getting at least the line and sourceURL from the exception object if it has values and the exceptionStack doesn't.
@@ -155,12 +155,12 @@
         String exceptionSourceURL;
         if (!frames.size()) {
             extractSourceInformationFromException(exec, exceptionObject, &lineNumber, &columnNumber, &exceptionSourceURL);
-            frames.append(ScriptCallFrame(String(), exceptionSourceURL, lineNumber, columnNumber));
+            frames.append(ScriptCallFrame(String(), exceptionSourceURL, noSourceID, lineNumber, columnNumber));
         } else {
             if (stackTrace[0].sourceURL.isEmpty()) {
                 const ScriptCallFrame& firstCallFrame = frames.first();
                 extractSourceInformationFromException(exec, exceptionObject, &lineNumber, &columnNumber, &exceptionSourceURL);
-                frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, lineNumber, columnNumber);
+                frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, stackTrace[0].sourceID, lineNumber, columnNumber);
             }
         }
     }

Modified: trunk/Source/_javascript_Core/inspector/protocol/Console.json (199851 => 199852)


--- trunk/Source/_javascript_Core/inspector/protocol/Console.json	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/inspector/protocol/Console.json	2016-04-22 00:50:09 UTC (rev 199852)
@@ -27,6 +27,7 @@
             "properties": [
                 { "name": "functionName", "type": "string", "description": "_javascript_ function name." },
                 { "name": "url", "type": "string", "description": "_javascript_ script name or url." },
+                { "name": "scriptId", "$ref": "Debugger.ScriptId", "description": "Script identifier." },
                 { "name": "lineNumber", "type": "integer", "description": "_javascript_ script line number." },
                 { "name": "columnNumber", "type": "integer", "description": "_javascript_ script column number." }
             ]

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (199851 => 199852)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2016-04-22 00:50:09 UTC (rev 199852)
@@ -561,11 +561,12 @@
                     codeBlock->firstLineColumnOffset(),
                     codeBlock->sourceOffset(),
                     visitor->bytecodeOffset(),
-                    visitor->sourceURL()
+                    visitor->sourceURL(),
+                    visitor->sourceID(),
                 };
                 m_results.append(s);
             } else {
-                StackFrame s = { Strong<JSObject>(vm, visitor->callee()), StackFrameNativeCode, Strong<ScriptExecutable>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, 0, String()};
+                StackFrame s = { Strong<JSObject>(vm, visitor->callee()), StackFrameNativeCode, Strong<ScriptExecutable>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, 0, String(), noSourceID};
                 m_results.append(s);
             }
     

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.h (199851 => 199852)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.h	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.h	2016-04-22 00:50:09 UTC (rev 199852)
@@ -94,6 +94,7 @@
         unsigned characterOffset;
         unsigned bytecodeOffset;
         String sourceURL;
+        intptr_t sourceID;
         JS_EXPORT_PRIVATE String toString(CallFrame*);
         String friendlySourceURL() const;
         String friendlyFunctionName(CallFrame*) const;

Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp (199851 => 199852)


--- trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp	2016-04-22 00:50:09 UTC (rev 199852)
@@ -27,6 +27,7 @@
 #include "StackVisitor.h"
 
 #include "ClonedArguments.h"
+#include "DebuggerPrimitives.h"
 #include "Executable.h"
 #include "InlineCallFrame.h"
 #include "Interpreter.h"
@@ -277,6 +278,13 @@
     return traceBuild.toString().impl();
 }
 
+intptr_t StackVisitor::Frame::sourceID()
+{
+    if (CodeBlock* codeBlock = this->codeBlock())
+        return codeBlock->ownerScriptExecutable()->sourceID();
+    return noSourceID;
+}
+
 ClonedArguments* StackVisitor::Frame::createArguments()
 {
     ASSERT(m_callFrame);

Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.h (199851 => 199852)


--- trunk/Source/_javascript_Core/interpreter/StackVisitor.h	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.h	2016-04-22 00:50:09 UTC (rev 199852)
@@ -78,6 +78,8 @@
         JS_EXPORT_PRIVATE String sourceURL();
         JS_EXPORT_PRIVATE String toString();
 
+        intptr_t sourceID();
+
         CodeType codeType() const;
         JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned& line, unsigned& column);
 

Modified: trunk/Source/WebInspectorUI/ChangeLog (199851 => 199852)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-04-22 00:50:09 UTC (rev 199852)
@@ -1,5 +1,46 @@
 2016-04-21  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: sourceMappingURL not loaded in generated script
+        https://bugs.webkit.org/show_bug.cgi?id=156022
+        <rdar://problem/25438595>
+
+        Reviewed by Geoffrey Garen.
+
+        * UserInterface/Controllers/SourceMapManager.js:
+        (WebInspector.SourceMapManager.prototype.downloadSourceMap):
+        If the sourceMapURL is a dataURL at this point, we can just pass it on,
+        otherwise we would have returned and skipped it.
+        
+        * UserInterface/Models/CallFrame.js:
+        (WebInspector.CallFrame.fromPayload):
+        Add handling for "scriptId" if it is available in the Console.CallFrame.
+        Don't automatically mark CallFrames that didn't have a "url" as native,
+        instead try to get a SourceCode.
+
+        * UserInterface/Models/Script.js:
+        (WebInspector.Script.prototype.get displayURL):
+        Used by SourceCodeLocation formatting, so behave more like Resources
+        when we have only have a sourceURL name. This produces output like:
+        "foo.js:#:#" instead of "foo.js (line #:#)"
+
+        (WebInspector.Script.prototype.get anonymous):
+        Easy accessor to see if this would be treated as anonymous or not.
+
+        * UserInterface/Models/SourceMap.js:
+        (WebInspector.SourceMap.prototype.get sourceMappingBasePathURLComponents):
+        Gracefully handle no path.
+
+        * UserInterface/Models/StackTrace.js:
+        (WebInspector.StackTrace.prototype.get firstNonNativeCallFrame):
+        (WebInspector.StackTrace.prototype.get firstNonNativeNonAnonymousCallFrame):
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WebInspector.ConsoleMessageView.prototype._appendLocationLink):
+        Now that "Eval Code" with a sourceURL is no longer native, we still don't
+        want to show it in the Web Inspector if it is anonymous. So include a stricter
+        version that skips native and anonymous call frames.
+
+2016-04-21  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: Debugger statement gets a space after it when pretty printed
         https://bugs.webkit.org/show_bug.cgi?id=156867
         <rdar://problem/25862308>

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js (199851 => 199852)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js	2016-04-22 00:50:09 UTC (rev 199852)
@@ -49,6 +49,11 @@
         if (WebInspector.frameResourceManager.mainFrame)
             baseURL = absoluteURL(WebInspector.frameResourceManager.mainFrame.url, baseURL);
 
+        if (sourceMapURL.startsWith("data:")) {
+            this._loadAndParseSourceMap(sourceMapURL, baseURL, originalSourceCode);
+            return;
+        }
+
         sourceMapURL = absoluteURL(sourceMapURL, baseURL);
         if (!sourceMapURL)
             return;

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js (199851 => 199852)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CallFrame.js	2016-04-22 00:50:09 UTC (rev 199852)
@@ -140,24 +140,31 @@
     {
         console.assert(payload);
 
-        let url = ""
+        let {url, scriptId} = payload;
         let nativeCode = false;
         let sourceCodeLocation = null;
         let functionName = WebInspector.CallFrame.functionNameFromPayload(payload);
         let programCode = WebInspector.CallFrame.programCodeFromPayload(payload);
 
-        if (!url || url ="" "[native code]") {
+        if (url ="" "[native code]") {
             nativeCode = true;
             url = ""
-        } else {
+        } else if (url || scriptId) {
             let sourceCode = WebInspector.frameResourceManager.resourceForURL(url);
             if (!sourceCode)
                 sourceCode = WebInspector.debuggerManager.scriptsForURL(url)[0];
+            if (!sourceCode && scriptId)
+                sourceCode = WebInspector.debuggerManager.scriptForIdentifier(scriptId);
 
             if (sourceCode) {
                 // The lineNumber is 1-based, but we expect 0-based.
                 let lineNumber = payload.lineNumber - 1;
                 sourceCodeLocation = sourceCode.createLazySourceCodeLocation(lineNumber, payload.columnNumber);
+            } else {
+                // Treat this as native code if we were unable to find a source.
+                console.assert(!url, "We should have detected source code for something with a url");
+                nativeCode = true;
+                url = ""
             }
         }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Script.js (199851 => 199852)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Script.js	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Script.js	2016-04-22 00:50:09 UTC (rev 199852)
@@ -107,11 +107,28 @@
         return WebInspector.UIString("Anonymous Script %d").format(this._uniqueDisplayNameNumber);
     }
 
+    get displayURL()
+    {
+        const isMultiLine = true;
+        const dataURIMaxSize = 64;
+
+        if (this._url)
+            return WebInspector.truncateURL(this._url, isMultiLine, dataURIMaxSize);
+        if (this._sourceURL)
+            return WebInspector.truncateURL(this._sourceURL, isMultiLine, dataURIMaxSize);
+        return null;
+    }
+
     get injected()
     {
         return this._injected;
     }
 
+    get anonymous()
+    {
+        return !this._resource && !this._url && !this._sourceURL;
+    }
+
     get resource()
     {
         return this._resource;

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/SourceMap.js (199851 => 199852)


--- trunk/Source/WebInspectorUI/UserInterface/Models/SourceMap.js	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/SourceMap.js	2016-04-22 00:50:09 UTC (rev 199852)
@@ -77,7 +77,7 @@
 
         // Fallback for _javascript_ debuggable named scripts that may not have a complete URL.
         if (!urlComponents.path)
-            urlComponents.path = this._sourceMappingURL;
+            urlComponents.path = this._sourceMappingURL || "";
 
         urlComponents.path = urlComponents.path.substr(0, urlComponents.path.lastIndexOf(urlComponents.lastPathComponent));
         urlComponents.lastPathComponent = null;

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js (199851 => 199852)


--- trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js	2016-04-22 00:50:09 UTC (rev 199852)
@@ -128,11 +128,28 @@
 
     get firstNonNativeCallFrame()
     {
-        for (var frame of this._callFrames) {
+        for (let frame of this._callFrames) {
             if (!frame.nativeCode)
                 return frame;
         }
 
         return null;
     }
+
+    get firstNonNativeNonAnonymousCallFrame()
+    {
+        for (let frame of this._callFrames) {
+            if (frame.nativeCode)
+                continue;
+            if (frame.sourceCodeLocation) {
+                let sourceCode = frame.sourceCodeLocation.sourceCode;
+                if (sourceCode instanceof WebInspector.Script && sourceCode.anonymous)
+                    continue;
+            }
+            return frame;
+        }
+
+        return null;
+    }
+    
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (199851 => 199852)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2016-04-22 00:33:32 UTC (rev 199851)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2016-04-22 00:50:09 UTC (rev 199852)
@@ -314,12 +314,12 @@
             return;
         }
 
-        var firstNonNativeCallFrame = this._message.stackTrace.firstNonNativeCallFrame;
+        var firstNonNativeNonAnonymousCallFrame = this._message.stackTrace.firstNonNativeNonAnonymousCallFrame;
 
         var callFrame;
-        if (firstNonNativeCallFrame) {
+        if (firstNonNativeNonAnonymousCallFrame) {
             // _javascript_ errors and console.* methods.
-            callFrame = firstNonNativeCallFrame;
+            callFrame = firstNonNativeNonAnonymousCallFrame;
         } else if (this._message.url && !this._shouldHideURL(this._message.url)) {
             // CSS warnings have no stack traces.
             callFrame = WebInspector.CallFrame.fromPayload({
@@ -335,7 +335,6 @@
             var locationElement = new WebInspector.CallFrameView(callFrame, showFunctionName);
             locationElement.classList.add("console-message-location");
             this._element.appendChild(locationElement);
-
             return;
         }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to