Add a watchdog timer to Gtk DumpRenderTree, and implement alert/prompt/confirm.
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2007 12:39:48 +0000 (12:39 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2007 12:39:48 +0000 (12:39 +0000)
This prevents many layout tests from hanging while waiting on user responses to dialogs.

Reviewed by Alp Toker.

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

WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
WebKitTools/DumpRenderTree/gtk/DumpRenderTreeGtk.h
WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp

index b21f57f..7509dc4 100644 (file)
@@ -2,6 +2,24 @@
 
         Reviewed by Alp Toker.
 
+        Add a watchdog timer to Gtk DumpRenderTree, and implement alert/prompt/confirm.  This prevents
+        many layout tests from hanging while waiting on user responses to dialogs.
+
+        * DumpRenderTree/gtk/DumpRenderTree.cpp:
+        (invalidateAnyPreviousWaitToDumpWatchdog):
+        (webViewScriptAlert):
+        (webViewScriptPrompt):
+        (webViewScriptConfirm):
+        (main):
+        * DumpRenderTree/gtk/DumpRenderTreeGtk.h:
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (waitToDumpWatchdogFired):
+        (LayoutTestController::setWaitToDump):
+
+2007-12-05  Mark Rowe  <mrowe@apple.com>
+
+        Reviewed by Alp Toker.
+
         Flesh out DumpRenderTree for Gtk.  After these changes, the majority of the tests in fast/js pass.
 
         * DumpRenderTree/gtk/DumpRenderTree.cpp:
index 733cc11..bd34861 100644 (file)
@@ -62,6 +62,7 @@ LayoutTestController* layoutTestController = 0;
 static WebKitWebView* webView;
 WebKitWebFrame* mainFrame = 0;
 WebKitWebFrame* topLoadingFrame = 0;
+guint waitToDumpWatchdog = 0;
 
 const unsigned maxViewHeight = 600;
 const unsigned maxViewWidth = 800;
@@ -134,8 +135,17 @@ static gchar* dumpRenderTreeAsText(WebKitWebFrame* frame)
     return strdup("foo");
 }
 
+static void invalidateAnyPreviousWaitToDumpWatchdog()
+{
+    if (waitToDumpWatchdog) {
+        g_source_remove(waitToDumpWatchdog);
+        waitToDumpWatchdog = 0;
+    }
+}
+
 void dump()
 {
+    invalidateAnyPreviousWaitToDumpWatchdog();
     if (dumpTree) {
         char* result = 0;
 
@@ -260,6 +270,28 @@ gboolean webViewConsoleMessage(WebKitWebView* view, const gchar* message, unsign
     return TRUE;
 }
 
+
+gboolean webViewScriptAlert(WebKitWebView* view, WebKitWebFrame* frame, const gchar* message)
+{
+    fprintf(stdout, "ALERT: %s\n", message);
+    return TRUE;
+}
+
+gboolean webViewScriptPrompt(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, const gchar* defaultValue, gchar** value)
+{
+    fprintf(stdout, "PROMPT: %s, default text: %s\n", message, defaultValue);
+    *value = g_strdup(defaultValue);
+    return TRUE;
+}
+
+gboolean webViewScriptConfirm(WebKitWebView* view, WebKitWebFrame* frame, const gchar* message, gboolean* didConfirm)
+{
+    fprintf(stdout, "CONFIRM: %s\n", message);
+    *didConfirm = TRUE;
+    return TRUE;
+}
+
+
 int main(int argc, char* argv[])
 {
     struct option options[] = {
@@ -297,6 +329,9 @@ int main(int argc, char* argv[])
     g_signal_connect(G_OBJECT(webView), "load-finished", G_CALLBACK(webViewLoadFinished), 0);
     g_signal_connect(G_OBJECT(webView), "window-object-cleared", G_CALLBACK(webViewWindowObjectCleared), 0);
     g_signal_connect(G_OBJECT(webView), "console-message", G_CALLBACK(webViewConsoleMessage), 0);
+    g_signal_connect(G_OBJECT(webView), "script-alert", G_CALLBACK(webViewScriptAlert), 0);
+    g_signal_connect(G_OBJECT(webView), "script-prompt", G_CALLBACK(webViewScriptPrompt), 0);
+    g_signal_connect(G_OBJECT(webView), "script-confirm", G_CALLBACK(webViewScriptConfirm), 0);
 
     if (argc == optind+1 && strcmp(argv[optind], "-") == 0) {
         char filenameBuffer[2048];
index 1b9b402..bf29142 100644 (file)
@@ -33,5 +33,6 @@
 
 extern WebKitWebFrame* mainFrame;
 extern WebKitWebFrame* topLoadingFrame;
+extern guint waitToDumpWatchdog;
 
 #endif // DumpRenderTreeGtk_h 
index 6e18da9..944a17f 100644 (file)
@@ -151,10 +151,20 @@ void LayoutTestController::setWindowIsKey(bool windowIsKey)
     // FIXME: implement
 }
 
+static gboolean waitToDumpWatchdogFired(void*)
+{
+    const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
+    fprintf(stderr, "%s", message);
+    fprintf(stdout, "%s", message);
+    dump();
+    return FALSE;
+}
+
 void LayoutTestController::setWaitToDump(bool waitUntilDone)
 {
     m_waitToDump = waitUntilDone;
-    // FIXME: Should have some sort of watchdog timer here
+    if (m_waitToDump && !waitToDumpWatchdog)
+        waitToDumpWatchdog = g_timeout_add_seconds(10, waitToDumpWatchdogFired, 0);
 }
 
 int LayoutTestController::windowCount()