Title: [235452] trunk
Revision
235452
Author
drou...@apple.com
Date
2018-08-28 18:36:36 -0700 (Tue, 28 Aug 2018)

Log Message

console.log() shows (anonymous function) instead of the passed string when a certain format is used
https://bugs.webkit.org/show_bug.cgi?id=188946
<rdar://problem/43756428>

Reviewed by Brian Burg.

Source/WebInspectorUI:

Stack trace URLs are much more likely to follow the following format:

    <protocol>://<path>:<line>:<column>

Modify the test regexp to always require that a protocol exists and to check that there are
no ":" inside the protocol or path. Additionally, stack traces usually have more than one
frame, so return false if there isn't more than one line.

* UserInterface/Models/StackTrace.js:
(WI.StackTrace.isLikelyStackTrace):

LayoutTests:

* inspector/console/js-isLikelyStackTrace-expected.txt:
* inspector/console/js-isLikelyStackTrace.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (235451 => 235452)


--- trunk/LayoutTests/ChangeLog	2018-08-29 00:06:40 UTC (rev 235451)
+++ trunk/LayoutTests/ChangeLog	2018-08-29 01:36:36 UTC (rev 235452)
@@ -1,3 +1,14 @@
+2018-08-28  Devin Rousso  <drou...@apple.com>
+
+        console.log() shows (anonymous function) instead of the passed string when a certain format is used
+        https://bugs.webkit.org/show_bug.cgi?id=188946
+        <rdar://problem/43756428>
+
+        Reviewed by Brian Burg.
+
+        * inspector/console/js-isLikelyStackTrace-expected.txt:
+        * inspector/console/js-isLikelyStackTrace.html:
+
 2018-08-28  Truitt Savell  <tsav...@apple.com>
 
         Edditing test expectations from webkit.org/b/188985.

Modified: trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt (235451 => 235452)


--- trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt	2018-08-29 00:06:40 UTC (rev 235451)
+++ trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt	2018-08-29 01:36:36 UTC (rev 235452)
@@ -18,3 +18,11 @@
     Expected: truthy
     Actual: false
 
+-- Running test case: testFormattedStrings
+PASS: "video:1:2" should not be a stacktrace.
+PASS: "video/mp4:1:2" should not be a stacktrace.
+PASS: "video/mp4 : 11:22:33-44:55:66" should not be a stacktrace.
+PASS: "http://video:1:2" should not be a stacktrace.
+PASS: "http://video/mp4:1:2" should not be a stacktrace.
+PASS: "http://video/mp4 : 11:22:33-44:55:66" should not be a stacktrace.
+

Modified: trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html (235451 => 235452)


--- trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html	2018-08-29 00:06:40 UTC (rev 235451)
+++ trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html	2018-08-29 01:36:36 UTC (rev 235452)
@@ -95,6 +95,25 @@
         }
     });
 
+    suite.addTestCase({
+        name: "testFormattedStrings",
+        test(resolve, reject) {
+            const strings = [
+                "video:1:2",
+                "video/mp4:1:2",
+                "video/mp4 : 11:22:33-44:55:66",
+                "http://video:1:2",
+                "http://video/mp4:1:2",
+                "http://video/mp4 : 11:22:33-44:55:66",
+            ];
+            
+            for (let string of strings)
+                InspectorTest.expectThat(!WI.StackTrace.isLikelyStackTrace(string), `"${string}" should not be a stacktrace.`);
+
+            resolve();
+        }
+    });
+
     suite.runTestCasesAndFinish();
 }
 </script>

Modified: trunk/Source/WebInspectorUI/ChangeLog (235451 => 235452)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-08-29 00:06:40 UTC (rev 235451)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-08-29 01:36:36 UTC (rev 235452)
@@ -1,5 +1,24 @@
 2018-08-28  Devin Rousso  <drou...@apple.com>
 
+        console.log() shows (anonymous function) instead of the passed string when a certain format is used
+        https://bugs.webkit.org/show_bug.cgi?id=188946
+        <rdar://problem/43756428>
+
+        Reviewed by Brian Burg.
+
+        Stack trace URLs are much more likely to follow the following format:
+
+            <protocol>://<path>:<line>:<column>
+
+        Modify the test regexp to always require that a protocol exists and to check that there are
+        no ":" inside the protocol or path. Additionally, stack traces usually have more than one
+        frame, so return false if there isn't more than one line.
+
+        * UserInterface/Models/StackTrace.js:
+        (WI.StackTrace.isLikelyStackTrace):
+
+2018-08-28  Devin Rousso  <drou...@apple.com>
+
         Web Inspector: REGRESSION: CanvasSidebarPanel is empty for imported recordings
         https://bugs.webkit.org/show_bug.cgi?id=189061
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js (235451 => 235452)


--- trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js	2018-08-29 00:06:40 UTC (rev 235451)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js	2018-08-29 01:36:36 UTC (rev 235452)
@@ -80,11 +80,11 @@
         if (/^[^a-z$_]/i.test(stack[0]))
             return false;
 
+        const reasonablyLongProtocolLength = 10;
         const reasonablyLongLineLength = 500;
         const reasonablyLongNativeMethodLength = 120;
-        const stackTraceLine = `(.{1,${reasonablyLongLineLength}}:\\d+:\\d+|eval code|.{1,${reasonablyLongNativeMethodLength}}@\\[native code\\])`;
-        const stackTrace = new RegExp(`^${stackTraceLine}(\\n${stackTraceLine})*$`, "g");
-
+        const stackTraceLine = `(global code|eval code|module code|\\w+)?([^:]{1,${reasonablyLongProtocolLength}}://[^:]{1,${reasonablyLongLineLength}}:\\d+:\\d+|[^@]{1,${reasonablyLongNativeMethodLength}}@\\[native code\\])`;
+        const stackTrace = new RegExp(`^${stackTraceLine}([\\n\\r]${stackTraceLine})+$`, "g");
         return stackTrace.test(stack);
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to