Modified: trunk/LayoutTests/ChangeLog (235938 => 235939)
--- trunk/LayoutTests/ChangeLog 2018-09-12 16:20:36 UTC (rev 235938)
+++ trunk/LayoutTests/ChangeLog 2018-09-12 16:34:09 UTC (rev 235939)
@@ -1,3 +1,18 @@
+2018-09-12 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: fix test case failures in js-isLikelyStackTrace.html
+ https://bugs.webkit.org/show_bug.cgi?id=180664
+
+ Reviewed by Devin Rousso.
+
+ * inspector/console/js-isLikelyStackTrace-expected.txt:
+ * inspector/console/js-isLikelyStackTrace.html:
+ Avoid Inspector Internal InjectedScript code in backtraces by producing
+ the exception stacks in the page itself without going through inspector
+ test evaluation code. This produces exception stacks more like a page.
+ Also add some explicit tests for strings that we'd expect to be classified
+ as exception stacks.
+
2018-09-12 Per Arne Vollan <[email protected]>
Layout Test fast/text/variations/ipc2.html is failing
Modified: trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt (235938 => 235939)
--- trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt 2018-09-12 16:20:36 UTC (rev 235938)
+++ trunk/LayoutTests/inspector/console/js-isLikelyStackTrace-expected.txt 2018-09-12 16:34:09 UTC (rev 235939)
@@ -5,20 +5,21 @@
-- Running test case: notStacktrace
PASS: Should NOT be a stacktrace.
--- Running test case: typeErrorWrap
-FAIL: Should be a stacktrace.
- Expected: truthy
- Actual: false
+-- Running test case: WI.StackTrace.isLikelyStackTrace.TypeError
+PASS: Should be a stacktrace.
--- Running test case: getAnonymousFunctionError
+-- Running test case: WI.StackTrace.isLikelyStackTrace.AnonymousFunctionError
PASS: Should be a stacktrace.
--- Running test case: testWithNativeCallInBetween
-FAIL: Should be a stacktrace.
- Expected: truthy
- Actual: false
+-- Running test case: WI.StackTrace.isLikelyStackTrace.NativeFunctionCallsError
+PASS: Should be a stacktrace.
--- Running test case: testFormattedStrings
+-- Running test case: WI.StackTrace.isLikelyStackTrace.ValidStackStrings
+PASS: "a@file:///ex.html:10:6\nb@file:///ex.html:7:6\nglobal code@file:///ex.html:12:2" should be a stacktrace.
+PASS: "global code@file:///ex.html:12:2\na@file:///ex.html:10:6\nb@file:///ex.html:7:6" should be a stacktrace.
+PASS: "global code@file:///ex.html:1:1\nmap@[native code]" should be a stacktrace.
+
+-- Running test case: WI.StackTrace.isLikelyStackTrace.InvalidStackStrings
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.
Modified: trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html (235938 => 235939)
--- trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html 2018-09-12 16:20:36 UTC (rev 235938)
+++ trunk/LayoutTests/inspector/console/js-isLikelyStackTrace.html 2018-09-12 16:34:09 UTC (rev 235939)
@@ -2,16 +2,10 @@
<head>
<script src=""
<script>
-function typeErrorWrap()
+function generateTypeError()
{
- return typeError();
-}
-
-function typeError()
-{
- var object = {};
try {
- object.propertyDoesnt.exist;
+ ({}).propertyDoesnt.exist;
} catch(e) {
console.trace();
return e.stack;
@@ -18,27 +12,23 @@
}
}
-function testWithNativeCallInBetween()
+function generateErrorNativeCallInBetween()
{
- return [42].map(typeError)[0];
+ return [42].map(generateTypeError)[0];
}
-var _anonymousFunctionError = null;
-
+var _globalTypeError = generateTypeError();
+var _globalErrorWithNativeCalls = generateErrorNativeCallInBetween();
+var _globalAnonymousFunctionError = null;
(function() {
var object = {};
try {
object.methodDoesntExist();
} catch(e) {
- _anonymousFunctionError = e.stack;
+ _globalAnonymousFunctionError = e.stack;
}
})();
-function getAnonymousFunctionError()
-{
- return _anonymousFunctionError;
-}
-
function test()
{
let suite = InspectorTest.createAsyncSuite("WI.StackTrace.isLikelyStackTrace");
@@ -53,51 +43,46 @@
});
suite.addTestCase({
- name: "typeErrorWrap",
- test(resolve, reject) {
- InspectorTest.evaluateInPage("typeErrorWrap()", function(error, result) {
- if (error)
- reject(error);
+ name: "WI.StackTrace.isLikelyStackTrace.TypeError",
+ async test() {
+ let result = await InspectorTest.evaluateInPage(`_globalTypeError`);
+ InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
+ }
+ });
- InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
-
- resolve();
- });
+ suite.addTestCase({
+ name: "WI.StackTrace.isLikelyStackTrace.AnonymousFunctionError",
+ async test() {
+ let result = await InspectorTest.evaluateInPage(`_globalAnonymousFunctionError`);
+ InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
}
});
suite.addTestCase({
- name: "getAnonymousFunctionError",
- test(resolve, reject) {
- InspectorTest.evaluateInPage("getAnonymousFunctionError()", function(error, result) {
- if (error)
- reject(error);
-
- // FIXME: this test case fails. <https://bugs.webkit.org/show_bug.cgi?id=180664>
- InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
-
- resolve();
- });
+ name: "WI.StackTrace.isLikelyStackTrace.NativeFunctionCallsError",
+ async test() {
+ let result = await InspectorTest.evaluateInPage(`_globalErrorWithNativeCalls`);
+ InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
}
});
suite.addTestCase({
- name: "testWithNativeCallInBetween",
- test(resolve, reject) {
- InspectorTest.evaluateInPage("testWithNativeCallInBetween()", function(error, result) {
- if (error)
- reject(error);
+ name: "WI.StackTrace.isLikelyStackTrace.ValidStackStrings",
+ async test() {
+ const strings = [
+ "a@file:///ex.html:10:6\nb@file:///ex.html:7:6\nglobal code@file:///ex.html:12:2",
+ "global code@file:///ex.html:12:2\na@file:///ex.html:10:6\nb@file:///ex.html:7:6",
+ "global code@file:///ex.html:1:1\nmap@[native code]",
+ ];
- InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(result), "Should be a stacktrace.");
-
- resolve();
- });
+ for (let string of strings)
+ InspectorTest.expectThat(WI.StackTrace.isLikelyStackTrace(string), `${JSON.stringify(string)} should be a stacktrace.`);
}
});
suite.addTestCase({
- name: "testFormattedStrings",
- test(resolve, reject) {
+ name: "WI.StackTrace.isLikelyStackTrace.InvalidStackStrings",
+ async test() {
const strings = [
"video:1:2",
"video/mp4:1:2",
@@ -106,11 +91,9 @@
"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();
+ InspectorTest.expectThat(!WI.StackTrace.isLikelyStackTrace(string), `${JSON.stringify(string)} should not be a stacktrace.`);
}
});
@@ -119,8 +102,6 @@
</script>
</head>
<body _onload_="runTest()">
-<p>
-Test stack trace detection heuristic.<br>
-</p>
+<p>Test stack trace detection heuristic.</p>
</body>
</html>
Modified: trunk/Source/WebInspectorUI/ChangeLog (235938 => 235939)
--- trunk/Source/WebInspectorUI/ChangeLog 2018-09-12 16:20:36 UTC (rev 235938)
+++ trunk/Source/WebInspectorUI/ChangeLog 2018-09-12 16:34:09 UTC (rev 235939)
@@ -1,3 +1,16 @@
+2018-09-12 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: fix test case failures in js-isLikelyStackTrace.html
+ https://bugs.webkit.org/show_bug.cgi?id=180664
+
+ Reviewed by Devin Rousso.
+
+ * UserInterface/Models/StackTrace.js:
+ (WI.StackTrace.isLikelyStackTrace):
+ In a quick benchmark 50% of the time was rebuilding the same complex regular
+ _expression_ over and over again. Instead just build the regex once and reset
+ it before each use.
+
2018-09-12 Devin Rousso <[email protected]>
Web Inspector: imported recordings are unable to be viewed after navigation
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js (235938 => 235939)
--- trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js 2018-09-12 16:20:36 UTC (rev 235938)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/StackTrace.js 2018-09-12 16:34:09 UTC (rev 235939)
@@ -80,12 +80,16 @@
if (/^[^a-z$_]/i.test(stack[0]))
return false;
- const reasonablyLongProtocolLength = 10;
- const reasonablyLongLineLength = 500;
- const reasonablyLongNativeMethodLength = 120;
- 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);
+ if (!WI.StackTrace._likelyStackTraceRegex) {
+ const reasonablyLongProtocolLength = 10;
+ const reasonablyLongLineLength = 500;
+ const reasonablyLongNativeMethodLength = 120;
+ const stackTraceLine = `(global code|eval code|module code|\\w+)?([^:]{1,${reasonablyLongProtocolLength}}://[^:]{1,${reasonablyLongLineLength}}:\\d+:\\d+|[^@]{1,${reasonablyLongNativeMethodLength}}@\\[native code\\])`;
+ WI.StackTrace._likelyStackTraceRegex = new RegExp(`^${stackTraceLine}([\\n\\r]${stackTraceLine})+$`);
+ }
+
+ WI.StackTrace._likelyStackTraceRegex.lastIndex = 0;
+ return WI.StackTrace._likelyStackTraceRegex.test(stack);
}
static _parseStackTrace(stack)