Title: [129595] trunk
Revision
129595
Author
[email protected]
Date
2012-09-25 22:58:08 -0700 (Tue, 25 Sep 2012)

Log Message

Web Inspector: Fix logging in pure protocol test harness
https://bugs.webkit.org/show_bug.cgi?id=97579

Patch by Peter Rybin <[email protected]> on 2012-09-25
Reviewed by Yury Semikhatsky.

Tools:

_javascript_ alert implementation in DumpRenderTree gets immediate flush to make sure that
the message survives crash or kill by timeout.

* DumpRenderTree/blackberry/DumpRenderTree.cpp:
(BlackBerry::WebKit::DumpRenderTree::runJavaScriptAlert):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::runModalAlertDialog):
* DumpRenderTree/efl/DumpRenderTreeView.cpp:
(onJavaScriptAlert):
* DumpRenderTree/gtk/DumpRenderTree.cpp:
(webViewScriptAlert):
* DumpRenderTree/mac/UIDelegate.mm:
(-[UIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
* DumpRenderTree/qt/DumpRenderTreeQt.cpp:
(WebCore::WebPage::_javascript_Alert):
* DumpRenderTree/win/UIDelegate.cpp:
(UIDelegate::runJavaScriptAlertPanelWithMessage):

LayoutTests:

Logging facility is fixed and improved for inspector protocol harness.

* http/tests/inspector-protocol/resources/InspectorTest.js:
(InspectorTest.log): proper escaping is added
(InspectorTest.debugLog): new method is added for crash-proof debug messaging
* http/tests/inspector-protocol/resources/protocol-test.js:
(debugLog): new method is added for crash-proof debug messaging

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (129594 => 129595)


--- trunk/LayoutTests/ChangeLog	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/LayoutTests/ChangeLog	2012-09-26 05:58:08 UTC (rev 129595)
@@ -1,3 +1,18 @@
+2012-09-25  Peter Rybin  <[email protected]>
+
+        Web Inspector: Fix logging in pure protocol test harness
+        https://bugs.webkit.org/show_bug.cgi?id=97579
+
+        Reviewed by Yury Semikhatsky.
+
+        Logging facility is fixed and improved for inspector protocol harness.
+
+        * http/tests/inspector-protocol/resources/InspectorTest.js:
+        (InspectorTest.log): proper escaping is added 
+        (InspectorTest.debugLog): new method is added for crash-proof debug messaging
+        * http/tests/inspector-protocol/resources/protocol-test.js:
+        (debugLog): new method is added for crash-proof debug messaging
+
 2012-09-25  Gavin Barraclough  <[email protected]>
 
         REGRESSION (r129456): http/tests/security/xss-eval.html is failing on JSC platforms

Modified: trunk/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js (129594 => 129595)


--- trunk/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js	2012-09-26 05:58:08 UTC (rev 129595)
@@ -60,18 +60,34 @@
 }
 
 /**
+* Logs message to document.
 * @param {string} message
 */
 InspectorTest.log = function(message)
 {
-    this.sendCommand("Runtime.evaluate", { "_expression_": "log(\"" + message + "\");"} );
+    this.sendCommand("Runtime.evaluate", { "_expression_": "log(" + JSON.stringify(message) + ")" } );
 }
 
+/**
+* Logs message directly to process stdout via alert function (hopefully followed by flush call).
+* This message should survive process crash or kill by timeout. 
+* @param {string} message
+*/
+InspectorTest.debugLog = function(message)
+{
+    this.sendCommand("Runtime.evaluate", { "_expression_": "debugLog(" + JSON.stringify(message) + ")" } );
+}
+
 InspectorTest.completeTest = function()
 {
     this.sendCommand("Runtime.evaluate", { "_expression_": "closeTest();"} );
 }
 
 window.addEventListener("message", function(event) {
-    eval(event.data);
+    try {
+        eval(event.data);
+    } catch (e) {
+        alert(e.stack);
+        throw e;
+    }
 });

Modified: trunk/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.js (129594 => 129595)


--- trunk/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.js	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/LayoutTests/http/tests/inspector-protocol/resources/protocol-test.js	2012-09-26 05:58:08 UTC (rev 129595)
@@ -25,8 +25,17 @@
 var outputElement;
 
 /**
+ * Logs message to process stdout via alert (hopefully implemented with immediate flush).
  * @param {string} text
  */
+function debugLog(text)
+{
+    alert(text);
+}
+
+/**
+ * @param {string} text
+ */
 function log(text)
 {
     if (!outputElement) {

Modified: trunk/Tools/ChangeLog (129594 => 129595)


--- trunk/Tools/ChangeLog	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/Tools/ChangeLog	2012-09-26 05:58:08 UTC (rev 129595)
@@ -1,3 +1,28 @@
+2012-09-25  Peter Rybin  <[email protected]>
+
+        Web Inspector: Fix logging in pure protocol test harness
+        https://bugs.webkit.org/show_bug.cgi?id=97579
+
+        Reviewed by Yury Semikhatsky.
+
+        _javascript_ alert implementation in DumpRenderTree gets immediate flush to make sure that
+        the message survives crash or kill by timeout.
+
+        * DumpRenderTree/blackberry/DumpRenderTree.cpp:
+        (BlackBerry::WebKit::DumpRenderTree::runJavaScriptAlert):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::runModalAlertDialog):
+        * DumpRenderTree/efl/DumpRenderTreeView.cpp:
+        (onJavaScriptAlert):
+        * DumpRenderTree/gtk/DumpRenderTree.cpp:
+        (webViewScriptAlert):
+        * DumpRenderTree/mac/UIDelegate.mm:
+        (-[UIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
+        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
+        (WebCore::WebPage::_javascript_Alert):
+        * DumpRenderTree/win/UIDelegate.cpp:
+        (UIDelegate::runJavaScriptAlertPanelWithMessage):
+
 2012-09-25  Dan Bernstein  <[email protected]>
 
         Tools part of <rdar://problem/11455228> [mac] Stop using screen fonts

Modified: trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp (129594 => 129595)


--- trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp	2012-09-26 05:58:08 UTC (rev 129595)
@@ -664,8 +664,10 @@
 
 void DumpRenderTree::runJavaScriptAlert(const String& message)
 {
-    if (!testDone)
+    if (!testDone) {
         printf("ALERT: %s\n", message.utf8().data());
+        fflush(stdout);
+    }
 }
 
 bool DumpRenderTree::runJavaScriptConfirm(const String& message)

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (129594 => 129595)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-09-26 05:58:08 UTC (rev 129595)
@@ -546,6 +546,7 @@
 void WebViewHost::runModalAlertDialog(WebFrame*, const WebString& message)
 {
     printf("ALERT: %s\n", message.utf8().data());
+    fflush(stdout);
 }
 
 bool WebViewHost::runModalConfirmDialog(WebFrame*, const WebString& message)

Modified: trunk/Tools/DumpRenderTree/efl/DumpRenderTreeView.cpp (129594 => 129595)


--- trunk/Tools/DumpRenderTree/efl/DumpRenderTreeView.cpp	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/Tools/DumpRenderTree/efl/DumpRenderTreeView.cpp	2012-09-26 05:58:08 UTC (rev 129595)
@@ -82,6 +82,7 @@
 static void onJavaScriptAlert(Ewk_View_Smart_Data*, Evas_Object*, const char* message)
 {
     printf("ALERT: %s\n", message);
+    fflush(stdout);
 }
 
 static Eina_Bool onJavaScriptConfirm(Ewk_View_Smart_Data*, Evas_Object*, const char* message)

Modified: trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp (129594 => 129595)


--- trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp	2012-09-26 05:58:08 UTC (rev 129595)
@@ -925,6 +925,7 @@
 static gboolean webViewScriptAlert(WebKitWebView* view, WebKitWebFrame* frame, const gchar* message, gpointer data)
 {
     fprintf(stdout, "ALERT: %s\n", message);
+    fflush(stdout);
     return TRUE;
 }
 

Modified: trunk/Tools/DumpRenderTree/mac/UIDelegate.mm (129594 => 129595)


--- trunk/Tools/DumpRenderTree/mac/UIDelegate.mm	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/Tools/DumpRenderTree/mac/UIDelegate.mm	2012-09-26 05:58:08 UTC (rev 129595)
@@ -89,8 +89,10 @@
 
 - (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
 {
-    if (!done)
+    if (!done) {
         printf("ALERT: %s\n", [message UTF8String]);
+        fflush(stdout);
+    }
 }
 
 - (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame

Modified: trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp (129594 => 129595)


--- trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp	2012-09-26 05:58:08 UTC (rev 129595)
@@ -225,6 +225,7 @@
         return;
 
     fprintf(stdout, "ALERT: %s\n", message.toUtf8().constData());
+    fflush(stdout);
 }
 
 void WebPage::requestPermission(QWebFrame* frame, QWebPage::Feature feature)

Modified: trunk/Tools/DumpRenderTree/win/UIDelegate.cpp (129594 => 129595)


--- trunk/Tools/DumpRenderTree/win/UIDelegate.cpp	2012-09-26 05:39:54 UTC (rev 129594)
+++ trunk/Tools/DumpRenderTree/win/UIDelegate.cpp	2012-09-26 05:58:08 UTC (rev 129595)
@@ -435,6 +435,7 @@
         /* [in] */ BSTR message)
 {
     printf("ALERT: %S\n", message ? message : L"");
+    fflush(stdout);
 
     return S_OK;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to