- Revision
- 188687
- Author
- [email protected]
- Date
- 2015-08-20 09:43:53 -0700 (Thu, 20 Aug 2015)
Log Message
Web Inspector: add TestHarness option to tee all commands to system console
https://bugs.webkit.org/show_bug.cgi?id=148181
Reviewed by Joseph Pecoraro.
Source/WebCore:
* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::unbufferedLog): Remove log prefix so output
to stderr can be diffed against expected results without processing.
Source/WebInspectorUI:
It is currently difficult to trace what's going on when a test times out
on a buildbot instance. The existing option for forcing debug logging can
still drop messages that don't make it from the inspector to the test page.
This patch adds an option which logs all TestHarness commands directly to
stderr in the Inspector instance using InspectorFrontendHost::unbufferedLog.
Clean up how existing harness logging code calls into each other. Extract
the stringifying code that is duplicated everywhere.
* UserInterface/Test.html: Reorganize options and add new option.
* UserInterface/Test/FrontendTestHarness.js:
(FrontendTestHarness.prototype.completeTest):
(FrontendTestHarness.prototype.addResult):
(FrontendTestHarness.prototype.debugLog):
(FrontendTestHarness.prototype.testPageDidLoad):
(FrontendTestHarness.prototype._resendResults):
(FrontendTestHarness):
* UserInterface/Test/ProtocolTestHarness.js:
(ProtocolTestHarness.prototype.completeTest):
(ProtocolTestHarness.prototype.addResult):
(ProtocolTestHarness.prototype.debugLog):
* UserInterface/Test/TestHarness.js:
(TestHarness.prototype.log):
(TestHarness.prototype.assert):
(TestHarness.prototype.expectThat):
(TestHarness.messageAsString):
(TestHarness):
* UserInterface/TestStub.html: Reorganize options and add new option.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (188686 => 188687)
--- trunk/Source/WebCore/ChangeLog 2015-08-20 15:11:07 UTC (rev 188686)
+++ trunk/Source/WebCore/ChangeLog 2015-08-20 16:43:53 UTC (rev 188687)
@@ -1,3 +1,14 @@
+2015-08-19 Brian Burg <[email protected]>
+
+ Web Inspector: add TestHarness option to tee all commands to system console
+ https://bugs.webkit.org/show_bug.cgi?id=148181
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/InspectorFrontendHost.cpp:
+ (WebCore::InspectorFrontendHost::unbufferedLog): Remove log prefix so output
+ to stderr can be diffed against expected results without processing.
+
2015-08-19 Brent Fulgham <[email protected]>
[Win] Unreviewed build fix after r188663.
Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp (188686 => 188687)
--- trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp 2015-08-20 15:11:07 UTC (rev 188686)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp 2015-08-20 16:43:53 UTC (rev 188687)
@@ -308,7 +308,7 @@
void InspectorFrontendHost::unbufferedLog(const String& message)
{
// This is used only for debugging inspector tests.
- WTFLogAlways("InspectorTest: %s", message.utf8().data());
+ WTFLogAlways("%s", message.utf8().data());
}
void InspectorFrontendHost::beep()
Modified: trunk/Source/WebInspectorUI/ChangeLog (188686 => 188687)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-08-20 15:11:07 UTC (rev 188686)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-08-20 16:43:53 UTC (rev 188687)
@@ -1,3 +1,40 @@
+2015-08-19 Brian Burg <[email protected]>
+
+ Web Inspector: add TestHarness option to tee all commands to system console
+ https://bugs.webkit.org/show_bug.cgi?id=148181
+
+ Reviewed by Joseph Pecoraro.
+
+ It is currently difficult to trace what's going on when a test times out
+ on a buildbot instance. The existing option for forcing debug logging can
+ still drop messages that don't make it from the inspector to the test page.
+
+ This patch adds an option which logs all TestHarness commands directly to
+ stderr in the Inspector instance using InspectorFrontendHost::unbufferedLog.
+
+ Clean up how existing harness logging code calls into each other. Extract
+ the stringifying code that is duplicated everywhere.
+
+ * UserInterface/Test.html: Reorganize options and add new option.
+ * UserInterface/Test/FrontendTestHarness.js:
+ (FrontendTestHarness.prototype.completeTest):
+ (FrontendTestHarness.prototype.addResult):
+ (FrontendTestHarness.prototype.debugLog):
+ (FrontendTestHarness.prototype.testPageDidLoad):
+ (FrontendTestHarness.prototype._resendResults):
+ (FrontendTestHarness):
+ * UserInterface/Test/ProtocolTestHarness.js:
+ (ProtocolTestHarness.prototype.completeTest):
+ (ProtocolTestHarness.prototype.addResult):
+ (ProtocolTestHarness.prototype.debugLog):
+ * UserInterface/Test/TestHarness.js:
+ (TestHarness.prototype.log):
+ (TestHarness.prototype.assert):
+ (TestHarness.prototype.expectThat):
+ (TestHarness.messageAsString):
+ (TestHarness):
+ * UserInterface/TestStub.html: Reorganize options and add new option.
+
2015-08-20 Joseph Pecoraro <[email protected]>
Web Inspector: Remove unused temporary variable
Modified: trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js (188686 => 188687)
--- trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js 2015-08-20 15:11:07 UTC (rev 188686)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js 2015-08-20 16:43:53 UTC (rev 188687)
@@ -37,8 +37,8 @@
completeTest()
{
- if (this.forceSyncDebugLogging)
- InspectorFrontendHost.unbufferedLog("FrontendTestHarness.completeTest()");
+ if (this.dumpActivityToSystemConsole)
+ InspectorFrontendHost.unbufferedLog("completeTest()");
// Wait for results to be resent before requesting completeTest(). Otherwise, messages will be
// queued after pending dispatches run to zero and the test page will quit before processing them.
@@ -52,18 +52,25 @@
addResult(message)
{
- this._results.push(message);
+ let stringifiedMessage = TestHarness.messageAsString(message);
- if (this.forceSyncDebugLogging)
- InspectorFrontendHost.unbufferedLog("addResult: " + message);
+ // Save the stringified message, since message may be a DOM element that won't survive reload.
+ this._results.push(stringifiedMessage);
+ if (this.dumpActivityToSystemConsole)
+ InspectorFrontendHost.unbufferedLog(stringifiedMessage);
+
if (!this._testPageIsReloading)
- this.evaluateInPage(`TestPage.addResult(unescape("${escape(message)}"))`);
+ this.evaluateInPage(`TestPage.addResult(unescape("${escape(stringifiedMessage)}"))`);
}
debugLog(message)
{
- let stringifiedMessage = typeof message !== "string" ? JSON.stringify(message) : message;
+ let stringifiedMessage = TestHarness.messageAsString(message);
+
+ if (this.dumpActivityToSystemConsole)
+ InspectorFrontendHost.unbufferedLog(stringifiedMessage);
+
this.evaluateInPage(`TestPage.debugLog(unescape("${escape(stringifiedMessage)}"));`);
}
@@ -92,6 +99,9 @@
testPageDidLoad()
{
+ if (this.dumpActivityToSystemConsole)
+ InspectorFrontendHost.unbufferedLog("testPageDidLoad()");
+
this._testPageIsReloading = false;
this._resendResults();
@@ -163,6 +173,9 @@
console.assert(this._shouldResendResults);
this._shouldResendResults = false;
+ if (this.dumpActivityToSystemConsole)
+ InspectorFrontendHost.unbufferedLog("_resendResults()");
+
for (let result of this._results)
this.evaluateInPage(`TestPage.addResult(unescape("${escape(result)}"))`);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Test/ProtocolTestHarness.js (188686 => 188687)
--- trunk/Source/WebInspectorUI/UserInterface/Test/ProtocolTestHarness.js 2015-08-20 15:11:07 UTC (rev 188686)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/ProtocolTestHarness.js 2015-08-20 16:43:53 UTC (rev 188687)
@@ -29,20 +29,31 @@
completeTest()
{
+ if (this.dumpActivityToSystemConsole)
+ InspectorFrontendHost.unbufferedLog("completeTest()");
+
this.evaluateInPage("TestPage.closeTest();");
}
addResult(message)
{
+ let stringifiedMessage = TestHarness.messageAsString(message);
+
+ if (this.dumpActivityToSystemConsole)
+ InspectorFrontendHost.unbufferedLog(stringifiedMessage);
+
// Unfortunately, every string argument must be escaped because tests are not consistent
// with respect to escaping with single or double quotes. Some exceptions use single quotes.
- let stringifiedMessage = typeof message !== "string" ? JSON.stringify(message) : message;
this.evaluateInPage(`TestPage.log(unescape("${escape(stringifiedMessage)}"));`);
}
debugLog(message)
{
- let stringifiedMessage = typeof message !== "string" ? JSON.stringify(message) : message;
+ let stringifiedMessage = TestHarness.messageAsString(message);
+
+ if (this.dumpActivityToSystemConsole)
+ InspectorFrontendHost.unbufferedLog(stringifiedMessage);
+
this.evaluateInPage(`TestPage.debugLog(unescape("${escape(stringifiedMessage)}"));`);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js (188686 => 188687)
--- trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js 2015-08-20 15:11:07 UTC (rev 188686)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js 2015-08-20 16:43:53 UTC (rev 188687)
@@ -71,7 +71,7 @@
{
++this._logCount;
- if (this.forceSyncDebugLogging)
+ if (this.forceDebugLogging)
this.debugLog(message);
else
this.addResult(message);
@@ -82,14 +82,24 @@
if (condition)
return;
- let stringifiedMessage = typeof message !== "object" ? message : JSON.stringify(message);
- this.addResult("ASSERT: " + stringifiedMessage);
+ let stringifiedMessage = TestHarness.messageAsString(message);
+ this.log("ASSERT: " + stringifiedMessage);
}
expectThat(condition, message)
{
let prefix = condition ? "PASS" : "FAIL";
- let stringifiedMessage = typeof message !== "object" ? message : JSON.stringify(message);
- this.addResult(`${prefix}: ${stringifiedMessage}`);
+ let stringifiedMessage = TestHarness.messageAsString(message);
+ this.log(`${prefix}: ${stringifiedMessage}`);
}
+
+ // Protected
+
+ static messageAsString(message)
+ {
+ if (message instanceof Element)
+ return message.textContent;
+
+ return (typeof message !== "string") ? JSON.stringify(message) : message;
+ }
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (188686 => 188687)
--- trunk/Source/WebInspectorUI/UserInterface/Test.html 2015-08-20 15:11:07 UTC (rev 188686)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html 2015-08-20 16:43:53 UTC (rev 188687)
@@ -147,12 +147,14 @@
<script type="text/_javascript_">
WebInspector.loaded();
- // Not reliable unless console messages are dumped to stderr.
- // See wiki for details <https://http://trac.webkit.org/wiki/WebInspectorDebugging>.
+ // Debug logging is synchronous on the test page.
+ InspectorTest.forceDebugLogging = false;
+
+ // Tee all TestHarness commands to stderr from within the Inspector.
+ InspectorTest.dumpActivityToSystemConsole = false;
+
+ // Best used in combination with dumpActivityToSystemConsole.
InspectorBackend.dumpInspectorProtocolMessages = false;
-
- // Synchronous logging may produce more output prior to a timeout.
- InspectorTest.forceSyncDebugLogging = false;
</script>
</head>
<body>
Modified: trunk/Source/WebInspectorUI/UserInterface/TestStub.html (188686 => 188687)
--- trunk/Source/WebInspectorUI/UserInterface/TestStub.html 2015-08-20 15:11:07 UTC (rev 188686)
+++ trunk/Source/WebInspectorUI/UserInterface/TestStub.html 2015-08-20 16:43:53 UTC (rev 188687)
@@ -40,12 +40,14 @@
<script src=""
<script>
- // Not reliable unless console messages are dumped to console.
- // See wiki for details <https://http://trac.webkit.org/wiki/WebInspectorDebugging>.
- ProtocolTest.dumpInspectorProtocolMessages = false;
+ // Debug logging is synchronous on the test page.
+ ProtocolTest.forceDebugLogging = false;
- // Synchronous logging may produce more output prior to a timeout.
- ProtocolTest.forceSyncDebugLogging = false;
+ // Tee all TestHarness commands to stderr from within the Inspector.
+ ProtocolTest.dumpActivityToSystemConsole = false;
+
+ // Best used in combination with dumpActivityToSystemConsole.
+ InspectorProtocol.dumpInspectorProtocolMessages = false;
</script>
</head>
</html>