Title: [190780] trunk
Revision
190780
Author
[email protected]
Date
2015-10-08 23:01:30 -0700 (Thu, 08 Oct 2015)

Log Message

Web Inspector: Stack trace view doesn't properly display lines without function names
https://bugs.webkit.org/show_bug.cgi?id=149922

Source/WebInspectorUI:

Reviewed by Timothy Hatcher.

* UserInterface/Models/StackTrace.js:
(WebInspector.StackTrace._parseStackTrace):
(WebInspector.StackTrace._parseLocation): Added.

LayoutTests:

Test an anomymous function.

Reviewed by Timothy Hatcher.

* inspector/debugger/js-stacktrace-expected.txt: Also, rebaseline one old test.
* inspector/debugger/js-stacktrace.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (190779 => 190780)


--- trunk/LayoutTests/ChangeLog	2015-10-09 05:53:12 UTC (rev 190779)
+++ trunk/LayoutTests/ChangeLog	2015-10-09 06:01:30 UTC (rev 190780)
@@ -1,3 +1,15 @@
+2015-10-08  Nikita Vasilyev  <[email protected]>
+
+        Web Inspector: Stack trace view doesn't properly display lines without function names
+        https://bugs.webkit.org/show_bug.cgi?id=149922
+
+        Test an anomymous function.
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/debugger/js-stacktrace-expected.txt: Also, rebaseline one old test.
+        * inspector/debugger/js-stacktrace.html:
+
 2015-10-08  Brian Burg  <[email protected]>
 
         http/tests/media/media-source/SourceBuffer-abort-updating.html is flaky

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


--- trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt	2015-10-09 05:53:12 UTC (rev 190779)
+++ trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt	2015-10-09 06:01:30 UTC (rev 190780)
@@ -71,8 +71,24 @@
     {
         "functionName": "testWithNativeCallInBetween",
         "url": "/inspector/debugger/js-stacktrace.html",
-        "lineNumber": "23",
-        "columnNumber": "20"
+        "lineNumber": 23,
+        "columnNumber": 20
     }
 ]
 
+Error object:
+[
+    {
+        "functionName": "",
+        "url": "/inspector/debugger/js-stacktrace.html",
+        "lineNumber": 31,
+        "columnNumber": 33
+    },
+    {
+        "functionName": "global code",
+        "url": "/inspector/debugger/js-stacktrace.html",
+        "lineNumber": 35,
+        "columnNumber": 3
+    }
+]
+

Modified: trunk/LayoutTests/inspector/debugger/js-stacktrace.html (190779 => 190780)


--- trunk/LayoutTests/inspector/debugger/js-stacktrace.html	2015-10-09 05:53:12 UTC (rev 190779)
+++ trunk/LayoutTests/inspector/debugger/js-stacktrace.html	2015-10-09 06:01:30 UTC (rev 190780)
@@ -23,7 +23,22 @@
     return [42].map(typeError)[0];
 }
 
+var _anonymousFunctionError = null;
 
+(function() {
+    var object = {};
+    try {
+        object.methodDoesntExist();
+    } catch (e) {
+        _anonymousFunctionError = e.stack;
+    }
+})();
+
+function getAnonymousFunctionError() {
+    return _anonymousFunctionError;
+}
+
+
 function test()
 {
     WebInspector.logManager.addEventListener(WebInspector.LogManager.Event.MessageAdded, function(event) {
@@ -71,6 +86,19 @@
         InspectorTest.completeTest();
     });
 
+    InspectorTest.evaluateInPage("getAnonymousFunctionError()", function(error, result) {
+        InspectorTest.log("\nError object:");
+
+        if (error)
+            InspectorTest.log(error);
+
+        var stackTrace = stripPayloadAfterEval(WebInspector.StackTrace._parseStackTrace(result.value));
+        stackTrace = stripFilePaths(stackTrace);
+
+        InspectorTest.log(JSON.stringify(stackTrace, null, 4));
+        InspectorTest.completeTest();
+    });
+
     function stripFilePaths(stackTrace)
     {
         for (var frame of stackTrace) {

Modified: trunk/Source/WebInspectorUI/ChangeLog (190779 => 190780)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-10-09 05:53:12 UTC (rev 190779)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-10-09 06:01:30 UTC (rev 190780)
@@ -1,5 +1,16 @@
 2015-10-08  Nikita Vasilyev  <[email protected]>
 
+        Web Inspector: Stack trace view doesn't properly display lines without function names
+        https://bugs.webkit.org/show_bug.cgi?id=149922
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/StackTrace.js:
+        (WebInspector.StackTrace._parseStackTrace):
+        (WebInspector.StackTrace._parseLocation): Added.
+
+2015-10-08  Nikita Vasilyev  <[email protected]>
+
         Web Inspector: An error view doesn't get expanded by clicking on the expand arrow
         https://bugs.webkit.org/show_bug.cgi?id=149917
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js (190779 => 190780)


--- trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js	2015-10-09 05:53:12 UTC (rev 190779)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js	2015-10-09 06:01:30 UTC (rev 190780)
@@ -58,24 +58,14 @@
             var url = ""
             var lineNumber = 0;
             var columnNumber = 0;
+            var atIndex = line.indexOf("@");
 
-            var index = line.indexOf("@");
-            if (index !== -1) {
-                functionName = line.slice(0, index);
-                url = "" + 1);
-
-                var columnIndex = url.lastIndexOf(":");
-                if (columnIndex !== -1) {
-                    columnNumber = parseInt(url.slice(columnIndex + 1));
-
-                    url = "" columnIndex);
-                    var lineIndex = url.lastIndexOf(":", columnIndex);
-                    if (lineIndex !== -1) {
-                        lineNumber = parseInt(url.slice(lineIndex + 1, columnIndex));
-                        url = "" lineIndex);
-                    }
-                }
-            } else
+            if (atIndex !== -1) {
+                functionName = line.slice(0, atIndex);
+                ({url, lineNumber, columnNumber} = WebInspector.StackTrace._parseLocation(line.slice(atIndex + 1)));
+            } else if (line.includes("/"))
+                ({url, lineNumber, columnNumber} = WebInspector.StackTrace._parseLocation(line));
+            else
                 functionName = line;
 
             result.push({functionName, url, lineNumber, columnNumber});
@@ -84,6 +74,26 @@
         return result;
     }
 
+    static _parseLocation(locationString)
+    {
+        var result = {url: "", lineNumber: 0, columnNumber: 0};
+        var locationRegEx = /(.+?)(?::(\d+)(?::(\d+))?)?$/;
+        var matched = locationString.match(locationRegEx);
+
+        if (!matched)
+            return result;
+
+        result.url = ""
+
+        if (matched[2])
+            result.lineNumber = parseInt(matched[2]);
+
+        if (matched[3])
+            result.columnNumber = parseInt(matched[3]);
+
+        return result;
+    }
+
     // Public
 
     get callFrames()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to