Title: [201048] trunk/Source/WebInspectorUI
- Revision
- 201048
- Author
- [email protected]
- Date
- 2016-05-17 15:04:48 -0700 (Tue, 17 May 2016)
Log Message
Web Inspector: inspector tests should redirect and log console.trace() calls in test output
https://bugs.webkit.org/show_bug.cgi?id=157802
<rdar://problem/26325671>
Reviewed by Timothy Hatcher.
* UserInterface/Test/FrontendTestHarness.js:
(FrontendTestHarness.prototype.redirectConsoleToTestOutput.createProxyConsoleHandler):
Remove bind() that is now unnecessary. Also redirect console.warn.
(FrontendTestHarness.prototype.redirectConsoleToTestOutput):
For console.trace(), throw and catch a dummy Error to get a stack trace.
Do some post processing on it to remove useless frames and sanitize file paths.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (201047 => 201048)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-05-17 21:38:17 UTC (rev 201047)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-05-17 22:04:48 UTC (rev 201048)
@@ -1,5 +1,21 @@
2016-05-17 Brian Burg <[email protected]>
+ Web Inspector: inspector tests should redirect and log console.trace() calls in test output
+ https://bugs.webkit.org/show_bug.cgi?id=157802
+ <rdar://problem/26325671>
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Test/FrontendTestHarness.js:
+ (FrontendTestHarness.prototype.redirectConsoleToTestOutput.createProxyConsoleHandler):
+ Remove bind() that is now unnecessary. Also redirect console.warn.
+
+ (FrontendTestHarness.prototype.redirectConsoleToTestOutput):
+ For console.trace(), throw and catch a dummy Error to get a stack trace.
+ Do some post processing on it to remove useless frames and sanitize file paths.
+
+2016-05-17 Brian Burg <[email protected]>
+
Web Inspector: Filtering huge data grids should yield occasionally so the UI remains responsive
https://bugs.webkit.org/show_bug.cgi?id=157702
<rdar://problem/26282898>
Modified: trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js (201047 => 201048)
--- trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js 2016-05-17 21:38:17 UTC (rev 201047)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js 2016-05-17 22:04:48 UTC (rev 201048)
@@ -134,17 +134,51 @@
let self = this;
function createProxyConsoleHandler(type) {
return function() {
- self.addResult(`${type}: ` + Array.from(arguments).join(" "));
+ self.addResult(`${type}: ` + Array.from(arguments).join(" "));
};
}
+ function createProxyConsoleTraceHandler(){
+ return function() {
+ try {
+ throw new Exception();
+ } catch (e) {
+ // Skip the first frame which is added by this function.
+ let frames = e.stack.split("\n").slice(1);
+ let sanitizedFrames = frames.map((frame, i) => {
+ // Most frames are of the form "functionName@file:///foo/bar/File.js:345".
+ // But, some frames do not have a functionName. Get rid of the file path.
+ let nameAndURLSeparator = frame.indexOf("@");
+ let frameName = (nameAndURLSeparator > 0) ? frame.substr(0, nameAndURLSeparator) : "(anonymous)";
+
+ let lastPathSeparator = Math.max(frame.lastIndexOf("/"), frame.lastIndexOf("\\"));
+ let frameLocation = (lastPathSeparator > 0) ? frame.substr(lastPathSeparator + 1) : frame;
+ if (!frameLocation.length)
+ frameLocation = "unknown";
+
+ // Clean up the location so it is bracketed or in parenthesis.
+ if (frame.indexOf("[native code]") !== -1)
+ frameLocation = "[native code]";
+ else
+ frameLocation = "(" + frameLocation + ")"
+
+ return `#${i}: ${frameName} ${frameLocation}`;
+ });
+ self.addResult("TRACE: " + Array.from(arguments).join(" "));
+ self.addResult(sanitizedFrames.join("\n"));
+ }
+ }
+ }
+
let redirectedMethods = {};
- for (let key in window.console)
- redirectedMethods[key] = window.console[key].bind(window.console);
+ for (let key in window.console)
+ redirectedMethods[key] = window.console[key];
- for (let type of ["log", "error", "info"])
+ for (let type of ["log", "error", "info", "warn"])
redirectedMethods[type] = createProxyConsoleHandler(type.toUpperCase());
+ redirectedMethods["trace"] = createProxyConsoleTraceHandler();
+
this._originalConsole = window.console;
window.console = redirectedMethods;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes