Web Inspector: add debugging flag to InspectorTest for unbuffered logging to stderr
authorburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Aug 2014 20:21:59 +0000 (20:21 +0000)
committerburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Aug 2014 20:21:59 +0000 (20:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135726

Reviewed by Timothy Hatcher.

Source/WebCore:

Add a bridge so that InspectorTest can synchronously log to the console.

* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::unbufferedLog): Added.
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.idl:

Source/WebInspectorUI:

Added a flag for debugging inspector tests which will synchronously log messages.
This avoids failure modes that prevent logging from being added to the test page.

* UserInterface/Base/Test.js:
(InspectorTest.debugLog):
(InspectorTest.addResult):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172355 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorFrontendHost.idl
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Test.js

index e160a9f..3f9756a 100644 (file)
@@ -1,3 +1,17 @@
+2014-08-08  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Inspector: add debugging flag to InspectorTest for unbuffered logging to stderr
+        https://bugs.webkit.org/show_bug.cgi?id=135726
+
+        Reviewed by Timothy Hatcher.
+
+        Add a bridge so that InspectorTest can synchronously log to the console.
+
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::InspectorFrontendHost::unbufferedLog): Added.
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.idl:
+
 2014-08-08  Roger Fong  <roger_fong@apple.com>
 
         Adjustments to CueBox CSS Width calculations.
index 69ad310..d1a4625 100644 (file)
@@ -302,6 +302,12 @@ bool InspectorFrontendHost::isUnderTest()
     return m_client && m_client->isUnderTest();
 }
 
+void InspectorFrontendHost::unbufferedLog(const String& message)
+{
+    // This is used only for debugging inspector tests.
+    WTFLogAlways("InspectorTest: %s", message.utf8().data());
+}
+
 void InspectorFrontendHost::beep()
 {
     systemBeep();
index 9f86228..8e8cd85 100644 (file)
@@ -84,6 +84,7 @@ public:
     void dispatchEventAsContextMenuEvent(Event*);
 
     bool isUnderTest();
+    void unbufferedLog(const String& message);
 
     void beep();
 
index 4012f37..eb8d728 100644 (file)
@@ -64,6 +64,7 @@
     [Custom] void showContextMenu(MouseEvent event, any items);
     void dispatchEventAsContextMenuEvent(Event event);
     void sendMessageToBackend(DOMString message);
+    void unbufferedLog(DOMString message);
 
     [Custom] void recordActionTaken(unsigned long actionCode);
     [Custom] void recordPanelShown(unsigned long panelCode);
index 0bce333..eea42cb 100644 (file)
@@ -1,3 +1,17 @@
+2014-08-08  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Inspector: add debugging flag to InspectorTest for unbuffered logging to stderr
+        https://bugs.webkit.org/show_bug.cgi?id=135726
+
+        Reviewed by Timothy Hatcher.
+
+        Added a flag for debugging inspector tests which will synchronously log messages.
+        This avoids failure modes that prevent logging from being added to the test page.
+
+        * UserInterface/Base/Test.js:
+        (InspectorTest.debugLog):
+        (InspectorTest.addResult):
+
 2014-08-08  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: When Switching Recordings, the UI datagrids do not update to match selection
index d97dcb9..ab5af10 100644 (file)
@@ -78,6 +78,9 @@ WebInspector.updateDockedState = function()
 // which are provided by `inspector-test.js`.
 InspectorTest = {};
 
+// This is useful for debugging Inspector tests by synchronously logging messages.
+InspectorTest.dumpMessagesToConsole = false;
+
 // This is a workaround for the fact that it would be hard to set up a constructor,
 // prototype, and prototype chain for the singleton InspectorTest.
 InspectorTest.EventDispatcher = function()
@@ -132,11 +135,17 @@ InspectorTest.expectThat = function(condition, message)
 // This function should only be used to debug tests and not to produce normal test output.
 InspectorTest.debugLog = function(message)
 {
+    if (InspectorTest.dumpMessagesToConsole)
+        InspectorFrontendHost.unbufferedLog("debugLog: " + message);
+
     this.evaluateInPage("InspectorTestProxy.debugLog(unescape('" + escape(JSON.stringify(message)) + "'))");
 }
 
 InspectorTest.completeTest = function()
 {
+    if (InspectorTest.dumpMessagesToConsole)
+        InspectorFrontendHost.unbufferedLog("InspectorTest.completeTest()");
+
     function signalCompletionToTestPage() {
         InspectorBackend.runAfterPendingDispatches(this.evaluateInPage.bind(this, "InspectorTestProxy.completeTest()"));
     }
@@ -165,6 +174,9 @@ InspectorTest.addResult = function(text)
 {
     this._results.push(text);
 
+    if (InspectorTest.dumpMessagesToConsole)
+        InspectorFrontendHost.unbufferedLog("addResult: " + text);
+
     if (!this._testPageIsReloading)
         this.evaluateInPage("InspectorTestProxy.addResult(unescape('" + escape(text) + "'))");
 }