Changeset 261758 in webkit
- Timestamp:
- May 15, 2020 1:50:18 PM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r261739 r261758 1 2020-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 1 34 2020-05-15 Diego Pino Garcia <dpino@igalia.com> 2 35 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r261242 r261758 557 557 WKWebsiteDataStoreRef TestController::websiteDataStore() 558 558 { 559 return WKPageConfigurationGetWebsiteDataStore(adoptWK(WKPageCopyPageConfiguration(m_mainWebView->page())).get());559 return m_websiteDataStore.get(); 560 560 } 561 561 … … 651 651 652 652 auto configuration = generatePageConfiguration(options); 653 platformInitializeDataStore(configuration.get(), options); 653 654 654 655 // Some preferences (notably mock scroll bars setting) currently cannot be re-applied to an existing view, so we need to set them now. … … 942 943 WKPreferencesSetDirectoryUploadEnabled(preferences, true); 943 944 944 WKHTTPCookieStoreDeleteAllCookies(WKWebsiteDataStoreGetHTTPCookieStore( TestController::defaultWebsiteDataStore()), nullptr, nullptr);945 WKHTTPCookieStoreDeleteAllCookies(WKWebsiteDataStoreGetHTTPCookieStore(websiteDataStore()), nullptr, nullptr); 945 946 946 947 WKPreferencesSetMockCaptureDevicesEnabled(preferences, true); … … 1029 1030 1030 1031 WKWebsiteDataStoreClearAllDeviceOrientationPermissions(websiteDataStore()); 1031 WKWebsiteDataStoreClearAllDeviceOrientationPermissions(TestController::defaultWebsiteDataStore());1032 1032 1033 1033 clearIndexedDatabases(); … … 2234 2234 auto setHTTPCookieAcceptPolicy = [&] (WKHTTPCookieAcceptPolicy policy, CompletionHandler<void(WKTypeRef)>&& completionHandler) { 2235 2235 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) { 2237 2237 auto completionHandlerPointer = static_cast<CompletionHandler<void(WKTypeRef)>*>(context); 2238 2238 (*completionHandlerPointer)(nullptr); … … 3117 3117 } 3118 3118 3119 void TestController::platformInitializeDataStore(WKPageConfigurationRef configuration, const TestOptions&) 3120 { 3121 m_websiteDataStore = WKPageConfigurationGetWebsiteDataStore(configuration); 3122 } 3123 3119 3124 void TestController::platformCreateWebView(WKPageConfigurationRef configuration, const TestOptions& options) 3120 3125 { … … 3218 3223 ClearServiceWorkerRegistrationsCallbackContext context(*this); 3219 3224 3220 WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations( TestController::defaultWebsiteDataStore(), &context, clearServiceWorkerRegistrationsCallback);3225 WKWebsiteDataStoreRemoveAllServiceWorkerRegistrations(websiteDataStore(), &context, clearServiceWorkerRegistrationsCallback); 3221 3226 runUntil(context.done, noTimeout); 3222 3227 } … … 3244 3249 3245 3250 auto cacheOrigin = adoptWK(WKSecurityOriginCreateFromString(origin)); 3246 WKWebsiteDataStoreRemoveFetchCacheForOrigin( TestController::defaultWebsiteDataStore(), cacheOrigin.get(), &context, clearDOMCacheCallback);3251 WKWebsiteDataStoreRemoveFetchCacheForOrigin(websiteDataStore(), cacheOrigin.get(), &context, clearDOMCacheCallback); 3247 3252 runUntil(context.done, noTimeout); 3248 3253 } … … 3252 3257 ClearDOMCacheCallbackContext context(*this); 3253 3258 3254 WKWebsiteDataStoreRemoveAllFetchCaches( TestController::defaultWebsiteDataStore(), &context, clearDOMCacheCallback);3259 WKWebsiteDataStoreRemoveAllFetchCaches(websiteDataStore(), &context, clearDOMCacheCallback); 3255 3260 runUntil(context.done, noTimeout); 3256 3261 } … … 3336 3341 { 3337 3342 FetchCacheOriginsCallbackContext context(*this, origin); 3338 WKWebsiteDataStoreGetFetchCacheOrigins( TestController::defaultWebsiteDataStore(), &context, fetchCacheOriginsCallback);3343 WKWebsiteDataStoreGetFetchCacheOrigins(websiteDataStore(), &context, fetchCacheOriginsCallback); 3339 3344 runUntil(context.done, noTimeout); 3340 3345 return context.result; … … 3364 3369 { 3365 3370 FetchCacheSizeForOriginCallbackContext context(*this); 3366 WKWebsiteDataStoreGetFetchCacheSizeForOrigin( TestController::defaultWebsiteDataStore(), origin, &context, fetchCacheSizeForOriginCallback);3371 WKWebsiteDataStoreGetFetchCacheSizeForOrigin(websiteDataStore(), origin, &context, fetchCacheSizeForOriginCallback); 3367 3372 runUntil(context.done, noTimeout); 3368 3373 return context.result; … … 3421 3426 ResourceStatisticsCallbackContext context(*this); 3422 3427 3423 WKWebsiteDataStoreRemoveITPDataForDomain( TestController::defaultWebsiteDataStore(), domain, &context, resourceStatisticsVoidResultCallback);3428 WKWebsiteDataStoreRemoveITPDataForDomain(websiteDataStore(), domain, &context, resourceStatisticsVoidResultCallback); 3424 3429 runUntil(context.done, noTimeout); 3425 3430 } -
trunk/Tools/WebKitTestRunner/TestController.h
r261242 r261758 372 372 373 373 void platformInitialize(); 374 void platformInitializeDataStore(WKPageConfigurationRef, const TestOptions&); 374 375 void platformDestroy(); 375 376 WKContextRef platformAdjustContext(WKContextRef, WKContextConfigurationRef); … … 624 625 625 626 std::unique_ptr<EventSenderProxy> m_eventSenderProxy; 627 WKRetainPtr<WKWebsiteDataStoreRef> m_websiteDataStore; 626 628 627 629 WorkQueueManager m_workQueueManager; -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r261620 r261758 165 165 TestController::singleton().setShouldLogHistoryClientCallbacks(shouldLogHistoryClientCallbacks()); 166 166 167 WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKWebsiteDataStoreGetHTTPCookieStore(TestController:: defaultWebsiteDataStore()), kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, nullptr, nullptr);167 WKHTTPCookieStoreSetHTTPCookieAcceptPolicy(WKWebsiteDataStoreGetHTTPCookieStore(TestController::singleton().websiteDataStore()), kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain, nullptr, nullptr); 168 168 169 169 // FIXME: We should clear out visited links here. … … 1083 1083 ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID()); 1084 1084 uint64_t model = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody)); 1085 WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(TestController:: defaultWebsiteDataStore(), model);1085 WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(TestController::singleton().websiteDataStore(), model); 1086 1086 return nullptr; 1087 1087 } … … 1140 1140 1141 1141 if (WKStringIsEqualToUTF8CString(messageName, "DeleteAllIndexedDatabases")) { 1142 WKWebsiteDataStoreRemoveAllIndexedDatabases(TestController:: defaultWebsiteDataStore(), nullptr, { });1142 WKWebsiteDataStoreRemoveAllIndexedDatabases(TestController::singleton().websiteDataStore(), nullptr, { }); 1143 1143 return nullptr; 1144 1144 } -
trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
r261407 r261758 132 132 } 133 133 134 void 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 134 149 void TestController::platformCreateWebView(WKPageConfigurationRef, const TestOptions& options) 135 150 { … … 158 173 [copiedConfiguration _setEditableImagesEnabled:YES]; 159 174 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()]; 170 176 171 177 [copiedConfiguration _setAllowTopNavigationToDataURLs:options.allowTopNavigationToDataURLs];
Note: See TracChangeset
for help on using the changeset viewer.