summaryrefslogtreecommitdiffstats
path: root/WebKitTools/WebKitTestRunner
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/WebKitTestRunner')
-rw-r--r--WebKitTools/WebKitTestRunner/Configurations/InjectedBundleCommon.vsprops2
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl3
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp52
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h13
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp56
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h2
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp12
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h8
-rw-r--r--WebKitTools/WebKitTestRunner/TestController.cpp83
-rw-r--r--WebKitTools/WebKitTestRunner/TestController.h26
-rw-r--r--WebKitTools/WebKitTestRunner/TestInvocation.cpp36
-rw-r--r--WebKitTools/WebKitTestRunner/TestInvocation.h2
-rw-r--r--WebKitTools/WebKitTestRunner/WebKitTestRunner.sln2
-rw-r--r--WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm1
-rw-r--r--WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm4
-rw-r--r--WebKitTools/WebKitTestRunner/mac/main.mm9
-rw-r--r--WebKitTools/WebKitTestRunner/win/InjectedBundle.vcproj (renamed from WebKitTools/WebKitTestRunner/InjectedBundle/win/InjectedBundle.vcproj)32
-rw-r--r--WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp4
-rw-r--r--WebKitTools/WebKitTestRunner/win/WebKitTestRunner.sln39
-rw-r--r--WebKitTools/WebKitTestRunner/win/main.cpp5
20 files changed, 220 insertions, 171 deletions
diff --git a/WebKitTools/WebKitTestRunner/Configurations/InjectedBundleCommon.vsprops b/WebKitTools/WebKitTestRunner/Configurations/InjectedBundleCommon.vsprops
index 20a4852..e90ddb1 100644
--- a/WebKitTools/WebKitTestRunner/Configurations/InjectedBundleCommon.vsprops
+++ b/WebKitTools/WebKitTestRunner/Configurations/InjectedBundleCommon.vsprops
@@ -6,7 +6,7 @@
>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;$(ProjectDir)\..&quot;;&quot;$(ProjectDir)\..\..&quot;;&quot;$(ProjectDir)\..\Bindings&quot;;&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\private&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitOutputDir)\obj\InjectedBundle\DerivedSources\&quot;"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)\..&quot;;&quot;$(ProjectDir)\..\InjectedBundle\&quot;;&quot;$(ProjectDir)\..\InjectedBundle\Bindings&quot;;&quot;$(WebKitOutputDir)\Include&quot;;&quot;$(WebKitOutputDir)\Include\private&quot;;&quot;$(WebKitOutputDir)\Include\WebCore\ForwardingHeaders&quot;;&quot;$(WebKitLibrariesDir)\include&quot;;&quot;$(WebKitOutputDir)\obj\InjectedBundle\DerivedSources\&quot;"
ForcedIncludeFiles="WebKitTestRunnerPrefix.h"
/>
<Tool
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
index a0fbb85..2eca583 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
@@ -41,6 +41,9 @@ module WTR {
// Special options.
void keepWebHistory();
void setAcceptsEditing(in boolean value);
+ void setCanOpenWindows(in boolean value);
+ void setCloseRemainingWindowsWhenComplete(in boolean value);
+ unsigned long windowCount();
// Special DOM functions.
object computedStyleIncludingVisitedInfo(in object element);
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
index 0e99dde..095bd9c 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
@@ -27,13 +27,16 @@
#include "ActivateFonts.h"
#include "InjectedBundlePage.h"
-#include <WebKit2/WebKit2.h>
#include <WebKit2/WKBundle.h>
#include <WebKit2/WKBundlePage.h>
+#include <WebKit2/WKBundlePagePrivate.h>
#include <WebKit2/WKBundlePrivate.h>
#include <WebKit2/WKRetainPtr.h>
#include <WebKit2/WKStringCF.h>
+#include <WebKit2/WebKit2.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
namespace WTR {
@@ -45,6 +48,7 @@ InjectedBundle& InjectedBundle::shared()
InjectedBundle::InjectedBundle()
: m_bundle(0)
+ , m_mainPage(0)
{
}
@@ -58,9 +62,9 @@ void InjectedBundle::_willDestroyPage(WKBundleRef bundle, WKBundlePageRef page,
static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->willDestroyPage(page);
}
-void InjectedBundle::_didReceiveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo)
+void InjectedBundle::_didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
{
- static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didReceiveMessage(message);
+ static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didReceiveMessage(messageName, messageBody);
}
void InjectedBundle::initialize(WKBundleRef bundle)
@@ -81,37 +85,48 @@ void InjectedBundle::initialize(WKBundleRef bundle)
void InjectedBundle::done()
{
+ WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Done")));
+
std::string output = m_outputStream.str();
RetainPtr<CFStringRef> outputCFString(AdoptCF, CFStringCreateWithCString(0, output.c_str(), kCFStringEncodingUTF8));
- WKRetainPtr<WKStringRef> doneMessage(AdoptWK, WKStringCreateWithCFString(outputCFString.get()));
- WKBundlePostMessage(m_bundle, doneMessage.get());
+ WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithCFString(outputCFString.get()));
+
+ WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
}
void InjectedBundle::didCreatePage(WKBundlePageRef page)
{
// FIXME: we really need the main page ref to be sent over from the ui process
- m_mainPage = new InjectedBundlePage(page);
- m_pages.add(page, m_mainPage);
+ OwnPtr<InjectedBundlePage> pageWrapper = adoptPtr(new InjectedBundlePage(page));
+ if (!m_mainPage)
+ m_mainPage = pageWrapper.release();
+ else
+ m_otherPages.add(page, pageWrapper.leakPtr());
}
void InjectedBundle::willDestroyPage(WKBundlePageRef page)
{
- delete m_pages.take(page);
+ if (m_mainPage && m_mainPage->page() == page)
+ m_mainPage.clear();
+ else
+ delete m_otherPages.take(page);
}
-void InjectedBundle::didReceiveMessage(WKStringRef message)
+void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody)
{
- CFStringRef cfMessage = WKStringCopyCFString(0, message);
+ CFStringRef cfMessage = WKStringCopyCFString(0, messageName);
if (CFEqual(cfMessage, CFSTR("BeginTest"))) {
- WKRetainPtr<WKStringRef> ackMessage(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTestAck")));
- WKBundlePostMessage(m_bundle, ackMessage.get());
+ WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Ack")));
+ WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
+ WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get());
reset();
return;
}
- WKRetainPtr<WKStringRef> errorMessage(AdoptWK, WKStringCreateWithCFString(CFSTR("Error: Unknown.")));
- WKBundlePostMessage(m_bundle, errorMessage.get());
+ WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Error")));
+ WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("Unknown")));
+ WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get());
}
void InjectedBundle::reset()
@@ -120,6 +135,7 @@ void InjectedBundle::reset()
m_layoutTestController = LayoutTestController::create();
WKBundleSetShouldTrackVisitedLinks(m_bundle, false);
WKBundleRemoveAllVisitedLinks(m_bundle);
+ m_mainPage->reset();
}
void InjectedBundle::setShouldTrackVisitedLinks()
@@ -127,4 +143,12 @@ void InjectedBundle::setShouldTrackVisitedLinks()
WKBundleSetShouldTrackVisitedLinks(m_bundle, true);
}
+void InjectedBundle::closeOtherPages()
+{
+ Vector<WKBundlePageRef> pages;
+ copyKeysToVector(m_otherPages, pages);
+ for (size_t i = 0; i < pages.size(); ++i)
+ WKBundlePageClose(pages[i]);
+}
+
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
index 9bda922..42eb3a1 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
@@ -30,6 +30,7 @@
#include <WebKit2/WKBase.h>
#include <WebKit2/WKBundleBase.h>
#include <wtf/HashMap.h>
+#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
#include <sstream>
@@ -48,7 +49,9 @@ public:
void done();
LayoutTestController* layoutTestController() { return m_layoutTestController.get(); }
- InjectedBundlePage* page() { return m_mainPage; }
+ InjectedBundlePage* page() { return m_mainPage.get(); }
+ size_t pageCount() { return !!m_mainPage + m_otherPages.size(); }
+ void closeOtherPages();
std::ostringstream& os() { return m_outputStream; }
@@ -60,17 +63,17 @@ private:
static void _didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo);
static void _willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo);
- static void _didReceiveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
+ static void _didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
void didCreatePage(WKBundlePageRef page);
void willDestroyPage(WKBundlePageRef page);
- void didReceiveMessage(WKStringRef message);
+ void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody);
void reset();
WKBundleRef m_bundle;
- HashMap<WKBundlePageRef, InjectedBundlePage*> m_pages;
- InjectedBundlePage* m_mainPage;
+ HashMap<WKBundlePageRef, InjectedBundlePage*> m_otherPages;
+ OwnPtr<InjectedBundlePage> m_mainPage;
RefPtr<LayoutTestController> m_layoutTestController;
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
index 3632fb9..406787e 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
@@ -29,6 +29,7 @@
#include <JavaScriptCore/JSRetainPtr.h>
#include <WebKit2/WKArray.h>
#include <WebKit2/WKBundleFrame.h>
+#include <WebKit2/WKBundleFramePrivate.h>
#include <WebKit2/WKBundleNode.h>
#include <WebKit2/WKBundlePagePrivate.h>
#include <WebKit2/WKRetainPtr.h>
@@ -72,21 +73,6 @@ static ostream& operator<<(ostream& out, const WKRetainPtr<WKStringRef>& stringR
return out << stringRef.get();
}
-static ostream& operator<<(ostream& out, JSStringRef stringRef)
-{
- if (!stringRef)
- return out;
- CFIndex bufferLength = JSStringGetMaximumUTF8CStringSize(stringRef) + 1;
- Vector<char> buffer(bufferLength);
- JSStringGetUTF8CString(stringRef, buffer.data(), bufferLength);
- return out << buffer.data();
-}
-
-static ostream& operator<<(ostream& out, const JSRetainPtr<JSStringRef>& stringRef)
-{
- return out << stringRef.get();
-}
-
static string dumpPath(WKBundleNodeRef node)
{
if (!node)
@@ -169,6 +155,11 @@ InjectedBundlePage::~InjectedBundlePage()
{
}
+void InjectedBundlePage::reset()
+{
+ WKBundlePageClearMainFrameName(m_page);
+}
+
// Loader Client Callbacks
void InjectedBundlePage::_didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo)
@@ -238,23 +229,6 @@ static JSValueRef propertyValue(JSContextRef context, JSObjectRef object, const
return JSObjectGetProperty(context, object, propertyNameString.get(), &exception);
}
-static JSObjectRef propertyObject(JSContextRef context, JSObjectRef object, const char* propertyName)
-{
- JSValueRef value = propertyValue(context, object, propertyName);
- if (!value || !JSValueIsObject(context, value))
- return 0;
- return const_cast<JSObjectRef>(value);
-}
-
-static JSRetainPtr<JSStringRef> propertyString(JSContextRef context, JSObjectRef object, const char* propertyName)
-{
- JSValueRef value = propertyValue(context, object, propertyName);
- if (!value)
- return 0;
- JSValueRef exception;
- return JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, value, &exception));
-}
-
static double numericWindowPropertyValue(WKBundleFrameRef frame, const char* propertyName)
{
JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
@@ -285,8 +259,7 @@ static void dumpDescendantFrameScrollPositions(WKBundleFrameRef frame)
WKRetainPtr<WKArrayRef> childFrames(AdoptWK, WKBundleFrameCopyChildFrames(frame));
size_t size = WKArrayGetSize(childFrames.get());
for (size_t i = 0; i < size; ++i) {
- // FIXME: I don't like that we have to const_cast here. Can we change WKArray?
- WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(const_cast<void*>(WKArrayGetItemAtIndex(childFrames.get(), i)));
+ WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(WKArrayGetItemAtIndex(childFrames.get(), i));
dumpFrameScrollPosition(subframe, ShouldIncludeFrameName);
dumpDescendantFrameScrollPositions(subframe);
}
@@ -301,10 +274,8 @@ void InjectedBundlePage::dumpAllFrameScrollPositions()
static void dumpFrameText(WKBundleFrameRef frame)
{
- JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
- JSObjectRef document = propertyObject(context, JSContextGetGlobalObject(context), "document");
- JSObjectRef documentElement = propertyObject(context, document, "documentElement");
- InjectedBundle::shared().os() << propertyString(context, documentElement, "innerText") << "\n";
+ WKRetainPtr<WKStringRef> text(AdoptWK, WKBundleFrameCopyInnerText(frame));
+ InjectedBundle::shared().os() << text << "\n";
}
static void dumpDescendantFramesText(WKBundleFrameRef frame)
@@ -312,8 +283,7 @@ static void dumpDescendantFramesText(WKBundleFrameRef frame)
WKRetainPtr<WKArrayRef> childFrames(AdoptWK, WKBundleFrameCopyChildFrames(frame));
size_t size = WKArrayGetSize(childFrames.get());
for (size_t i = 0; i < size; ++i) {
- // FIXME: I don't like that we have to const_cast here. Can we change WKArray?
- WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(const_cast<void*>(WKArrayGetItemAtIndex(childFrames.get(), i)));
+ WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(WKArrayGetItemAtIndex(childFrames.get(), i));
WKRetainPtr<WKStringRef> subframeName(AdoptWK, WKBundleFrameCopyName(subframe));
InjectedBundle::shared().os() << "\n--------\nFrame: '" << subframeName << "'\n--------\n";
dumpFrameText(subframe);
@@ -361,6 +331,9 @@ void InjectedBundlePage::didFinishLoadForFrame(WKBundleFrameRef frame)
m_isLoading = false;
+ if (this != InjectedBundle::shared().page())
+ return;
+
if (InjectedBundle::shared().layoutTestController()->waitToDump())
return;
@@ -374,6 +347,9 @@ void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame)
m_isLoading = false;
+ if (this != InjectedBundle::shared().page())
+ return;
+
InjectedBundle::shared().done();
}
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
index 1b67af0..f7d64f9 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
@@ -40,6 +40,8 @@ public:
bool isLoading() { return m_isLoading; }
+ void reset();
+
private:
// Loader Client
static void _didStartProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef, const void* clientInfo);
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
index 2f59eb1..8fda21e 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
@@ -116,6 +116,7 @@ LayoutTestController::LayoutTestController()
: m_whatToDump(RenderTree)
, m_shouldDumpAllFrameScrollPositions(false)
, m_shouldAllowEditing(true)
+ , m_shouldCloseExtraWindows(false)
, m_dumpEditingCallbacks(false)
, m_dumpStatusCallbacks(false)
, m_waitToDump(false)
@@ -242,6 +243,17 @@ bool LayoutTestController::isCommandEnabled(JSStringRef name)
return WKBundlePageIsEditingCommandEnabled(InjectedBundle::shared().page()->page(), toWK(name).get());
}
+void LayoutTestController::setCanOpenWindows(bool)
+{
+ // It's not clear if or why any tests require opening windows be forbidden.
+ // For now, just ignore this setting, and if we find later it's needed we can add it.
+}
+
+unsigned LayoutTestController::windowCount()
+{
+ return InjectedBundle::shared().pageCount();
+}
+
// Object Creation
void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
index 9f0641b..75aeb9e 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
@@ -60,6 +60,9 @@ public:
// Special options.
void keepWebHistory();
void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; }
+ void setCanOpenWindows(bool);
+ void setCloseRemainingWindowsWhenComplete(bool value) { m_shouldCloseExtraWindows = value; }
+ unsigned windowCount();
// Special DOM functions.
JSValueRef computedStyleIncludingVisitedInfo(JSValueRef element);
@@ -92,12 +95,17 @@ public:
bool shouldAllowEditing() const { return m_shouldAllowEditing; }
+ bool shouldCloseExtraWindowsAfterRunningTest() const { return m_shouldCloseExtraWindows; }
+
private:
LayoutTestController();
WhatToDump m_whatToDump;
bool m_shouldDumpAllFrameScrollPositions;
+
bool m_shouldAllowEditing;
+ bool m_shouldCloseExtraWindows;
+
bool m_dumpEditingCallbacks;
bool m_dumpStatusCallbacks;
bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
diff --git a/WebKitTools/WebKitTestRunner/TestController.cpp b/WebKitTools/WebKitTestRunner/TestController.cpp
index 4f8cd6b..93857a7 100644
--- a/WebKitTools/WebKitTestRunner/TestController.cpp
+++ b/WebKitTools/WebKitTestRunner/TestController.cpp
@@ -28,21 +28,62 @@
#include "PlatformWebView.h"
#include "TestInvocation.h"
#include <WebKit2/WKContextPrivate.h>
+#include <wtf/PassOwnPtr.h>
namespace WTR {
+static TestController* controller;
+
TestController& TestController::shared()
{
- static TestController& shared = *new TestController;
- return shared;
+ ASSERT(controller);
+ return *controller;
}
-TestController::TestController()
+TestController::TestController(int argc, const char* argv[])
: m_dumpPixels(false)
, m_verbose(false)
, m_printSeparators(false)
, m_usingServerMode(false)
{
+ initialize(argc, argv);
+ controller = this;
+ run();
+ controller = 0;
+}
+
+TestController::~TestController()
+{
+}
+
+static void closeOtherPage(WKPageRef page, const void* clientInfo)
+{
+ WKPageClose(page);
+ const PlatformWebView* view = static_cast<const PlatformWebView*>(clientInfo);
+ delete view;
+}
+
+static WKPageRef createOtherPage(WKPageRef oldPage, const void*)
+{
+ PlatformWebView* view = new PlatformWebView(WKPageGetPageNamespace(oldPage));
+ WKPageRef newPage = view->page();
+
+ view->resizeTo(800, 600);
+
+ WKPageUIClient otherPageUIClient = {
+ 0,
+ view,
+ createOtherPage,
+ 0,
+ closeOtherPage,
+ 0,
+ 0,
+ 0
+ };
+ WKPageSetPageUIClient(newPage, &otherPageUIClient);
+
+ WKRetain(newPage);
+ return newPage;
}
void TestController::initialize(int argc, const char* argv[])
@@ -75,21 +116,33 @@ void TestController::initialize(int argc, const char* argv[])
m_printSeparators = m_paths.size() > 1;
initializeInjectedBundlePath();
- initializeTestPluginPath();
+ initializeTestPluginDirectory();
m_context.adopt(WKContextCreateWithInjectedBundlePath(injectedBundlePath()));
- WKContextInjectedBundleClient injectedBundlePathClient = {
+ WKContextInjectedBundleClient injectedBundleClient = {
0,
this,
- _didReceiveMessageFromInjectedBundle
+ didReceiveMessageFromInjectedBundle
};
- WKContextSetInjectedBundleClient(m_context.get(), &injectedBundlePathClient);
+ WKContextSetInjectedBundleClient(m_context.get(), &injectedBundleClient);
- _WKContextSetAdditionalPluginPath(m_context.get(), testPluginPath());
+ _WKContextSetAdditionalPluginsDirectory(m_context.get(), testPluginDirectory());
m_pageNamespace.adopt(WKPageNamespaceCreate(m_context.get()));
- m_mainWebView = new PlatformWebView(m_pageNamespace.get());
+ m_mainWebView = adoptPtr(new PlatformWebView(m_pageNamespace.get()));
+
+ WKPageUIClient pageUIClient = {
+ 0,
+ this,
+ createOtherPage,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ };
+ WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient);
}
void TestController::runTest(const char* test)
@@ -114,7 +167,7 @@ void TestController::runTestingServerLoop()
}
}
-bool TestController::run()
+void TestController::run()
{
if (m_usingServerMode)
runTestingServerLoop();
@@ -122,18 +175,16 @@ bool TestController::run()
for (size_t i = 0; i < m_paths.size(); ++i)
runTest(m_paths[i].c_str());
}
-
- return true;
}
-void TestController::_didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
+void TestController::didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
{
- static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(message);
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(messageName, messageBody);
}
-void TestController::didReceiveMessageFromInjectedBundle(WKStringRef message)
+void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
{
- m_currentInvocation->didReceiveMessageFromInjectedBundle(message);
+ m_currentInvocation->didReceiveMessageFromInjectedBundle(messageName, messageBody);
}
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/TestController.h b/WebKitTools/WebKitTestRunner/TestController.h
index bd073bf..5754728 100644
--- a/WebKitTools/WebKitTestRunner/TestController.h
+++ b/WebKitTools/WebKitTestRunner/TestController.h
@@ -36,39 +36,37 @@ namespace WTR {
class TestInvocation;
class PlatformWebView;
+// FIXME: Rename this TestRunner?
class TestController {
public:
static TestController& shared();
- // Initialize the TestController.
- void initialize(int argc, const char *argv[]);
-
- // Returns true if all the tests passed, false otherwise.
- bool run();
+ TestController(int argc, const char* argv[]);
+ ~TestController();
bool verbose() const { return m_verbose; }
WKStringRef injectedBundlePath() { return m_injectedBundlePath.get(); }
- WKStringRef testPluginPath() { return m_testPluginPath.get(); }
+ WKStringRef testPluginDirectory() { return m_testPluginDirectory.get(); }
- PlatformWebView* mainWebView() { return m_mainWebView; }
+ PlatformWebView* mainWebView() { return m_mainWebView.get(); }
WKPageNamespaceRef pageNamespace() { return m_pageNamespace.get(); }
WKContextRef context() { return m_context.get(); }
private:
- TestController();
- ~TestController();
+ void initialize(int argc, const char* argv[]);
+ void run();
void runTestingServerLoop();
void runTest(const char* pathOrURL);
void platformInitialize();
void initializeInjectedBundlePath();
- void initializeTestPluginPath();
+ void initializeTestPluginDirectory();
// WKContextInjectedBundleClient
- static void _didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void*);
- void didReceiveMessageFromInjectedBundle(WKStringRef message);
+ static void didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void*);
+ void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
OwnPtr<TestInvocation> m_currentInvocation;
@@ -78,9 +76,9 @@ private:
bool m_usingServerMode;
std::vector<std::string> m_paths;
WKRetainPtr<WKStringRef> m_injectedBundlePath;
- WKRetainPtr<WKStringRef> m_testPluginPath;
+ WKRetainPtr<WKStringRef> m_testPluginDirectory;
- PlatformWebView* m_mainWebView;
+ OwnPtr<PlatformWebView> m_mainWebView;
WKRetainPtr<WKContextRef> m_context;
WKRetainPtr<WKPageNamespaceRef> m_pageNamespace;
};
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.cpp b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
index b6e950f..658911b 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.cpp
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
@@ -108,8 +108,9 @@ void TestInvocation::invoke()
sizeWebViewForCurrentTest(m_pathOrURL);
resetPreferencesToConsistentValues();
- WKRetainPtr<WKStringRef> message(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
- WKContextPostMessageToInjectedBundle(TestController::shared().context(), message.get());
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
+ WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("")));
+ WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), messageBody.get());
runUntil(m_gotInitialResponse);
if (m_error) {
@@ -139,11 +140,10 @@ void TestInvocation::dump(const char* stringToDump)
fflush(stderr);
}
-void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef message)
+void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
{
- RetainPtr<CFStringRef> cfMessage(AdoptCF, WKStringCopyCFString(0, message));
-
- if (CFEqual(cfMessage.get(), CFSTR("Error"))) {
+ RetainPtr<CFStringRef> cfMessageName(AdoptCF, WKStringCopyCFString(0, messageName));
+ if (CFEqual(cfMessageName.get(), CFSTR("Error"))) {
// Set all states to true to stop spinning the runloop.
m_gotInitialResponse = true;
m_gotFinalMessage = true;
@@ -151,15 +151,27 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef message)
return;
}
- if (CFEqual(cfMessage.get(), CFSTR("BeginTestAck"))) {
- m_gotInitialResponse = true;
- return;
+ if (CFEqual(cfMessageName.get(), CFSTR("Ack"))) {
+ ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+ RetainPtr<CFStringRef> cfMessageBody(AdoptCF, WKStringCopyCFString(0, static_cast<WKStringRef>(messageBody)));
+
+ if (CFEqual(cfMessageBody.get(), CFSTR("BeginTest"))) {
+ m_gotInitialResponse = true;
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
}
- OwnPtr<Vector<char> > utf8Message = WKStringToUTF8(message);
+ if (CFEqual(cfMessageName.get(), CFSTR("Done"))) {
+ ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
+ OwnPtr<Vector<char> > utf8Message = WKStringToUTF8(static_cast<WKStringRef>(messageBody));
+ dump(utf8Message->data());
+ m_gotFinalMessage = true;
+ return;
+ }
- dump(utf8Message->data());
- m_gotFinalMessage = true;
+ ASSERT_NOT_REACHED();
}
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.h b/WebKitTools/WebKitTestRunner/TestInvocation.h
index e064a8f..484e61d 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.h
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.h
@@ -37,7 +37,7 @@ public:
~TestInvocation();
void invoke();
- void didReceiveMessageFromInjectedBundle(WKStringRef message);
+ void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
private:
void dump(const char*);
diff --git a/WebKitTools/WebKitTestRunner/WebKitTestRunner.sln b/WebKitTools/WebKitTestRunner/WebKitTestRunner.sln
index e2435d3..670dd30 100644
--- a/WebKitTools/WebKitTestRunner/WebKitTestRunner.sln
+++ b/WebKitTools/WebKitTestRunner/WebKitTestRunner.sln
@@ -18,7 +18,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageDiff", "..\DumpRenderT
{DA31DA52-6675-48D4-89E0-333A7144397C} = {DA31DA52-6675-48D4-89E0-333A7144397C}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InjectedBundle", "InjectedBundle\win\InjectedBundle.vcproj", "{CBC3391C-F060-4BF5-A66E-81404168816B}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InjectedBundle", "win\InjectedBundle.vcproj", "{CBC3391C-F060-4BF5-A66E-81404168816B}"
ProjectSection(ProjectDependencies) = postProject
{4343BC0B-A2E0-4B48-8277-F33CFBFA83CD} = {4343BC0B-A2E0-4B48-8277-F33CFBFA83CD}
EndProjectSection
diff --git a/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm b/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
index 21db2eb..4e2a60c 100644
--- a/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
+++ b/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
@@ -38,6 +38,7 @@ PlatformWebView::PlatformWebView(WKPageNamespaceRef namespaceRef)
[[m_window contentView] addSubview:m_view];
[m_window orderBack:nil];
[m_window setAutodisplay:NO];
+ [m_window setReleasedWhenClosed:NO];
}
void PlatformWebView::resizeTo(unsigned width, unsigned height)
diff --git a/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm b/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
index ae4cc2f..1a71b5d 100644
--- a/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
+++ b/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
@@ -40,9 +40,9 @@ void TestController::initializeInjectedBundlePath()
m_injectedBundlePath.adopt(WKStringCreateWithCFString((CFStringRef)nsBundlePath));
}
-void TestController::initializeTestPluginPath()
+void TestController::initializeTestPluginDirectory()
{
- m_testPluginPath.adopt(WKStringCreateWithCFString((CFStringRef)[[NSBundle mainBundle] bundlePath]));
+ m_testPluginDirectory.adopt(WKStringCreateWithCFString((CFStringRef)[[NSBundle mainBundle] bundlePath]));
}
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/mac/main.mm b/WebKitTools/WebKitTestRunner/mac/main.mm
index 021c124..d2f26ab 100644
--- a/WebKitTools/WebKitTestRunner/mac/main.mm
+++ b/WebKitTools/WebKitTestRunner/mac/main.mm
@@ -28,13 +28,10 @@
int main(int argc, const char* argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
[NSApplication sharedApplication];
-
- WTR::TestController::shared().initialize(argc, argv);
- WTR::TestController::shared().run();
-
+ {
+ WTR::TestController controller(argc, argv);
+ }
[pool drain];
-
return 0;
}
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/win/InjectedBundle.vcproj b/WebKitTools/WebKitTestRunner/win/InjectedBundle.vcproj
index be20bab..d283083 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/win/InjectedBundle.vcproj
+++ b/WebKitTools/WebKitTestRunner/win/InjectedBundle.vcproj
@@ -18,7 +18,7 @@
<Configuration
Name="Debug|Win32"
ConfigurationType="2"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;..\..\Configurations\InjectedBundleCommon.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;..\Configurations\InjectedBundleCommon.vsprops"
CharacterSet="1"
>
<Tool
@@ -79,7 +79,7 @@
<Configuration
Name="Release|Win32"
ConfigurationType="2"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\release.vsprops;..\..\Configurations\InjectedBundleCommon.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\release.vsprops;..\Configurations\InjectedBundleCommon.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
@@ -141,7 +141,7 @@
<Configuration
Name="Debug_All|Win32"
ConfigurationType="2"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_all.vsprops;..\..\Configurations\InjectedBundleCommon.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_all.vsprops;..\Configurations\InjectedBundleCommon.vsprops"
CharacterSet="1"
>
<Tool
@@ -202,7 +202,7 @@
<Configuration
Name="Debug_Internal|Win32"
ConfigurationType="2"
- InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;..\..\Configurations\InjectedBundleCommon.vsprops"
+ InheritedPropertySheets="$(WebKitLibrariesDir)\tools\vsprops\common.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug.vsprops;$(WebKitLibrariesDir)\tools\vsprops\debug_internal.vsprops;..\Configurations\InjectedBundleCommon.vsprops"
CharacterSet="1"
>
<Tool
@@ -268,19 +268,19 @@
Name="Bindings"
>
<File
- RelativePath="..\Bindings\CodeGeneratorTestRunner.pm"
+ RelativePath="..\InjectedBundle\Bindings\CodeGeneratorTestRunner.pm"
>
</File>
<File
- RelativePath="..\Bindings\JSWrappable.h"
+ RelativePath="..\InjectedBundle\Bindings\JSWrappable.h"
>
</File>
<File
- RelativePath="..\Bindings\JSWrapper.cpp"
+ RelativePath="..\InjectedBundle\Bindings\JSWrapper.cpp"
>
</File>
<File
- RelativePath="..\Bindings\JSWrapper.h"
+ RelativePath="..\InjectedBundle\Bindings\JSWrapper.h"
>
</File>
</Filter>
@@ -297,35 +297,35 @@
</File>
</Filter>
<File
- RelativePath="ActivateFonts.cpp"
+ RelativePath="..\InjectedBundle\win\ActivateFonts.cpp"
>
</File>
<File
- RelativePath="..\InjectedBundle.cpp"
+ RelativePath="..\InjectedBundle\InjectedBundle.cpp"
>
</File>
<File
- RelativePath="..\InjectedBundle.h"
+ RelativePath="..\InjectedBundle\InjectedBundle.h"
>
</File>
<File
- RelativePath="..\InjectedBundleMain.cpp"
+ RelativePath="..\InjectedBundle\InjectedBundleMain.cpp"
>
</File>
<File
- RelativePath="..\InjectedBundlePage.cpp"
+ RelativePath="..\InjectedBundle\InjectedBundlePage.cpp"
>
</File>
<File
- RelativePath="..\InjectedBundlePage.h"
+ RelativePath="..\InjectedBundle\InjectedBundlePage.h"
>
</File>
<File
- RelativePath="..\LayoutTestController.cpp"
+ RelativePath="..\InjectedBundle\LayoutTestController.cpp"
>
</File>
<File
- RelativePath="..\LayoutTestController.h"
+ RelativePath="..\InjectedBundle\LayoutTestController.h"
>
</File>
</Files>
diff --git a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
index 987481a..9bec373 100644
--- a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
+++ b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
@@ -50,11 +50,11 @@ void TestController::initializeInjectedBundlePath()
m_injectedBundlePath.adopt(WKStringCreateWithCFString(bundlePath));
}
-void TestController::initializeTestPluginPath()
+void TestController::initializeTestPluginDirectory()
{
CFStringRef exeContainerPath = CFURLCopyFileSystemPath(CFURLCreateCopyDeletingLastPathComponent(0, CFBundleCopyExecutableURL(CFBundleGetMainBundle())), kCFURLWindowsPathStyle);
CFMutableStringRef bundlePath = CFStringCreateMutableCopy(0, 0, exeContainerPath);
- m_testPluginPath.adopt(WKStringCreateWithCFString(bundlePath));
+ m_testPluginDirectory.adopt(WKStringCreateWithCFString(bundlePath));
}
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/win/WebKitTestRunner.sln b/WebKitTools/WebKitTestRunner/win/WebKitTestRunner.sln
deleted file mode 100644
index 757b7fb..0000000
--- a/WebKitTools/WebKitTestRunner/win/WebKitTestRunner.sln
+++ /dev/null
@@ -1,39 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKitTestRunner", "WebKitTestRunner.vcproj", "{3B99669B-1817-443B-BCBE-835580146668}"
- ProjectSection(ProjectDependencies) = postProject
- {CBC3391C-F060-4BF5-A66E-81404168816B} = {CBC3391C-F060-4BF5-A66E-81404168816B}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InjectedBundle", "..\InjectedBundle\win\InjectedBundle.vcproj", "{CBC3391C-F060-4BF5-A66E-81404168816B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug_All|Win32 = Debug_All|Win32
- Debug_Internal|Win32 = Debug_Internal|Win32
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3B99669B-1817-443B-BCBE-835580146668}.Debug_All|Win32.ActiveCfg = Debug_All|Win32
- {3B99669B-1817-443B-BCBE-835580146668}.Debug_All|Win32.Build.0 = Debug_All|Win32
- {3B99669B-1817-443B-BCBE-835580146668}.Debug_Internal|Win32.ActiveCfg = Debug_Internal|Win32
- {3B99669B-1817-443B-BCBE-835580146668}.Debug_Internal|Win32.Build.0 = Debug_Internal|Win32
- {3B99669B-1817-443B-BCBE-835580146668}.Debug|Win32.ActiveCfg = Debug|Win32
- {3B99669B-1817-443B-BCBE-835580146668}.Debug|Win32.Build.0 = Debug|Win32
- {3B99669B-1817-443B-BCBE-835580146668}.Release|Win32.ActiveCfg = Release|Win32
- {3B99669B-1817-443B-BCBE-835580146668}.Release|Win32.Build.0 = Release|Win32
- {CBC3391C-F060-4BF5-A66E-81404168816B}.Debug_All|Win32.ActiveCfg = Debug_All|Win32
- {CBC3391C-F060-4BF5-A66E-81404168816B}.Debug_All|Win32.Build.0 = Debug_All|Win32
- {CBC3391C-F060-4BF5-A66E-81404168816B}.Debug_Internal|Win32.ActiveCfg = Debug_Internal|Win32
- {CBC3391C-F060-4BF5-A66E-81404168816B}.Debug_Internal|Win32.Build.0 = Debug_Internal|Win32
- {CBC3391C-F060-4BF5-A66E-81404168816B}.Debug|Win32.ActiveCfg = Debug|Win32
- {CBC3391C-F060-4BF5-A66E-81404168816B}.Debug|Win32.Build.0 = Debug|Win32
- {CBC3391C-F060-4BF5-A66E-81404168816B}.Release|Win32.ActiveCfg = Release|Win32
- {CBC3391C-F060-4BF5-A66E-81404168816B}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/WebKitTools/WebKitTestRunner/win/main.cpp b/WebKitTools/WebKitTestRunner/win/main.cpp
index 96e55b4..6ef0f66 100644
--- a/WebKitTools/WebKitTestRunner/win/main.cpp
+++ b/WebKitTools/WebKitTestRunner/win/main.cpp
@@ -27,8 +27,9 @@
int main(int argc, const char* argv[])
{
- WTR::TestController::shared().initialize(argc, argv);
- WTR::TestController::shared().run();
+ {
+ WTR::TestController controller(argc, argv);
+ }
return 0;
}