Changeset 235452 in webkit


Ignore:
Timestamp:
Aug 28, 2018 6:36:36 PM (6 years ago)
Author:
Devin Rousso
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r235449 r235452  
     12018-08-28  Devin Rousso  <drousso@apple.com>
     2
     3        console.log() shows (anonymous function) instead of the passed string when a certain format is used
     4        https://bugs.webkit.org/show_bug.cgi?id=188946
     5        <rdar://problem/43756428>
     6
     7        Reviewed by Brian Burg.
     8
     9        * inspector/console/js-isLikelyStackTrace-expected.txt:
     10        * inspector/console/js-isLikelyStackTrace.html:
     11
    1122018-08-28  Truitt Savell  <tsavell@apple.com>
    213
  • trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt

    r231717 r235452  
    1919    Actual: false
    2020
     21-- Running test case: testFormattedStrings
     22PASS: "video:1:2" should not be a stacktrace.
     23PASS: "video/mp4:1:2" should not be a stacktrace.
     24PASS: "video/mp4 : 11:22:33-44:55:66" should not be a stacktrace.
     25PASS: "http://video:1:2" should not be a stacktrace.
     26PASS: "http://video/mp4:1:2" should not be a stacktrace.
     27PASS: "http://video/mp4 : 11:22:33-44:55:66" should not be a stacktrace.
     28
  • trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html

    r225950 r235452  
    9696    });
    9797
     98    suite.addTestCase({
     99        name: "testFormattedStrings",
     100        test(resolve, reject) {
     101            const strings = [
     102                "video:1:2",
     103                "video/mp4:1:2",
     104                "video/mp4 : 11:22:33-44:55:66",
     105                "http://video:1:2",
     106                "http://video/mp4:1:2",
     107                "http://video/mp4 : 11:22:33-44:55:66",
     108            ];
     109           
     110            for (let string of strings)
     111                InspectorTest.expectThat(!WI.StackTrace.isLikelyStackTrace(string), `"${string}" should not be a stacktrace.`);
     112
     113            resolve();
     114        }
     115    });
     116
    98117    suite.runTestCasesAndFinish();
    99118}
  • trunk/Source/WebInspectorUI/ChangeLog

    r235451 r235452  
     12018-08-28  Devin Rousso  <drousso@apple.com>
     2
     3        console.log() shows (anonymous function) instead of the passed string when a certain format is used
     4        https://bugs.webkit.org/show_bug.cgi?id=188946
     5        <rdar://problem/43756428>
     6
     7        Reviewed by Brian Burg.
     8
     9        Stack trace URLs are much more likely to follow the following format:
     10
     11            <protocol>://<path>:<line>:<column>
     12
     13        Modify the test regexp to always require that a protocol exists and to check that there are
     14        no ":" inside the protocol or path. Additionally, stack traces usually have more than one
     15        frame, so return false if there isn't more than one line.
     16
     17        * UserInterface/Models/StackTrace.js:
     18        (WI.StackTrace.isLikelyStackTrace):
     19
    1202018-08-28  Devin Rousso  <drousso@apple.com>
    221
  • trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js

    r220119 r235452  
    8181            return false;
    8282
     83        const reasonablyLongProtocolLength = 10;
    8384        const reasonablyLongLineLength = 500;
    8485        const reasonablyLongNativeMethodLength = 120;
    85         const stackTraceLine = `(.{1,${reasonablyLongLineLength}}:\\d+:\\d+|eval code|.{1,${reasonablyLongNativeMethodLength}}@\\[native code\\])`;
    86         const stackTrace = new RegExp(`^${stackTraceLine}(\\n${stackTraceLine})*$`, "g");
    87 
     86        const stackTraceLine = `(global code|eval code|module code|\\w+)?([^:]{1,${reasonablyLongProtocolLength}}://[^:]{1,${reasonablyLongLineLength}}:\\d+:\\d+|[^@]{1,${reasonablyLongNativeMethodLength}}@\\[native code\\])`;
     87        const stackTrace = new RegExp(`^${stackTraceLine}([\\n\\r]${stackTraceLine})+$`, "g");
    8888        return stackTrace.test(stack);
    8989    }
Note: See TracChangeset for help on using the changeset viewer.