[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 12:01:00 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f13fb172d197559ec510a3312556ba3a90eb8f4c
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 12 21:28:24 2010 +0000

    WebKitTestRunner should be more aggressive about ensuring consistent state between tests
    https://bugs.webkit.org/show_bug.cgi?id=43653
    
    Reviewed by Alexey Proskuryakov.
    
    * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
    (WTR::InjectedBundle::InjectedBundle):
    (WTR::InjectedBundle::didReceiveMessage):
    (WTR::InjectedBundle::beginTesting):
    (WTR::InjectedBundle::done):
    * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
    (WTR::InjectedBundle::isTestRunning):
    (WTR::InjectedBundle::):
    * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
    (WTR::InjectedBundlePage::stopLoading):
    (WTR::InjectedBundlePage::didStartProvisionalLoadForFrame):
    (WTR::InjectedBundlePage::dump):
    (WTR::InjectedBundlePage::didFinishLoadForFrame):
    (WTR::InjectedBundlePage::didFailLoadWithErrorForFrame):
    (WTR::InjectedBundlePage::didReceiveTitleForFrame):
    (WTR::InjectedBundlePage::didClearWindowForFrame):
    (WTR::InjectedBundlePage::didFinishDocumentLoadForFrame):
    (WTR::InjectedBundlePage::willAddMessageToConsole):
    (WTR::InjectedBundlePage::willSetStatusbarText):
    (WTR::InjectedBundlePage::willRunJavaScriptAlert):
    (WTR::InjectedBundlePage::willRunJavaScriptConfirm):
    (WTR::InjectedBundlePage::shouldBeginEditing):
    (WTR::InjectedBundlePage::shouldEndEditing):
    (WTR::InjectedBundlePage::shouldInsertNode):
    (WTR::InjectedBundlePage::shouldInsertText):
    (WTR::InjectedBundlePage::shouldDeleteRange):
    (WTR::InjectedBundlePage::shouldChangeSelectedRange):
    (WTR::InjectedBundlePage::shouldApplyStyle):
    (WTR::InjectedBundlePage::didBeginEditing):
    (WTR::InjectedBundlePage::didEndEditing):
    (WTR::InjectedBundlePage::didChange):
    (WTR::InjectedBundlePage::didChangeSelection):
    Don't do any work if we are not currently running a test.
    
    * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
    * WebKitTestRunner/StringFunctions.h:
    (WTR::toCF):
    Add conversion function for WKURLRef -> CFURLRef
    
    * WebKitTestRunner/TestController.cpp:
    (WTR::TestController::TestController):
    (WTR::TestController::initialize):
    (WTR::TestController::resetStateToConsistentValues):
    (WTR::TestController::runTest):
    (WTR::TestController::didFinishLoadForFrame):
    * WebKitTestRunner/TestController.h:
    (WTR::TestController::):
    * WebKitTestRunner/TestInvocation.cpp:
    (WTR::TestInvocation::invoke):
    * WebKitTestRunner/TestInvocation.h:
    Move resetting code to TestController.
    
    * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
    * WebKitTestRunner/mac/TestControllerMac.mm:
    (WTR::TestController::runUntil):
    * WebKitTestRunner/mac/TestInvocationMac.mm: Removed.
    * WebKitTestRunner/win/TestControllerWin.cpp:
    (WTR::TestController::runUntil):
    * WebKitTestRunner/win/TestInvocationWin.cpp: Removed.
    * WebKitTestRunner/win/WebKitTestRunner.vcproj:
    Move runUntil to TestController.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65267 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index a4d75dc..391239e 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,72 @@
+2010-08-12  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        WebKitTestRunner should be more aggressive about ensuring consistent state between tests
+        https://bugs.webkit.org/show_bug.cgi?id=43653
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::InjectedBundle):
+        (WTR::InjectedBundle::didReceiveMessage):
+        (WTR::InjectedBundle::beginTesting):
+        (WTR::InjectedBundle::done):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        (WTR::InjectedBundle::isTestRunning):
+        (WTR::InjectedBundle::):
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::stopLoading):
+        (WTR::InjectedBundlePage::didStartProvisionalLoadForFrame):
+        (WTR::InjectedBundlePage::dump):
+        (WTR::InjectedBundlePage::didFinishLoadForFrame):
+        (WTR::InjectedBundlePage::didFailLoadWithErrorForFrame):
+        (WTR::InjectedBundlePage::didReceiveTitleForFrame):
+        (WTR::InjectedBundlePage::didClearWindowForFrame):
+        (WTR::InjectedBundlePage::didFinishDocumentLoadForFrame):
+        (WTR::InjectedBundlePage::willAddMessageToConsole):
+        (WTR::InjectedBundlePage::willSetStatusbarText):
+        (WTR::InjectedBundlePage::willRunJavaScriptAlert):
+        (WTR::InjectedBundlePage::willRunJavaScriptConfirm):
+        (WTR::InjectedBundlePage::shouldBeginEditing):
+        (WTR::InjectedBundlePage::shouldEndEditing):
+        (WTR::InjectedBundlePage::shouldInsertNode):
+        (WTR::InjectedBundlePage::shouldInsertText):
+        (WTR::InjectedBundlePage::shouldDeleteRange):
+        (WTR::InjectedBundlePage::shouldChangeSelectedRange):
+        (WTR::InjectedBundlePage::shouldApplyStyle):
+        (WTR::InjectedBundlePage::didBeginEditing):
+        (WTR::InjectedBundlePage::didEndEditing):
+        (WTR::InjectedBundlePage::didChange):
+        (WTR::InjectedBundlePage::didChangeSelection):
+        Don't do any work if we are not currently running a test.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
+        * WebKitTestRunner/StringFunctions.h:
+        (WTR::toCF):
+        Add conversion function for WKURLRef -> CFURLRef
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::TestController):
+        (WTR::TestController::initialize):
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::runTest):
+        (WTR::TestController::didFinishLoadForFrame):
+        * WebKitTestRunner/TestController.h:
+        (WTR::TestController::):
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::invoke):
+        * WebKitTestRunner/TestInvocation.h:
+        Move resetting code to TestController.
+
+        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+        * WebKitTestRunner/mac/TestControllerMac.mm:
+        (WTR::TestController::runUntil):
+        * WebKitTestRunner/mac/TestInvocationMac.mm: Removed.
+        * WebKitTestRunner/win/TestControllerWin.cpp:
+        (WTR::TestController::runUntil):
+        * WebKitTestRunner/win/TestInvocationWin.cpp: Removed.
+        * WebKitTestRunner/win/WebKitTestRunner.vcproj:
+        Move runUntil to TestController.
+
 2010-08-12  Lucas De Marchi  <lucas.demarchi at profusion.mobi>
 
         Unreviewed.
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/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..5ebb434 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;
@@ -143,10 +147,55 @@ void TestController::initialize(int argc, const char* argv[])
         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);
+
+    // Reset main page back to about:blank
+    m_doneResetting = false;
+    m_resetResultedInError = 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 +226,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 +238,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..8b39045 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();
@@ -64,10 +67,17 @@ private:
     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 +91,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..fd02335 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>
 
@@ -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/TestControllerMac.mm b/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
index 1a71b5d..6367491 100644
--- a/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
+++ b/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm
@@ -45,4 +45,10 @@ 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]];
+}
+
 } // 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/TestControllerWin.cpp b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
index f650d7f..a9c55e4 100644
--- a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
+++ b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
@@ -113,4 +113,16 @@ 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);
+    }
+}
+
 } // 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"

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list