summaryrefslogtreecommitdiff
path: root/Tools/WebKitTestRunner
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/WebKitTestRunner')
-rw-r--r--Tools/WebKitTestRunner/GNUmakefile.am2
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl2
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp16
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h2
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp13
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/TestRunner.h2
-rw-r--r--Tools/WebKitTestRunner/TestInvocation.cpp14
-rw-r--r--Tools/WebKitTestRunner/WorkQueueManager.cpp64
-rw-r--r--Tools/WebKitTestRunner/WorkQueueManager.h13
-rw-r--r--Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp32
-rw-r--r--Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp7
11 files changed, 148 insertions, 19 deletions
diff --git a/Tools/WebKitTestRunner/GNUmakefile.am b/Tools/WebKitTestRunner/GNUmakefile.am
index a03f8bcf1..a8a2fad56 100644
--- a/Tools/WebKitTestRunner/GNUmakefile.am
+++ b/Tools/WebKitTestRunner/GNUmakefile.am
@@ -42,6 +42,7 @@ Programs_WebKitTestRunner_CPPFLAGS = \
-I$(top_builddir)/DerivedSources/WebKit2/include \
$(global_cppflags) \
$(javascriptcore_cppflags) \
+ $(webcore_cppflags) \
$(GLOBALDEPS_CFLAGS) \
$(CAIRO_CFLAGS) \
$(GTK_CFLAGS) \
@@ -136,6 +137,7 @@ Libraries_libTestRunnerInjectedBundle_la_CPPFLAGS = \
-I$(top_builddir)/DerivedSources/WebKit2/include \
$(global_cppflags) \
$(javascriptcore_cppflags) \
+ $(webcore_cppflags) \
$(GLOBALDEPS_CFLAGS) \
$(CAIRO_CFLAGS) \
$(GLIB_CFLAGS) \
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
index 81432da1e..f9f619981 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
@@ -186,5 +186,7 @@ interface TestRunner {
void queueBackNavigation(in unsigned long howFarBackward);
void queueLoad(in DOMString url, in DOMString target);
void queueReload();
+ void queueLoadingScript(in DOMString script);
+ void queueNonLoadingScript(in DOMString script);
};
diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
index 8ff713f05..d64a734f0 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
@@ -507,4 +507,20 @@ void InjectedBundle::queueReload()
WKBundlePostMessage(m_bundle, messageName.get(), 0);
}
+void InjectedBundle::queueLoadingScript(WKStringRef script)
+{
+ m_useWorkQueue = true;
+
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueLoadingScript"));
+ WKBundlePostMessage(m_bundle, messageName.get(), script);
+}
+
+void InjectedBundle::queueNonLoadingScript(WKStringRef script)
+{
+ m_useWorkQueue = true;
+
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueNonLoadingScript"));
+ WKBundlePostMessage(m_bundle, messageName.get(), script);
+}
+
} // namespace WTR
diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
index 0b895846f..f3d2034ef 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
@@ -104,6 +104,8 @@ public:
void queueBackNavigation(unsigned howFarBackward);
void queueLoad(WKStringRef url, WKStringRef target);
void queueReload();
+ void queueLoadingScript(WKStringRef script);
+ void queueNonLoadingScript(WKStringRef script);
private:
InjectedBundle();
diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
index 740049544..23b5f34f2 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
@@ -75,6 +75,7 @@ TestRunner::TestRunner()
, m_dumpStatusCallbacks(false)
, m_dumpTitleChanges(false)
, m_dumpPixels(true)
+ , m_dumpSelectionRect(false)
, m_dumpFullScreenCallbacks(false)
, m_dumpFrameLoadCallbacks(false)
, m_dumpProgressFinishedCallback(false)
@@ -852,4 +853,16 @@ void TestRunner::queueReload()
InjectedBundle::shared().queueReload();
}
+void TestRunner::queueLoadingScript(JSStringRef script)
+{
+ WKRetainPtr<WKStringRef> scriptWK = toWK(script);
+ InjectedBundle::shared().queueLoadingScript(scriptWK.get());
+}
+
+void TestRunner::queueNonLoadingScript(JSStringRef script)
+{
+ WKRetainPtr<WKStringRef> scriptWK = toWK(script);
+ InjectedBundle::shared().queueNonLoadingScript(scriptWK.get());
+}
+
} // namespace WTR
diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
index 96d8220d6..f92e34220 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
@@ -265,6 +265,8 @@ public:
void queueBackNavigation(unsigned howFarBackward);
void queueLoad(JSStringRef url, JSStringRef target);
void queueReload();
+ void queueLoadingScript(JSStringRef script);
+ void queueNonLoadingScript(JSStringRef script);
private:
static const double waitToDumpWatchdogTimerInterval;
diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp
index 040adb544..fd9423220 100644
--- a/Tools/WebKitTestRunner/TestInvocation.cpp
+++ b/Tools/WebKitTestRunner/TestInvocation.cpp
@@ -466,6 +466,20 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "QueueLoadingScript")) {
+ ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+ WKStringRef script = static_cast<WKStringRef>(messageBody);
+ TestController::shared().workQueueManager().queueLoadingScript(toWTFString(script));
+ return;
+ }
+
+ if (WKStringIsEqualToUTF8CString(messageName, "QueueNonLoadingScript")) {
+ ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+ WKStringRef script = static_cast<WKStringRef>(messageBody);
+ TestController::shared().workQueueManager().queueNonLoadingScript(toWTFString(script));
+ return;
+ }
+
ASSERT_NOT_REACHED();
}
diff --git a/Tools/WebKitTestRunner/WorkQueueManager.cpp b/Tools/WebKitTestRunner/WorkQueueManager.cpp
index 1efa8ad12..738357908 100644
--- a/Tools/WebKitTestRunner/WorkQueueManager.cpp
+++ b/Tools/WebKitTestRunner/WorkQueueManager.cpp
@@ -29,6 +29,7 @@
#include "PlatformWebView.h"
#include "TestController.h"
#include <WebKit2/WKPage.h>
+#include <WebKit2/WKRetainPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/text/CString.h>
@@ -53,11 +54,48 @@ static inline bool goToItemAtIndex(int index)
return true;
}
+class WorkQueueItem {
+public:
+ enum Type {
+ Loading,
+ NonLoading
+ };
+
+ virtual ~WorkQueueItem() { }
+ virtual Type invoke() const = 0;
+};
+
+// Required by WKPageRunJavaScriptInMainFrame().
+static void runJavaScriptFunction(WKSerializedScriptValueRef, WKErrorRef, void*)
+{
+}
+
+template <WorkQueueItem::Type type>
+class ScriptItem : public WorkQueueItem {
+public:
+ explicit ScriptItem(const String& script)
+ : m_script(AdoptWK, WKStringCreateWithUTF8CString(script.utf8().data()))
+ {
+ }
+
+ WorkQueueItem::Type invoke() const
+ {
+ WKPageRunJavaScriptInMainFrame(mainPage(), m_script.get(), 0, runJavaScriptFunction);
+ return type;
+ }
+
+ WKRetainPtr<WKStringRef> m_script;
+};
+
WorkQueueManager::WorkQueueManager()
: m_processing(false)
{
}
+WorkQueueManager::~WorkQueueManager()
+{
+}
+
void WorkQueueManager::clearWorkQueue()
{
m_processing = false;
@@ -69,7 +107,7 @@ bool WorkQueueManager::processWorkQueue()
m_processing = false;
while (!m_processing && !m_workQueue.isEmpty()) {
OwnPtr<WorkQueueItem> item(m_workQueue.takeFirst());
- m_processing = item->invoke();
+ m_processing = (item->invoke() == WorkQueueItem::Loading);
}
return !m_processing;
@@ -85,15 +123,15 @@ void WorkQueueManager::queueLoad(const String& url, const String& target)
{
}
- bool invoke() const
+ WorkQueueItem::Type invoke() const
{
if (!m_target.isEmpty()) {
// FIXME: Use target. Some layout tests cannot pass as they rely on this functionality.
fprintf(stderr, "queueLoad for a specific target is not implemented.\n");
- return false;
+ return WorkQueueItem::NonLoading;
}
WKPageLoadURL(mainPage(), m_url.get());
- return true;
+ return WorkQueueItem::Loading;
}
WKRetainPtr<WKURLRef> m_url;
@@ -107,9 +145,9 @@ void WorkQueueManager::queueBackNavigation(unsigned howFarBackward)
{
class BackNavigationItem : public WorkQueueItem {
public:
- BackNavigationItem(unsigned howFarBackward) : m_howFarBackward(howFarBackward) { }
+ explicit BackNavigationItem(unsigned howFarBackward) : m_howFarBackward(howFarBackward) { }
- bool invoke() const { return goToItemAtIndex(-m_howFarBackward); }
+ WorkQueueItem::Type invoke() const { return goToItemAtIndex(-m_howFarBackward) ? WorkQueueItem::Loading : WorkQueueItem::NonLoading; }
unsigned m_howFarBackward;
};
@@ -121,16 +159,26 @@ void WorkQueueManager::queueReload()
{
class ReloadItem : public WorkQueueItem {
public:
- bool invoke() const
+ WorkQueueItem::Type invoke() const
{
WKPageReload(mainPage());
- return true;
+ return WorkQueueItem::Loading;
}
};
enqueue(new ReloadItem());
}
+void WorkQueueManager::queueLoadingScript(const String& script)
+{
+ enqueue(new ScriptItem<WorkQueueItem::Loading>(script));
+}
+
+void WorkQueueManager::queueNonLoadingScript(const String& script)
+{
+ enqueue(new ScriptItem<WorkQueueItem::NonLoading>(script));
+}
+
void WorkQueueManager::enqueue(WorkQueueItem* item)
{
ASSERT(item);
diff --git a/Tools/WebKitTestRunner/WorkQueueManager.h b/Tools/WebKitTestRunner/WorkQueueManager.h
index 665c7ab72..b9a22dde3 100644
--- a/Tools/WebKitTestRunner/WorkQueueManager.h
+++ b/Tools/WebKitTestRunner/WorkQueueManager.h
@@ -26,7 +26,6 @@
#ifndef WorkQueueManager_h
#define WorkQueueManager_h
-#include <WebKit2/WKRetainPtr.h>
#include <wtf/Deque.h>
#include <wtf/OwnPtr.h>
#include <wtf/text/WTFString.h>
@@ -37,6 +36,7 @@ class WorkQueueManager {
WTF_MAKE_NONCOPYABLE(WorkQueueManager);
public:
WorkQueueManager();
+ ~WorkQueueManager();
bool isWorkQueueEmpty() const { return m_workQueue.isEmpty(); }
void clearWorkQueue();
@@ -45,14 +45,11 @@ public:
void queueLoad(const String& url, const String& target);
void queueBackNavigation(unsigned howFarBackward);
void queueReload();
+ void queueLoadingScript(const String& script);
+ void queueNonLoadingScript(const String& script);
-private:
- class WorkQueueItem {
- public:
- virtual ~WorkQueueItem() { }
- virtual bool invoke() const = 0; // Returns 'true' if this started a load.
- };
- typedef Deque<OwnPtr<WorkQueueItem> > WorkQueue;
+private:
+ typedef Deque<OwnPtr<class WorkQueueItem> > WorkQueue;
void enqueue(WorkQueueItem*); // Adopts pointer.
diff --git a/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp b/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp
index d3fbfd2ef..498be14e4 100644
--- a/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp
+++ b/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2009 Apple Inc. All rights reserved.
* (C) 2011 Brent Fulgham <bfulgham@webkit.org>. All rights reserved.
* (C) 2010, 2011 Igalia S.L
+ * (C) 2012 Intel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -77,10 +78,39 @@ static void dumpBitmap(cairo_surface_t* surface, const char* checksum)
printPNG(data, dataLength, checksum);
}
-void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage, WKArrayRef /*repaintRects*/)
+static void paintRepaintRectOverlay(cairo_surface_t* surface, WKArrayRef repaintRects)
+{
+ cairo_t* context = cairo_create(surface);
+
+ cairo_push_group(context);
+
+ // Paint the gray mask over the original image.
+ cairo_set_source_rgba(context, 0, 0, 0, 0.66);
+ cairo_paint(context);
+
+ // Paint transparent rectangles over the mask to show the repainted regions.
+ cairo_set_source_rgba(context, 0, 0, 0, 0);
+ cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
+ size_t count = WKArrayGetSize(repaintRects);
+ for (size_t i = 0; i < count; ++i) {
+ WKRect rect = WKRectGetValue(static_cast<WKRectRef>(WKArrayGetItemAtIndex(repaintRects, i)));
+ cairo_rectangle(context, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+ cairo_fill(context);
+ }
+
+ cairo_pop_group_to_source(context);
+ cairo_paint(context);
+
+ cairo_destroy(context);
+}
+
+void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage, WKArrayRef repaintRects)
{
cairo_surface_t* surface = WKImageCreateCairoSurface(wkImage);
+ if (repaintRects)
+ paintRepaintRectOverlay(surface, repaintRects);
+
char actualHash[33];
computeMD5HashStringForCairoSurface(surface, actualHash);
if (!compareActualHashToExpectedAndDumpResults(actualHash))
diff --git a/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp b/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp
index e11e6e74a..00177db81 100644
--- a/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp
+++ b/Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp
@@ -66,6 +66,9 @@ private Q_SLOTS:
setSurfaceType(OpenGLSurface);
create();
QQuickWindowPrivate::get(this)->setRenderWithoutShowing(true);
+ } else {
+ QQuickWebViewExperimental experimental(m_view);
+ experimental.setRenderToOffscreenBuffer(true);
}
QWindowSystemInterface::handleWindowActivated(this);
@@ -82,8 +85,6 @@ PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGro
, m_windowIsKey(true)
, m_modalEventLoop(0)
{
- QQuickWebViewExperimental experimental(m_view);
- experimental.setRenderToOffscreenBuffer(true);
m_view->setAllowAnyHTTPSCertificateForLocalHost(true);
m_view->componentComplete();
}
@@ -164,6 +165,8 @@ WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
bool PlatformWebView::windowShapshotEnabled()
{
+ // We need a way to disable UI side rendering for tests because it is
+ // too slow without appropriate hardware.
static bool result;
static bool hasChecked = false;
if (!hasChecked)