summaryrefslogtreecommitdiffstats
path: root/WebKitTools/WebKitTestRunner
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-08-19 17:55:56 +0100
committerIain Merrick <husky@google.com>2010-08-23 11:05:40 +0100
commitf486d19d62f1bc33246748b14b14a9dfa617b57f (patch)
tree195485454c93125455a30e553a73981c3816144d /WebKitTools/WebKitTestRunner
parent6ba0b43722d16bc295606bec39f396f596e4fef1 (diff)
downloadexternal_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.zip
external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.gz
external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.bz2
Merge WebKit at r65615 : Initial merge by git.
Change-Id: Ifbf384f4531e3b58475a662e38195c2d9152ae79
Diffstat (limited to 'WebKitTools/WebKitTestRunner')
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp33
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h10
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp72
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h1
-rw-r--r--WebKitTools/WebKitTestRunner/PlatformWebView.h1
-rw-r--r--WebKitTools/WebKitTestRunner/StringFunctions.h10
-rw-r--r--WebKitTools/WebKitTestRunner/TestController.cpp81
-rw-r--r--WebKitTools/WebKitTestRunner/TestController.h19
-rw-r--r--WebKitTools/WebKitTestRunner/TestInvocation.cpp15
-rw-r--r--WebKitTools/WebKitTestRunner/TestInvocation.h5
-rw-r--r--WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj4
-rw-r--r--WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm5
-rw-r--r--WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm10
-rw-r--r--WebKitTools/WebKitTestRunner/mac/TestInvocationMac.mm36
-rw-r--r--WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp7
-rw-r--r--WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp28
-rw-r--r--WebKitTools/WebKitTestRunner/win/TestInvocationWin.cpp42
-rw-r--r--WebKitTools/WebKitTestRunner/win/WebKitTestRunner.vcproj4
18 files changed, 263 insertions, 120 deletions
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
index 02dfeb1..b2aa836 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
@@ -49,6 +49,7 @@ InjectedBundle& InjectedBundle::shared()
InjectedBundle::InjectedBundle()
: m_bundle(0)
, m_mainPage(0)
+ , m_state(Idle)
{
}
@@ -84,17 +85,6 @@ void InjectedBundle::initialize(WKBundleRef bundle)
WKBundleActivateMacFontAscentHack(m_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> 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
@@ -121,7 +111,7 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get());
- reset();
+ beginTesting();
return;
}
@@ -130,8 +120,10 @@ void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messag
WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get());
}
-void InjectedBundle::reset()
+void InjectedBundle::beginTesting()
{
+ m_state = Testing;
+
m_outputStream.str("");
m_layoutTestController = LayoutTestController::create();
@@ -144,6 +136,21 @@ void InjectedBundle::reset()
m_mainPage->reset();
}
+void InjectedBundle::done()
+{
+ m_mainPage->stopLoading();
+
+ 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> doneMessageBody(AdoptWK, WKStringCreateWithCFString(outputCFString.get()));
+
+ WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
+
+ m_state = Idle;
+}
+
void InjectedBundle::closeOtherPages()
{
Vector<WKBundlePageRef> pages;
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
index ba021b1..d094f42 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
@@ -61,6 +61,8 @@ public:
void done();
std::ostringstream& os() { return m_outputStream; }
+ bool isTestRunning() { return m_state == Testing; }
+
private:
InjectedBundle();
~InjectedBundle();
@@ -73,7 +75,7 @@ private:
void willDestroyPage(WKBundlePageRef page);
void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody);
- void reset();
+ void beginTesting();
WKBundleRef m_bundle;
HashMap<WKBundlePageRef, InjectedBundlePage*> m_otherPages;
@@ -84,6 +86,12 @@ private:
RefPtr<EventSendingController> m_eventSendingController;
std::ostringstream m_outputStream;
+
+ enum State {
+ Idle,
+ Testing
+ };
+ State m_state;
};
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
index 40a098e..424f7ab 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
@@ -147,6 +147,12 @@ InjectedBundlePage::~InjectedBundlePage()
{
}
+void InjectedBundlePage::stopLoading()
+{
+ WKBundlePageStopLoading(m_page);
+ m_isLoading = false;
+}
+
void InjectedBundlePage::reset()
{
WKBundlePageClearMainFrameName(m_page);
@@ -235,6 +241,9 @@ void InjectedBundlePage::didRunInsecureContentForFrame(WKBundlePageRef page, WKB
void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (frame == WKBundlePageGetMainFrame(m_page))
m_isLoading = true;
}
@@ -331,6 +340,8 @@ void InjectedBundlePage::dumpAllFramesText()
void InjectedBundlePage::dump()
{
+ ASSERT(InjectedBundle::shared().isTestRunning());
+
InjectedBundle::shared().layoutTestController()->invalidateWaitToDumpWatchdog();
switch (InjectedBundle::shared().layoutTestController()->whatToDump()) {
@@ -357,6 +368,9 @@ void InjectedBundlePage::dump()
void InjectedBundlePage::didFinishLoadForFrame(WKBundleFrameRef frame)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (!WKBundleFrameIsMainFrame(frame))
return;
@@ -373,6 +387,9 @@ void InjectedBundlePage::didFinishLoadForFrame(WKBundleFrameRef frame)
void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (!WKBundleFrameIsMainFrame(frame))
return;
@@ -386,6 +403,9 @@ void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame)
void InjectedBundlePage::didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef frame)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (!InjectedBundle::shared().layoutTestController()->shouldDumpTitleChanges())
return;
@@ -394,6 +414,9 @@ void InjectedBundlePage::didReceiveTitleForFrame(WKStringRef title, WKBundleFram
void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
JSValueRef exception = 0;
InjectedBundle::shared().layoutTestController()->makeWindowObject(context, window, &exception);
InjectedBundle::shared().gcController()->makeWindowObject(context, window, &exception);
@@ -414,6 +437,9 @@ void InjectedBundlePage::didChangeLocationWithinPageForFrame(WKBundleFrameRef fr
void InjectedBundlePage::didFinishDocumentLoadForFrame(WKBundleFrameRef frame)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
unsigned pendingFrameUnloadEvents = WKBundleFrameGetPendingUnloadCount(frame);
if (pendingFrameUnloadEvents)
InjectedBundle::shared().os() << frame << " - has " << pendingFrameUnloadEvents << " onunload handler(s)\n";
@@ -460,12 +486,18 @@ void InjectedBundlePage::willRunJavaScriptPrompt(WKBundlePageRef page, WKStringR
void InjectedBundlePage::willAddMessageToConsole(WKStringRef message, uint32_t lineNumber)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
// FIXME: Strip file: urls.
InjectedBundle::shared().os() << "CONSOLE MESSAGE: line " << lineNumber << ": " << message << "\n";
}
void InjectedBundlePage::willSetStatusbarText(WKStringRef statusbarText)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (!InjectedBundle::shared().layoutTestController()->shouldDumpStatusCallbacks())
return;
@@ -474,11 +506,17 @@ void InjectedBundlePage::willSetStatusbarText(WKStringRef statusbarText)
void InjectedBundlePage::willRunJavaScriptAlert(WKStringRef message, WKBundleFrameRef)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
InjectedBundle::shared().os() << "ALERT: " << message << "\n";
}
void InjectedBundlePage::willRunJavaScriptConfirm(WKStringRef message, WKBundleFrameRef)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
InjectedBundle::shared().os() << "CONFIRM: " << message << "\n";
}
@@ -546,6 +584,9 @@ void InjectedBundlePage::didChangeSelection(WKBundlePageRef page, WKStringRef no
bool InjectedBundlePage::shouldBeginEditing(WKBundleRangeRef range)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return true;
+
if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
InjectedBundle::shared().os() << "EDITING DELEGATE: shouldBeginEditingInDOMRange:" << range << "\n";
return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
@@ -553,6 +594,9 @@ bool InjectedBundlePage::shouldBeginEditing(WKBundleRangeRef range)
bool InjectedBundlePage::shouldEndEditing(WKBundleRangeRef range)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return true;
+
if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
InjectedBundle::shared().os() << "EDITING DELEGATE: shouldEndEditingInDOMRange:" << range << "\n";
return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
@@ -560,6 +604,9 @@ bool InjectedBundlePage::shouldEndEditing(WKBundleRangeRef range)
bool InjectedBundlePage::shouldInsertNode(WKBundleNodeRef node, WKBundleRangeRef rangeToReplace, WKInsertActionType action)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return true;
+
static const char* insertactionstring[] = {
"WebViewInsertActionTyped",
"WebViewInsertActionPasted",
@@ -573,6 +620,9 @@ bool InjectedBundlePage::shouldInsertNode(WKBundleNodeRef node, WKBundleRangeRef
bool InjectedBundlePage::shouldInsertText(WKStringRef text, WKBundleRangeRef rangeToReplace, WKInsertActionType action)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return true;
+
static const char *insertactionstring[] = {
"WebViewInsertActionTyped",
"WebViewInsertActionPasted",
@@ -586,6 +636,9 @@ bool InjectedBundlePage::shouldInsertText(WKStringRef text, WKBundleRangeRef ran
bool InjectedBundlePage::shouldDeleteRange(WKBundleRangeRef range)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return true;
+
if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
InjectedBundle::shared().os() << "EDITING DELEGATE: shouldDeleteDOMRange:" << range << "\n";
return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
@@ -593,6 +646,9 @@ bool InjectedBundlePage::shouldDeleteRange(WKBundleRangeRef range)
bool InjectedBundlePage::shouldChangeSelectedRange(WKBundleRangeRef fromRange, WKBundleRangeRef toRange, WKAffinityType affinity, bool stillSelecting)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return true;
+
static const char *affinitystring[] = {
"NSSelectionAffinityUpstream",
"NSSelectionAffinityDownstream"
@@ -609,6 +665,9 @@ bool InjectedBundlePage::shouldChangeSelectedRange(WKBundleRangeRef fromRange, W
bool InjectedBundlePage::shouldApplyStyle(WKBundleCSSStyleDeclarationRef style, WKBundleRangeRef range)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return true;
+
if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
InjectedBundle::shared().os() << "EDITING DELEGATE: shouldApplyStyle:" << style << " toElementsInDOMRange:" << range << "\n";
return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
@@ -616,27 +675,38 @@ bool InjectedBundlePage::shouldApplyStyle(WKBundleCSSStyleDeclarationRef style,
void InjectedBundlePage::didBeginEditing(WKStringRef notificationName)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidBeginEditing:" << notificationName << "\n";
}
void InjectedBundlePage::didEndEditing(WKStringRef notificationName)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidEndEditing:" << notificationName << "\n";
}
void InjectedBundlePage::didChange(WKStringRef notificationName)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChange:" << notificationName << "\n";
}
void InjectedBundlePage::didChangeSelection(WKStringRef notificationName)
{
+ if (!InjectedBundle::shared().isTestRunning())
+ return;
+
if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChangeSelection:" << notificationName << "\n";
}
-
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
index 8909883..3f63bf3 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
@@ -38,6 +38,7 @@ public:
WKBundlePageRef page() const { return m_page; }
void dump();
+ void stopLoading();
bool isLoading() { return m_isLoading; }
void reset();
diff --git a/WebKitTools/WebKitTestRunner/PlatformWebView.h b/WebKitTools/WebKitTestRunner/PlatformWebView.h
index 6fc4509..29c63ae 100644
--- a/WebKitTools/WebKitTestRunner/PlatformWebView.h
+++ b/WebKitTools/WebKitTestRunner/PlatformWebView.h
@@ -51,6 +51,7 @@ public:
WKPageRef page();
PlatformWKView platformView() { return m_view; }
void resizeTo(unsigned width, unsigned height);
+ void focus();
private:
PlatformWKView m_view;
diff --git a/WebKitTools/WebKitTestRunner/StringFunctions.h b/WebKitTools/WebKitTestRunner/StringFunctions.h
index 4f8fe93..8195606 100644
--- a/WebKitTools/WebKitTestRunner/StringFunctions.h
+++ b/WebKitTools/WebKitTestRunner/StringFunctions.h
@@ -52,6 +52,16 @@ inline RetainPtr<CFStringRef> toCF(WKStringRef string)
return RetainPtr<CFStringRef>(AdoptCF, WKStringCopyCFString(0, string));
}
+inline RetainPtr<CFURLRef> toCF(WKURLRef url)
+{
+ return RetainPtr<CFURLRef>(AdoptCF, WKURLCopyCFURL(0, url));
+}
+
+inline RetainPtr<CFURLRef> toCF(const WKRetainPtr<WKURLRef>& url)
+{
+ return toCF(url.get());
+}
+
inline WKRetainPtr<WKStringRef> toWK(JSStringRef string)
{
return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithCFString(toCF(string).get()));
diff --git a/WebKitTools/WebKitTestRunner/TestController.cpp b/WebKitTools/WebKitTestRunner/TestController.cpp
index 93857a7..c8a78d5 100644
--- a/WebKitTools/WebKitTestRunner/TestController.cpp
+++ b/WebKitTools/WebKitTestRunner/TestController.cpp
@@ -26,8 +26,10 @@
#include "TestController.h"
#include "PlatformWebView.h"
+#include "StringFunctions.h"
#include "TestInvocation.h"
#include <WebKit2/WKContextPrivate.h>
+#include <WebKit2/WKPreferencesPrivate.h>
#include <wtf/PassOwnPtr.h>
namespace WTR {
@@ -45,6 +47,8 @@ TestController::TestController(int argc, const char* argv[])
, m_verbose(false)
, m_printSeparators(false)
, m_usingServerMode(false)
+ , m_state(Initial)
+ , m_doneResetting(false)
{
initialize(argc, argv);
controller = this;
@@ -78,6 +82,7 @@ static WKPageRef createOtherPage(WKPageRef oldPage, const void*)
closeOtherPage,
0,
0,
+ 0,
0
};
WKPageSetPageUIClient(newPage, &otherPageUIClient);
@@ -119,6 +124,7 @@ void TestController::initialize(int argc, const char* argv[])
initializeTestPluginDirectory();
m_context.adopt(WKContextCreateWithInjectedBundlePath(injectedBundlePath()));
+ platformInitializeContext();
WKContextInjectedBundleClient injectedBundleClient = {
0,
@@ -128,7 +134,7 @@ void TestController::initialize(int argc, const char* argv[])
WKContextSetInjectedBundleClient(m_context.get(), &injectedBundleClient);
_WKContextSetAdditionalPluginsDirectory(m_context.get(), testPluginDirectory());
-
+
m_pageNamespace.adopt(WKPageNamespaceCreate(m_context.get()));
m_mainWebView = adoptPtr(new PlatformWebView(m_pageNamespace.get()));
@@ -140,13 +146,60 @@ void TestController::initialize(int argc, const char* argv[])
0,
0,
0,
+ 0,
0
};
WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient);
+
+ WKPageLoaderClient pageLoaderClient = {
+ 0,
+ this,
+ 0,
+ 0,
+ 0,
+ 0,
+ didFinishLoadForFrame,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ };
+ WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient);
+}
+
+void TestController::resetStateToConsistentValues()
+{
+ m_state = Resetting;
+
+ // FIXME: This function should also ensure that there is only one page open.
+
+ // Reset preferences
+ WKPreferencesRef preferences = WKContextGetPreferences(m_context.get());
+ WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
+ WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
+
+ m_mainWebView->focus();
+
+ // Reset main page back to about:blank
+ m_doneResetting = false;
+
+ WKRetainPtr<WKURLRef> url(AdoptWK, createWKURL("about:blank"));
+ WKPageLoadURL(m_mainWebView->page(), url.get());
+ TestController::runUntil(m_doneResetting);
}
void TestController::runTest(const char* test)
{
+ resetStateToConsistentValues();
+
+ m_state = RunningTest;
m_currentInvocation.set(new TestInvocation(test));
m_currentInvocation->invoke();
m_currentInvocation.clear();
@@ -177,6 +230,8 @@ void TestController::run()
}
}
+// WKContextInjectedBundleClient
+
void TestController::didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
{
static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(messageName, messageBody);
@@ -187,4 +242,28 @@ void TestController::didReceiveMessageFromInjectedBundle(WKStringRef messageName
m_currentInvocation->didReceiveMessageFromInjectedBundle(messageName, messageBody);
}
+// WKPageLoaderClient
+
+void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo)
+{
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->didFinishLoadForFrame(page, frame);
+}
+
+void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame)
+{
+ if (m_state != Resetting)
+ return;
+
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKFrameCopyURL(frame));
+ RetainPtr<CFURLRef> cfURL= toCF(wkURL);
+ CFStringRef cfURLString = CFURLGetString(cfURL.get());
+ if (!CFEqual(cfURLString, CFSTR("about:blank")))
+ return;
+
+ m_doneResetting = true;
+}
+
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/TestController.h b/WebKitTools/WebKitTestRunner/TestController.h
index 5754728..5f6d99d 100644
--- a/WebKitTools/WebKitTestRunner/TestController.h
+++ b/WebKitTools/WebKitTestRunner/TestController.h
@@ -53,6 +53,9 @@ public:
WKPageNamespaceRef pageNamespace() { return m_pageNamespace.get(); }
WKContextRef context() { return m_context.get(); }
+ // Helper
+ static void runUntil(bool& done);
+
private:
void initialize(int argc, const char* argv[]);
void run();
@@ -61,13 +64,21 @@ private:
void runTest(const char* pathOrURL);
void platformInitialize();
+ void platformInitializeContext();
void initializeInjectedBundlePath();
void initializeTestPluginDirectory();
+ void resetStateToConsistentValues();
+
// WKContextInjectedBundleClient
static void didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void*);
void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
+ // WKPageLoaderClient
+ static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, const void*);
+ void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame);
+
+
OwnPtr<TestInvocation> m_currentInvocation;
bool m_dumpPixels;
@@ -81,6 +92,14 @@ private:
OwnPtr<PlatformWebView> m_mainWebView;
WKRetainPtr<WKContextRef> m_context;
WKRetainPtr<WKPageNamespaceRef> m_pageNamespace;
+
+ enum State {
+ Initial,
+ Resetting,
+ RunningTest
+ };
+ State m_state;
+ bool m_doneResetting;
};
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.cpp b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
index 9a0f0aa..47df66b 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.cpp
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
@@ -29,7 +29,6 @@
#include "StringFunctions.h"
#include "TestController.h"
#include <WebKit2/WKContextPrivate.h>
-#include <WebKit2/WKPreferencesPrivate.h>
#include <WebKit2/WKRetainPtr.h>
#include <wtf/RetainPtr.h>
@@ -59,7 +58,7 @@ static const unsigned normalHeight = 600;
static void sizeWebViewForCurrentTest(char* pathOrURL)
{
- bool isSVGW3CTest = strstr(pathOrURL, "svg/W3C-SVG-1.1");
+ bool isSVGW3CTest = strstr(pathOrURL, "svg/W3C-SVG-1.1") || strstr(pathOrURL, "svg\\W3C-SVG-1.1");
if (isSVGW3CTest)
TestController::shared().mainWebView()->resizeTo(w3cSVGWidth, w3cSVGHeight);
@@ -67,23 +66,15 @@ static void sizeWebViewForCurrentTest(char* pathOrURL)
TestController::shared().mainWebView()->resizeTo(normalWidth, normalHeight);
}
-void TestInvocation::resetPreferencesToConsistentValues()
-{
- WKPreferencesRef preferences = WKContextGetPreferences(TestController::shared().context());
- WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
- WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
-}
-
void TestInvocation::invoke()
{
sizeWebViewForCurrentTest(m_pathOrURL);
- resetPreferencesToConsistentValues();
WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithCFString(CFSTR("")));
WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), messageBody.get());
- runUntil(m_gotInitialResponse);
+ TestController::runUntil(m_gotInitialResponse);
if (m_error) {
dump("FAIL\n");
return;
@@ -91,7 +82,7 @@ void TestInvocation::invoke()
WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get());
- runUntil(m_gotFinalMessage);
+ TestController::runUntil(m_gotFinalMessage);
if (m_error) {
dump("FAIL\n");
return;
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.h b/WebKitTools/WebKitTestRunner/TestInvocation.h
index 484e61d..1b33e49 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.h
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.h
@@ -42,11 +42,6 @@ public:
private:
void dump(const char*);
- void resetPreferencesToConsistentValues();
-
- // Helper
- static void runUntil(bool& done);
-
WKRetainPtr<WKURLRef> m_url;
char* m_pathOrURL;
diff --git a/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj b/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
index 6f78289..f5ee6d5 100644
--- a/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
+++ b/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
@@ -53,7 +53,6 @@
BCC997A511D3C8F60017BCA2 /* InjectedBundlePage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC997A211D3C8F60017BCA2 /* InjectedBundlePage.cpp */; };
BCC9981811D3F51E0017BCA2 /* LayoutTestController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC9981711D3F51E0017BCA2 /* LayoutTestController.cpp */; };
BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD7D2F711921278006DB7EE /* TestInvocation.cpp */; };
- BCDA2ABF1190B51A00C3BC47 /* TestInvocationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCDA2ABE1190B51A00C3BC47 /* TestInvocationMac.mm */; };
BCDA2B9A1191051F00C3BC47 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCDA2B991191051F00C3BC47 /* JavaScriptCore.framework */; };
/* End PBXBuildFile section */
@@ -132,7 +131,6 @@
BCC9981711D3F51E0017BCA2 /* LayoutTestController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutTestController.cpp; sourceTree = "<group>"; };
BCD7D2F611921278006DB7EE /* TestInvocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestInvocation.h; sourceTree = "<group>"; };
BCD7D2F711921278006DB7EE /* TestInvocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestInvocation.cpp; sourceTree = "<group>"; };
- BCDA2ABE1190B51A00C3BC47 /* TestInvocationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestInvocationMac.mm; sourceTree = "<group>"; };
BCDA2B991191051F00C3BC47 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -270,7 +268,6 @@
children = (
BC7933FF118F7C84005EA8E2 /* main.mm */,
BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
- BCDA2ABE1190B51A00C3BC47 /* TestInvocationMac.mm */,
BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
);
path = mac;
@@ -426,7 +423,6 @@
BC793400118F7C84005EA8E2 /* main.mm in Sources */,
BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
- BCDA2ABF1190B51A00C3BC47 /* TestInvocationMac.mm in Sources */,
BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
);
diff --git a/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm b/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
index 4e2a60c..96e6526 100644
--- a/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
+++ b/WebKitTools/WebKitTestRunner/mac/PlatformWebViewMac.mm
@@ -58,4 +58,9 @@ WKPageRef PlatformWebView::page()
return [m_view pageRef];
}
+void PlatformWebView::focus()
+{
+ // Implement.
+}
+
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm b/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
index 1a71b5d..dbe35e2 100644
--- a/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
+++ b/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
@@ -45,4 +45,14 @@ void TestController::initializeTestPluginDirectory()
m_testPluginDirectory.adopt(WKStringCreateWithCFString((CFStringRef)[[NSBundle mainBundle] bundlePath]));
}
+void TestController::runUntil(bool& done)
+{
+ while (!done)
+ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
+}
+
+void TestController::platformInitializeContext()
+{
+}
+
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/mac/TestInvocationMac.mm b/WebKitTools/WebKitTestRunner/mac/TestInvocationMac.mm
deleted file mode 100644
index bd01029..0000000
--- a/WebKitTools/WebKitTestRunner/mac/TestInvocationMac.mm
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "TestInvocation.h"
-
-namespace WTR {
-
-void TestInvocation::runUntil(bool& done)
-{
- while (!done)
- [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
-}
-
-} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp b/WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp
index e602d0e..deed4ab 100644
--- a/WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp
+++ b/WebKitTools/WebKitTestRunner/win/PlatformWebViewWin.cpp
@@ -65,7 +65,7 @@ PlatformWebView::~PlatformWebView()
void PlatformWebView::resizeTo(unsigned width, unsigned height)
{
- // Implement
+ ::SetWindowPos(WKViewGetWindow(m_view), 0, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
}
WKPageRef PlatformWebView::page()
@@ -73,4 +73,9 @@ WKPageRef PlatformWebView::page()
return WKViewGetPage(m_view);
}
+void PlatformWebView::focus()
+{
+ ::SetFocus(::WKViewGetWindow(m_view));
+}
+
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
index f650d7f..e35ee22 100644
--- a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
+++ b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
@@ -29,6 +29,7 @@
#include <io.h>
#include <shlwapi.h>
#include <string>
+#include <WebKit2/WKContextPrivateWin.h>
#include <WebKit2/WKStringCF.h>
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
@@ -80,8 +81,17 @@ static void addQTDirToPATH()
::SetEnvironmentVariableW(pathEnvironmentVariable, newPath.data());
}
+static LONG WINAPI exceptionFilter(EXCEPTION_POINTERS*)
+{
+ fputs("#CRASHED\n", stderr);
+ fflush(stderr);
+ return EXCEPTION_CONTINUE_SEARCH;
+}
+
void TestController::platformInitialize()
{
+ ::SetUnhandledExceptionFilter(exceptionFilter);
+
_setmode(1, _O_BINARY);
_setmode(2, _O_BINARY);
@@ -113,4 +123,22 @@ void TestController::initializeTestPluginDirectory()
m_testPluginDirectory.adopt(WKStringCreateWithCFString(testPluginDirectoryPath.get()));
}
+void TestController::runUntil(bool& done)
+{
+ while (!done) {
+ MSG msg;
+ BOOL result = GetMessage(&msg, 0, 0, 0);
+ if (result == -1)
+ return;
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+void TestController::platformInitializeContext()
+{
+ // FIXME: Make DRT pass with Windows native controls. <http://webkit.org/b/25592>
+ WKContextSetShouldPaintNativeControls(m_context.get(), false);
+}
+
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/win/TestInvocationWin.cpp b/WebKitTools/WebKitTestRunner/win/TestInvocationWin.cpp
deleted file mode 100644
index cfeebcc..0000000
--- a/WebKitTools/WebKitTestRunner/win/TestInvocationWin.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "TestInvocation.h"
-
-namespace WTR {
-
-void TestInvocation::runUntil(bool& done)
-{
- while (!done) {
- MSG msg;
- BOOL result = GetMessage(&msg, 0, 0, 0);
- if (result == -1)
- return;
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-}
-
-} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/win/WebKitTestRunner.vcproj b/WebKitTools/WebKitTestRunner/win/WebKitTestRunner.vcproj
index 7375bd4..d7ddd5c 100644
--- a/WebKitTools/WebKitTestRunner/win/WebKitTestRunner.vcproj
+++ b/WebKitTools/WebKitTestRunner/win/WebKitTestRunner.vcproj
@@ -317,10 +317,6 @@
RelativePath=".\TestControllerWin.cpp"
>
</File>
- <File
- RelativePath=".\TestInvocationWin.cpp"
- >
- </File>
</Filter>
<File
RelativePath="..\PlatformWebView.h"