Changeset 261758 in webkit


Ignore:
Timestamp:
May 15, 2020 1:50:18 PM (4 years ago)
Author:
Chris Dumez
Message:

Make sure we use current data store in WKTR's TestController
https://bugs.webkit.org/show_bug.cgi?id=211920

Reviewed by Alex Christensen.

Make sure we use current data store in WKTR's TestController. Currently, a lot of code
uses defaultDataStore(), even though the test may be using another data store (e.g. an
ephemeral one). I suspect this is contributing to test flakiness.

We now also make sure that TestController::websiteDataStore() returns the actual store
that will be used by the test when resetPreferencesToConsistentValues() is called.
Previously, it would not since it would get the store from the m_mainView and m_mainView
would only get initialized after calling resetPreferencesToConsistentValues(). To support
this, we now initialize a m_websiteDataStore member in platformInitializeDataStore(),
which gets called right before resetPreferencesToConsistentValues(). When
platformCreateWebView() gets called right after resetPreferencesToConsistentValues(),
it now simply relies on m_websiteDataStore instead of creating the data store at this
point.

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
(WTR::TestController::clearServiceWorkerRegistrations):
(WTR::TestController::clearDOMCache):
(WTR::TestController::clearDOMCaches):
(WTR::TestController::hasDOMCache):
(WTR::TestController::domCacheSize):
(WTR::TestController::clearStatisticsDataForDomain):

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::invoke):
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r261739 r261758  
     12020-05-15  Chris Dumez  <cdumez@apple.com>
     2
     3        Make sure we use current data store in WKTR's TestController
     4        https://bugs.webkit.org/show_bug.cgi?id=211920
     5
     6        Reviewed by Alex Christensen.
     7
     8        Make sure we use current data store in WKTR's TestController. Currently, a lot of code
     9        uses defaultDataStore(), even though the test may be using another data store (e.g. an
     10        ephemeral one). I suspect this is contributing to test flakiness.
     11
     12        We now also make sure that TestController::websiteDataStore() returns the actual store
     13        that will be used by the test when resetPreferencesToConsistentValues() is called.
     14        Previously, it would not since it would get the store from the m_mainView and m_mainView
     15        would only get initialized after calling resetPreferencesToConsistentValues(). To support
     16        this, we now initialize a m_websiteDataStore member in platformInitializeDataStore(),
     17        which gets called right before resetPreferencesToConsistentValues(). When
     18        platformCreateWebView() gets called right after resetPreferencesToConsistentValues(),
     19        it now simply relies on m_websiteDataStore instead of creating the data store at this
     20        point.
     21
     22        * WebKitTestRunner/TestController.cpp:
     23        (WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
     24        (WTR::TestController::clearServiceWorkerRegistrations):
     25        (WTR::TestController::clearDOMCache):
     26        (WTR::TestController::clearDOMCaches):
     27        (WTR::TestController::hasDOMCache):
     28        (WTR::TestController::domCacheSize):
     29        (WTR::TestController::clearStatisticsDataForDomain):
     30        * WebKitTestRunner/TestInvocation.cpp:
     31        (WTR::TestInvocation::invoke):
     32        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     33
    1342020-05-15  Diego Pino Garcia  <dpino@igalia.com>
    235
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r261242 r261758  
    557557WKWebsiteDataStoreRef TestController::websiteDataStore()
    558558{
    559     return WKPageConfigurationGetWebsiteDataStore(adoptWK(WKPageCopyPageConfiguration(m_mainWebView->page())).get());
     559    return m_websiteDataStore.get();
    560560}
    561561
     
    651651
    652652    auto configuration = generatePageConfiguration(options);
     653    platformInitializeDataStore(configuration.get(), options);
    653654
    654655    // Some preferences (notably mock scroll bars setting) currently cannot be re-applied to an existing view, so we need to set them now.
     
    942943    WKPreferencesSetDirectoryUploadEnabled(preferences, true);
    943944
    944     WKHTTPCookieStoreDeleteAllCookies(WKWebsiteDataStoreGetHTTPCookieStore(TestController::defaultWebsiteDataStore()), nullptr, nullptr);
     945    WKHTTPCookieStoreDeleteAllCookies(WKWebsiteDataStoreGetHTTPCookieStore(websiteDataStore()), nullptr, nullptr);
    945946
    946947    WKPreferencesSetMockCaptureDevicesEnabled(preferences, true);
     
    10291030
    10301031    WKWebsiteDataStoreClearAllDeviceOrientationPermissions(websiteDataStore());
    1031     WKWebsiteDataStoreClearAllDeviceOrientationPermissions(TestController::defaultWebsiteDataStore());
    10321032
    10331033    clearIndexedDatabases();
     
    22342234    auto setHTTPCookieAcceptPolicy = [&] (WKHTTPCookieAcceptPolicy policy, CompletionHandler<void(WKTypeRef)>&& completionHandler) {
    22352235        auto context = new CompletionHandler<void(WKTypeRef)>(WTFMove(completionHandler));
    2236         WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKWebsiteDataStoreGetHTTPCookieStore(TestController::defaultWebsiteDataStore()), policy, context, [] (void* context) {
     2236        WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKWebsiteDataStoreGetHTTPCookieStore(websiteDataStore()), policy, context, [] (void* context) {
    22372237            auto completionHandlerPointer = static_cast<CompletionHandler<void(WKTypeRef)>*>(context);
    22382238            (*completionHandlerPointer)(nullptr);
     
    31173117}
    31183118
     3119void TestController::platformInitializeDataStore(WKPageConfigurationRef configuration, const TestOptions&)
     3120{
     3121    m_websiteDataStore = WKPageConfigurationGetWebsiteDataStore(configuration);
     3122}
     3123
    31193124void TestController::platformCreateWebView(WKPageConfigurationRef configuration, const TestOptions& options)
    31203125{
     
    32183223    ClearServiceWorkerRegistrationsCallbackContext context(*this);
    32193224
    3220     WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(TestController::defaultWebsiteDataStore(), &context, clearServiceWorkerRegistrationsCallback);
     3225    WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(websiteDataStore(), &context, clearServiceWorkerRegistrationsCallback);
    32213226    runUntil(context.done, noTimeout);
    32223227}
     
    32443249
    32453250    auto cacheOrigin = adoptWK(WKSecurityOriginCreateFromString(origin));
    3246     WKWebsiteDataStoreRemoveFetchCacheForOrigin(TestController::defaultWebsiteDataStore(), cacheOrigin.get(), &context, clearDOMCacheCallback);
     3251    WKWebsiteDataStoreRemoveFetchCacheForOrigin(websiteDataStore(), cacheOrigin.get(), &context, clearDOMCacheCallback);
    32473252    runUntil(context.done, noTimeout);
    32483253}
     
    32523257    ClearDOMCacheCallbackContext context(*this);
    32533258
    3254     WKWebsiteDataStoreRemoveAllFetchCaches(TestController::defaultWebsiteDataStore(), &context, clearDOMCacheCallback);
     3259    WKWebsiteDataStoreRemoveAllFetchCaches(websiteDataStore(), &context, clearDOMCacheCallback);
    32553260    runUntil(context.done, noTimeout);
    32563261}
     
    33363341{
    33373342    FetchCacheOriginsCallbackContext context(*this, origin);
    3338     WKWebsiteDataStoreGetFetchCacheOrigins(TestController::defaultWebsiteDataStore(), &context, fetchCacheOriginsCallback);
     3343    WKWebsiteDataStoreGetFetchCacheOrigins(websiteDataStore(), &context, fetchCacheOriginsCallback);
    33393344    runUntil(context.done, noTimeout);
    33403345    return context.result;
     
    33643369{
    33653370    FetchCacheSizeForOriginCallbackContext context(*this);
    3366     WKWebsiteDataStoreGetFetchCacheSizeForOrigin(TestController::defaultWebsiteDataStore(), origin, &context, fetchCacheSizeForOriginCallback);
     3371    WKWebsiteDataStoreGetFetchCacheSizeForOrigin(websiteDataStore(), origin, &context, fetchCacheSizeForOriginCallback);
    33673372    runUntil(context.done, noTimeout);
    33683373    return context.result;
     
    34213426    ResourceStatisticsCallbackContext context(*this);
    34223427
    3423     WKWebsiteDataStoreRemoveITPDataForDomain(TestController::defaultWebsiteDataStore(), domain, &context, resourceStatisticsVoidResultCallback);
     3428    WKWebsiteDataStoreRemoveITPDataForDomain(websiteDataStore(), domain, &context, resourceStatisticsVoidResultCallback);
    34243429    runUntil(context.done, noTimeout);
    34253430}
  • trunk/Tools/WebKitTestRunner/TestController.h

    r261242 r261758  
    372372
    373373    void platformInitialize();
     374    void platformInitializeDataStore(WKPageConfigurationRef, const TestOptions&);
    374375    void platformDestroy();
    375376    WKContextRef platformAdjustContext(WKContextRef, WKContextConfigurationRef);
     
    624625
    625626    std::unique_ptr<EventSenderProxy> m_eventSenderProxy;
     627    WKRetainPtr<WKWebsiteDataStoreRef> m_websiteDataStore;
    626628
    627629    WorkQueueManager m_workQueueManager;
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r261620 r261758  
    165165    TestController::singleton().setShouldLogHistoryClientCallbacks(shouldLogHistoryClientCallbacks());
    166166
    167     WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKWebsiteDataStoreGetHTTPCookieStore(TestController::defaultWebsiteDataStore()), kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, nullptr, nullptr);
     167    WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKWebsiteDataStoreGetHTTPCookieStore(TestController::singleton().websiteDataStore()), kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, nullptr, nullptr);
    168168
    169169    // FIXME: We should clear out visited links here.
     
    10831083        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
    10841084        uint64_t model = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
    1085         WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(TestController::defaultWebsiteDataStore(), model);
     1085        WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(TestController::singleton().websiteDataStore(), model);
    10861086        return nullptr;
    10871087    }
     
    11401140   
    11411141    if (WKStringIsEqualToUTF8CString(messageName, "DeleteAllIndexedDatabases")) {
    1142         WKWebsiteDataStoreRemoveAllIndexedDatabases(TestController::defaultWebsiteDataStore(), nullptr, { });
     1142        WKWebsiteDataStoreRemoveAllIndexedDatabases(TestController::singleton().websiteDataStore(), nullptr, { });
    11431143        return nullptr;
    11441144    }
  • trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

    r261407 r261758  
    132132}
    133133
     134void TestController::platformInitializeDataStore(WKPageConfigurationRef, const TestOptions& options)
     135{
     136    if (options.useEphemeralSession || options.standaloneWebApplicationURL.length()) {
     137        auto websiteDataStoreConfig = options.useEphemeralSession ? [[[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration] autorelease] : [[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease];
     138        if (!options.useEphemeralSession)
     139            configureWebsiteDataStoreTemporaryDirectories((WKWebsiteDataStoreConfigurationRef)websiteDataStoreConfig);
     140        if (options.standaloneWebApplicationURL.length())
     141            [websiteDataStoreConfig setStandaloneApplicationURL:[NSURL URLWithString:[NSString stringWithUTF8String:options.standaloneWebApplicationURL.c_str()]]];
     142        auto *websiteDataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfig] autorelease];
     143        [websiteDataStore _setResourceLoadStatisticsEnabled:YES];
     144        m_websiteDataStore = (__bridge WKWebsiteDataStoreRef)websiteDataStore;
     145    } else
     146        m_websiteDataStore = (__bridge WKWebsiteDataStoreRef)globalWebViewConfiguration.websiteDataStore;
     147}
     148
    134149void TestController::platformCreateWebView(WKPageConfigurationRef, const TestOptions& options)
    135150{
     
    158173        [copiedConfiguration _setEditableImagesEnabled:YES];
    159174
    160     if (options.useEphemeralSession || options.standaloneWebApplicationURL.length()) {
    161         auto websiteDataStoreConfig = options.useEphemeralSession ? [[[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration] autorelease] : [[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease];
    162         if (!options.useEphemeralSession)
    163             configureWebsiteDataStoreTemporaryDirectories((WKWebsiteDataStoreConfigurationRef)websiteDataStoreConfig);
    164         if (options.standaloneWebApplicationURL.length())
    165             [websiteDataStoreConfig setStandaloneApplicationURL:[NSURL URLWithString:[NSString stringWithUTF8String:options.standaloneWebApplicationURL.c_str()]]];
    166         auto websiteDataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfig] autorelease];
    167         [websiteDataStore _setResourceLoadStatisticsEnabled:YES];
    168         [copiedConfiguration setWebsiteDataStore:websiteDataStore];
    169     }
     175    [copiedConfiguration setWebsiteDataStore:(WKWebsiteDataStore *)websiteDataStore()];
    170176
    171177    [copiedConfiguration _setAllowTopNavigationToDataURLs:options.allowTopNavigationToDataURLs];
Note: See TracChangeset for help on using the changeset viewer.