Changeset 65267 in webkit


Ignore:
Timestamp:
Aug 12, 2010 2:28:24 PM (14 years ago)
Author:
weinig@apple.com
Message:

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.

Location:
trunk/WebKitTools
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r65256 r65267  
     12010-08-12  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        WebKitTestRunner should be more aggressive about ensuring consistent state between tests
     6        https://bugs.webkit.org/show_bug.cgi?id=43653
     7
     8        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     9        (WTR::InjectedBundle::InjectedBundle):
     10        (WTR::InjectedBundle::didReceiveMessage):
     11        (WTR::InjectedBundle::beginTesting):
     12        (WTR::InjectedBundle::done):
     13        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
     14        (WTR::InjectedBundle::isTestRunning):
     15        (WTR::InjectedBundle::):
     16        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
     17        (WTR::InjectedBundlePage::stopLoading):
     18        (WTR::InjectedBundlePage::didStartProvisionalLoadForFrame):
     19        (WTR::InjectedBundlePage::dump):
     20        (WTR::InjectedBundlePage::didFinishLoadForFrame):
     21        (WTR::InjectedBundlePage::didFailLoadWithErrorForFrame):
     22        (WTR::InjectedBundlePage::didReceiveTitleForFrame):
     23        (WTR::InjectedBundlePage::didClearWindowForFrame):
     24        (WTR::InjectedBundlePage::didFinishDocumentLoadForFrame):
     25        (WTR::InjectedBundlePage::willAddMessageToConsole):
     26        (WTR::InjectedBundlePage::willSetStatusbarText):
     27        (WTR::InjectedBundlePage::willRunJavaScriptAlert):
     28        (WTR::InjectedBundlePage::willRunJavaScriptConfirm):
     29        (WTR::InjectedBundlePage::shouldBeginEditing):
     30        (WTR::InjectedBundlePage::shouldEndEditing):
     31        (WTR::InjectedBundlePage::shouldInsertNode):
     32        (WTR::InjectedBundlePage::shouldInsertText):
     33        (WTR::InjectedBundlePage::shouldDeleteRange):
     34        (WTR::InjectedBundlePage::shouldChangeSelectedRange):
     35        (WTR::InjectedBundlePage::shouldApplyStyle):
     36        (WTR::InjectedBundlePage::didBeginEditing):
     37        (WTR::InjectedBundlePage::didEndEditing):
     38        (WTR::InjectedBundlePage::didChange):
     39        (WTR::InjectedBundlePage::didChangeSelection):
     40        Don't do any work if we are not currently running a test.
     41
     42        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
     43        * WebKitTestRunner/StringFunctions.h:
     44        (WTR::toCF):
     45        Add conversion function for WKURLRef -> CFURLRef
     46
     47        * WebKitTestRunner/TestController.cpp:
     48        (WTR::TestController::TestController):
     49        (WTR::TestController::initialize):
     50        (WTR::TestController::resetStateToConsistentValues):
     51        (WTR::TestController::runTest):
     52        (WTR::TestController::didFinishLoadForFrame):
     53        * WebKitTestRunner/TestController.h:
     54        (WTR::TestController::):
     55        * WebKitTestRunner/TestInvocation.cpp:
     56        (WTR::TestInvocation::invoke):
     57        * WebKitTestRunner/TestInvocation.h:
     58        Move resetting code to TestController.
     59
     60        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
     61        * WebKitTestRunner/mac/TestControllerMac.mm:
     62        (WTR::TestController::runUntil):
     63        * WebKitTestRunner/mac/TestInvocationMac.mm: Removed.
     64        * WebKitTestRunner/win/TestControllerWin.cpp:
     65        (WTR::TestController::runUntil):
     66        * WebKitTestRunner/win/TestInvocationWin.cpp: Removed.
     67        * WebKitTestRunner/win/WebKitTestRunner.vcproj:
     68        Move runUntil to TestController.
     69
    1702010-08-12  Lucas De Marchi  <lucas.demarchi@profusion.mobi>
    271
  • trunk/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r64985 r65267  
    5050    : m_bundle(0)
    5151    , m_mainPage(0)
     52    , m_state(Idle)
    5253{
    5354}
     
    8586}
    8687
    87 void InjectedBundle::done()
    88 {
    89     WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Done")));
    90 
    91     std::string output = m_outputStream.str();
    92     RetainPtr<CFStringRef> outputCFString(AdoptCF, CFStringCreateWithCString(0, output.c_str(), kCFStringEncodingUTF8));
    93     WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithCFString(outputCFString.get()));
    94 
    95     WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
    96 }
    97 
    9888void InjectedBundle::didCreatePage(WKBundlePageRef page)
    9989{
     
    122112        WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get());
    123113
    124         reset();
     114        beginTesting();
    125115        return;
    126116    }
     
    131121}
    132122
    133 void InjectedBundle::reset()
     123void InjectedBundle::beginTesting()
    134124{
     125    m_state = Testing;
     126
    135127    m_outputStream.str("");
    136128
     
    145137}
    146138
     139void InjectedBundle::done()
     140{
     141    m_mainPage->stopLoading();
     142
     143    WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithCFString(CFSTR("Done")));
     144
     145    std::string output = m_outputStream.str();
     146    RetainPtr<CFStringRef> outputCFString(AdoptCF, CFStringCreateWithCString(0, output.c_str(), kCFStringEncodingUTF8));
     147    WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithCFString(outputCFString.get()));
     148
     149    WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get());
     150
     151    m_state = Idle;
     152}
     153
    147154void InjectedBundle::closeOtherPages()
    148155{
  • trunk/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

    r64985 r65267  
    6262    std::ostringstream& os() { return m_outputStream; }
    6363
     64    bool isTestRunning() { return m_state == Testing; }
     65
    6466private:
    6567    InjectedBundle();
     
    7476    void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody);
    7577
    76     void reset();
     78    void beginTesting();
    7779
    7880    WKBundleRef m_bundle;
     
    8587
    8688    std::ostringstream m_outputStream;
     89   
     90    enum State {
     91        Idle,
     92        Testing
     93    };
     94    State m_state;
    8795};
    8896
  • trunk/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

    r65029 r65267  
    148148}
    149149
     150void InjectedBundlePage::stopLoading()
     151{
     152    WKBundlePageStopLoading(m_page);
     153    m_isLoading = false;
     154}
     155
    150156void InjectedBundlePage::reset()
    151157{
     
    236242void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame)
    237243{
     244    if (!InjectedBundle::shared().isTestRunning())
     245        return;
     246
    238247    if (frame == WKBundlePageGetMainFrame(m_page))
    239248        m_isLoading = true;
     
    332341void InjectedBundlePage::dump()
    333342{
     343    ASSERT(InjectedBundle::shared().isTestRunning());
     344
    334345    InjectedBundle::shared().layoutTestController()->invalidateWaitToDumpWatchdog();
    335346
     
    358369void InjectedBundlePage::didFinishLoadForFrame(WKBundleFrameRef frame)
    359370{
     371    if (!InjectedBundle::shared().isTestRunning())
     372        return;
     373
    360374    if (!WKBundleFrameIsMainFrame(frame))
    361375        return;
     
    374388void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame)
    375389{
     390    if (!InjectedBundle::shared().isTestRunning())
     391        return;
     392
    376393    if (!WKBundleFrameIsMainFrame(frame))
    377394        return;
     
    387404void InjectedBundlePage::didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef frame)
    388405{
     406    if (!InjectedBundle::shared().isTestRunning())
     407        return;
     408
    389409    if (!InjectedBundle::shared().layoutTestController()->shouldDumpTitleChanges())
    390410        return;
     
    395415void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window)
    396416{
     417    if (!InjectedBundle::shared().isTestRunning())
     418        return;
     419
    397420    JSValueRef exception = 0;
    398421    InjectedBundle::shared().layoutTestController()->makeWindowObject(context, window, &exception);
     
    415438void InjectedBundlePage::didFinishDocumentLoadForFrame(WKBundleFrameRef frame)
    416439{
     440    if (!InjectedBundle::shared().isTestRunning())
     441        return;
     442
    417443    unsigned pendingFrameUnloadEvents = WKBundleFrameGetPendingUnloadCount(frame);
    418444    if (pendingFrameUnloadEvents)
     
    461487void InjectedBundlePage::willAddMessageToConsole(WKStringRef message, uint32_t lineNumber)
    462488{
     489    if (!InjectedBundle::shared().isTestRunning())
     490        return;
     491
    463492    // FIXME: Strip file: urls.
    464493    InjectedBundle::shared().os() << "CONSOLE MESSAGE: line " << lineNumber << ": " << message << "\n";
     
    467496void InjectedBundlePage::willSetStatusbarText(WKStringRef statusbarText)
    468497{
     498    if (!InjectedBundle::shared().isTestRunning())
     499        return;
     500
    469501    if (!InjectedBundle::shared().layoutTestController()->shouldDumpStatusCallbacks())
    470502        return;
     
    475507void InjectedBundlePage::willRunJavaScriptAlert(WKStringRef message, WKBundleFrameRef)
    476508{
     509    if (!InjectedBundle::shared().isTestRunning())
     510        return;
     511
    477512    InjectedBundle::shared().os() << "ALERT: " << message << "\n";
    478513}
     
    480515void InjectedBundlePage::willRunJavaScriptConfirm(WKStringRef message, WKBundleFrameRef)
    481516{
     517    if (!InjectedBundle::shared().isTestRunning())
     518        return;
     519
    482520    InjectedBundle::shared().os() << "CONFIRM: " << message << "\n";
    483521}
     
    547585bool InjectedBundlePage::shouldBeginEditing(WKBundleRangeRef range)
    548586{
     587    if (!InjectedBundle::shared().isTestRunning())
     588        return true;
     589
    549590    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
    550591        InjectedBundle::shared().os() << "EDITING DELEGATE: shouldBeginEditingInDOMRange:" << range << "\n";
     
    554595bool InjectedBundlePage::shouldEndEditing(WKBundleRangeRef range)
    555596{
     597    if (!InjectedBundle::shared().isTestRunning())
     598        return true;
     599
    556600    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
    557601        InjectedBundle::shared().os() << "EDITING DELEGATE: shouldEndEditingInDOMRange:" << range << "\n";
     
    561605bool InjectedBundlePage::shouldInsertNode(WKBundleNodeRef node, WKBundleRangeRef rangeToReplace, WKInsertActionType action)
    562606{
     607    if (!InjectedBundle::shared().isTestRunning())
     608        return true;
     609
    563610    static const char* insertactionstring[] = {
    564611        "WebViewInsertActionTyped",
     
    574621bool InjectedBundlePage::shouldInsertText(WKStringRef text, WKBundleRangeRef rangeToReplace, WKInsertActionType action)
    575622{
     623    if (!InjectedBundle::shared().isTestRunning())
     624        return true;
     625
    576626    static const char *insertactionstring[] = {
    577627        "WebViewInsertActionTyped",
     
    587637bool InjectedBundlePage::shouldDeleteRange(WKBundleRangeRef range)
    588638{
     639    if (!InjectedBundle::shared().isTestRunning())
     640        return true;
     641
    589642    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
    590643        InjectedBundle::shared().os() << "EDITING DELEGATE: shouldDeleteDOMRange:" << range << "\n";
     
    594647bool InjectedBundlePage::shouldChangeSelectedRange(WKBundleRangeRef fromRange, WKBundleRangeRef toRange, WKAffinityType affinity, bool stillSelecting)
    595648{
     649    if (!InjectedBundle::shared().isTestRunning())
     650        return true;
     651
    596652    static const char *affinitystring[] = {
    597653        "NSSelectionAffinityUpstream",
     
    610666bool InjectedBundlePage::shouldApplyStyle(WKBundleCSSStyleDeclarationRef style, WKBundleRangeRef range)
    611667{
     668    if (!InjectedBundle::shared().isTestRunning())
     669        return true;
     670
    612671    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
    613672        InjectedBundle::shared().os() << "EDITING DELEGATE: shouldApplyStyle:" << style << " toElementsInDOMRange:" << range << "\n";
     
    617676void InjectedBundlePage::didBeginEditing(WKStringRef notificationName)
    618677{
     678    if (!InjectedBundle::shared().isTestRunning())
     679        return;
     680
    619681    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
    620682        InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidBeginEditing:" << notificationName << "\n";
     
    623685void InjectedBundlePage::didEndEditing(WKStringRef notificationName)
    624686{
     687    if (!InjectedBundle::shared().isTestRunning())
     688        return;
     689
    625690    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
    626691        InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidEndEditing:" << notificationName << "\n";
     
    629694void InjectedBundlePage::didChange(WKStringRef notificationName)
    630695{
     696    if (!InjectedBundle::shared().isTestRunning())
     697        return;
     698
    631699    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
    632700        InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChange:" << notificationName << "\n";
     
    635703void InjectedBundlePage::didChangeSelection(WKStringRef notificationName)
    636704{
     705    if (!InjectedBundle::shared().isTestRunning())
     706        return;
     707
    637708    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
    638709        InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChangeSelection:" << notificationName << "\n";
    639710}
    640711
    641 
    642712} // namespace WTR
  • trunk/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h

    r64927 r65267  
    3939    void dump();
    4040
     41    void stopLoading();
    4142    bool isLoading() { return m_isLoading; }
    4243
  • trunk/WebKitTools/WebKitTestRunner/StringFunctions.h

    r64576 r65267  
    5151{
    5252    return RetainPtr<CFStringRef>(AdoptCF, WKStringCopyCFString(0, string));
     53}
     54
     55inline RetainPtr<CFURLRef> toCF(WKURLRef url)
     56{
     57    return RetainPtr<CFURLRef>(AdoptCF, WKURLCopyCFURL(0, url));
     58}
     59
     60inline RetainPtr<CFURLRef> toCF(const WKRetainPtr<WKURLRef>& url)
     61{
     62    return toCF(url.get());
    5363}
    5464
  • trunk/WebKitTools/WebKitTestRunner/TestController.cpp

    r64485 r65267  
    2727
    2828#include "PlatformWebView.h"
     29#include "StringFunctions.h"
    2930#include "TestInvocation.h"
    3031#include <WebKit2/WKContextPrivate.h>
     32#include <WebKit2/WKPreferencesPrivate.h>
    3133#include <wtf/PassOwnPtr.h>
    3234
     
    4648    , m_printSeparators(false)
    4749    , m_usingServerMode(false)
     50    , m_state(Initial)
     51    , m_doneResetting(false)
    4852{
    4953    initialize(argc, argv);
     
    144148    };
    145149    WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient);
     150
     151    WKPageLoaderClient pageLoaderClient = {
     152        0,
     153        this,
     154        0,
     155        0,
     156        0,
     157        0,
     158        didFinishLoadForFrame,
     159        0,
     160        0,
     161        0,
     162        0,
     163        0,
     164        0,
     165        0,
     166        0,
     167        0,
     168        0,
     169        0
     170    };
     171    WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient);
     172}
     173
     174void TestController::resetStateToConsistentValues()
     175{
     176    m_state = Resetting;
     177
     178    // FIXME: This function should also ensure that there is only one page open.
     179
     180    // Reset preferences
     181    WKPreferencesRef preferences = WKContextGetPreferences(m_context.get());
     182    WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
     183    WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
     184
     185    // Reset main page back to about:blank
     186    m_doneResetting = false;
     187    m_resetResultedInError = false;
     188
     189    WKRetainPtr<WKURLRef> url(AdoptWK, createWKURL("about:blank"));
     190    WKPageLoadURL(m_mainWebView->page(), url.get());
     191    TestController::runUntil(m_doneResetting);
    146192}
    147193
    148194void TestController::runTest(const char* test)
    149195{
     196    resetStateToConsistentValues();
     197
     198    m_state = RunningTest;
    150199    m_currentInvocation.set(new TestInvocation(test));
    151200    m_currentInvocation->invoke();
     
    178227}
    179228
     229// WKContextInjectedBundleClient
     230
    180231void TestController::didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo)
    181232{
     
    188239}
    189240
     241// WKPageLoaderClient
     242
     243void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo)
     244{
     245    static_cast<TestController*>(const_cast<void*>(clientInfo))->didFinishLoadForFrame(page, frame);
     246}
     247
     248void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame)
     249{
     250    if (m_state != Resetting)
     251        return;
     252
     253    if (!WKFrameIsMainFrame(frame))
     254        return;
     255
     256    WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKFrameCopyURL(frame));
     257    RetainPtr<CFURLRef> cfURL= toCF(wkURL);
     258    CFStringRef cfURLString = CFURLGetString(cfURL.get());
     259    if (!CFEqual(cfURLString, CFSTR("about:blank")))
     260        return;
     261
     262    m_doneResetting = true;
     263}
     264
    190265} // namespace WTR
  • trunk/WebKitTools/WebKitTestRunner/TestController.h

    r64485 r65267  
    5454    WKContextRef context() { return m_context.get(); }
    5555
     56    // Helper
     57    static void runUntil(bool& done);
     58
    5659private:
    5760    void initialize(int argc, const char* argv[]);
     
    6568    void initializeTestPluginDirectory();
    6669
     70    void resetStateToConsistentValues();
     71
    6772    // WKContextInjectedBundleClient
    6873    static void didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void*);
    6974    void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
     75
     76    // WKPageLoaderClient
     77    static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, const void*);
     78    void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame);
     79
    7080
    7181    OwnPtr<TestInvocation> m_currentInvocation;
     
    8292    WKRetainPtr<WKContextRef> m_context;
    8393    WKRetainPtr<WKPageNamespaceRef> m_pageNamespace;
     94   
     95    enum State {
     96        Initial,
     97        Resetting,
     98        RunningTest
     99    };
     100    State m_state;
     101    bool m_doneResetting;
    84102};
    85103
  • trunk/WebKitTools/WebKitTestRunner/TestInvocation.cpp

    r64888 r65267  
    3030#include "TestController.h"
    3131#include <WebKit2/WKContextPrivate.h>
    32 #include <WebKit2/WKPreferencesPrivate.h>
    3332#include <WebKit2/WKRetainPtr.h>
    3433#include <wtf/RetainPtr.h>
     
    6867}
    6968
    70 void TestInvocation::resetPreferencesToConsistentValues()
    71 {
    72     WKPreferencesRef preferences = WKContextGetPreferences(TestController::shared().context());
    73     WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
    74     WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
    75 }
    76 
    7769void TestInvocation::invoke()
    7870{
    7971    sizeWebViewForCurrentTest(m_pathOrURL);
    80     resetPreferencesToConsistentValues();
    8172
    8273    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithCFString(CFSTR("BeginTest")));
     
    8475    WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), messageBody.get());
    8576
    86     runUntil(m_gotInitialResponse);
     77    TestController::runUntil(m_gotInitialResponse);
    8778    if (m_error) {
    8879        dump("FAIL\n");
     
    9283    WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get());
    9384
    94     runUntil(m_gotFinalMessage);
     85    TestController::runUntil(m_gotFinalMessage);
    9586    if (m_error) {
    9687        dump("FAIL\n");
  • trunk/WebKitTools/WebKitTestRunner/TestInvocation.h

    r64396 r65267  
    4343    void dump(const char*);
    4444
    45     void resetPreferencesToConsistentValues();
    46 
    47     // Helper
    48     static void runUntil(bool& done);
    49 
    5045    WKRetainPtr<WKURLRef> m_url;
    5146    char* m_pathOrURL;
  • trunk/WebKitTools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj

    r64985 r65267  
    5454                BCC9981811D3F51E0017BCA2 /* LayoutTestController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC9981711D3F51E0017BCA2 /* LayoutTestController.cpp */; };
    5555                BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD7D2F711921278006DB7EE /* TestInvocation.cpp */; };
    56                 BCDA2ABF1190B51A00C3BC47 /* TestInvocationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCDA2ABE1190B51A00C3BC47 /* TestInvocationMac.mm */; };
    5756                BCDA2B9A1191051F00C3BC47 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCDA2B991191051F00C3BC47 /* JavaScriptCore.framework */; };
    5857/* End PBXBuildFile section */
     
    133132                BCD7D2F611921278006DB7EE /* TestInvocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestInvocation.h; sourceTree = "<group>"; };
    134133                BCD7D2F711921278006DB7EE /* TestInvocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestInvocation.cpp; sourceTree = "<group>"; };
    135                 BCDA2ABE1190B51A00C3BC47 /* TestInvocationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestInvocationMac.mm; sourceTree = "<group>"; };
    136134                BCDA2B991191051F00C3BC47 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    137135/* End PBXFileReference section */
     
    271269                                BC7933FF118F7C84005EA8E2 /* main.mm */,
    272270                                BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
    273                                 BCDA2ABE1190B51A00C3BC47 /* TestInvocationMac.mm */,
    274271                                BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
    275272                        );
     
    427424                                BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
    428425                                BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
    429                                 BCDA2ABF1190B51A00C3BC47 /* TestInvocationMac.mm in Sources */,
    430426                                BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
    431427                                BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
  • trunk/WebKitTools/WebKitTestRunner/mac/TestControllerMac.mm

    r64286 r65267  
    4646}
    4747
     48void TestController::runUntil(bool& done)
     49{
     50    while (!done)
     51        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
     52}
     53
    4854} // namespace WTR
  • trunk/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp

    r64948 r65267  
    114114}
    115115
     116void TestController::runUntil(bool& done)
     117{
     118    while (!done) {
     119        MSG msg;
     120        BOOL result = GetMessage(&msg, 0, 0, 0);
     121        if (result == -1)
     122            return;
     123        TranslateMessage(&msg);
     124        DispatchMessage(&msg);
     125    }
     126}
     127
    116128} // namespace WTR
  • trunk/WebKitTools/WebKitTestRunner/win/WebKitTestRunner.vcproj

    r64948 r65267  
    318318                                >
    319319                        </File>
    320                         <File
    321                                 RelativePath=".\TestInvocationWin.cpp"
    322                                 >
    323                         </File>
    324320                </Filter>
    325321                <File
Note: See TracChangeset for help on using the changeset viewer.