2008-01-04 Alp Toker <alp@atoker.com>
[WebKit-https.git] / WebKitTools / DumpRenderTree / gtk / LayoutTestControllerGtk.cpp
index 24636bfebd6a0ab14e8bf09a9e6fa90dd336db61..82af22ec082bf0b4d9233f4151d7730a4da8c11b 100644 (file)
@@ -35,6 +35,8 @@
 #include <JavaScriptCore/JSRetainPtr.h>
 #include <JavaScriptCore/JSStringRef.h>
 
+#include <glib.h>
+
 LayoutTestController::~LayoutTestController()
 {
     // FIXME: implement
@@ -74,12 +76,17 @@ void LayoutTestController::keepWebHistory()
 
 void LayoutTestController::notifyDone()
 {
-    // FIXME: The frame might not be finished loading yet
-    if (m_waitToDump && !WorkQueue::shared()->count())
+    if (m_waitToDump && !topLoadingFrame && !WorkQueue::shared()->count())
         dump();
     m_waitToDump = false;
 }
 
+JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
+{
+    // Function introduced in r28690. This may need special-casing on Windows.
+    return url; // Do nothing on Unix.
+}
+
 void LayoutTestController::queueBackNavigation(int howFarBack)
 {
     WorkQueue::shared()->queue(new BackItem(howFarBack));
@@ -146,10 +153,26 @@ 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)
 {
+    static const int timeoutSeconds = 10;
+
     m_waitToDump = waitUntilDone;
-    // FIXME: Should have some sort of watchdog timer here
+    if (m_waitToDump && !waitToDumpWatchdog)
+#if GLIB_CHECK_VERSION(2,14,0)
+        waitToDumpWatchdog = g_timeout_add_seconds(timeoutSeconds, waitToDumpWatchdogFired, 0);
+#else
+        waitToDumpWatchdog = g_timeout_add(timeoutSeconds * 1000, waitToDumpWatchdogFired, 0);
+#endif
 }
 
 int LayoutTestController::windowCount()
@@ -168,3 +191,8 @@ void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
     // FIXME: implement
 }
 
+void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
+{
+    // FIXME: implement
+}
+