Changeset 246097 in webkit
- Timestamp:
- Jun 4, 2019, 10:00:23 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r246095 r246097 1 2019-06-04 Chris Dumez <cdumez@apple.com> 2 3 Cookies set via [WKHTTPCookieStore setCookie:] on store right after constructing WKWebView get lost 4 https://bugs.webkit.org/show_bug.cgi?id=198553 5 <rdar://problem/51317144> 6 7 Reviewed by Geoffrey Garen. 8 9 If you call [WKHTTPCookieStore setCookie:] right after you construct the WKWebView and before the 10 WebContent process has finished launching, then WebsiteDataStore::processPoolForCookieStorageOperations() 11 would return null, even though there is already a view/page/WebProcessProxy/WebProcessPool for this data 12 store. As a result, the cookie would get added to the WebsiteDataStore's m_pendingCookies but it will 13 not be used since we've already previously launched a network process when we constructed the web view. 14 15 The reason processPoolForCookieStorageOperations() would return null is because WebsiteDataStore::processPools() 16 relies on WebProcessLifetimeObserver::processes() but processes only register themselves with the 17 WebProcessLifetimeObservers when they have pages *and* after they are finished launching. 18 19 This patch updates processPoolForCookieStorageOperations() to fallback to iterating over all process pools 20 and find a process pool with a process using the current data store and which has pages. This way, even if 21 the process is still launching, we'll properly find its associated process pool. 22 23 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 24 (WebKit::WebsiteDataStore::processPoolForCookieStorageOperations): 25 1 26 2019-06-04 Michael Catanzaro <mcatanzaro@igalia.com> 2 27 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r245801 r246097 167 167 { 168 168 auto pools = processPools(1, false); 169 return pools.isEmpty() ? nullptr : pools.begin()->get(); 169 if (!pools.isEmpty()) 170 return pools.begin()->get(); 171 172 for (auto* processPool : WebProcessPool::allProcessPools()) { 173 for (auto& process : processPool->processes()) { 174 if (process->pageCount() && &process->websiteDataStore() == this) 175 return processPool; 176 } 177 } 178 179 return nullptr; 170 180 } 171 181 -
trunk/Tools/ChangeLog
r246095 r246097 1 2019-06-04 Chris Dumez <cdumez@apple.com> 2 3 Cookies set via [WKHTTPCookieStore setCookie:] on store right after constructing WKWebView get lost 4 https://bugs.webkit.org/show_bug.cgi?id=198553 5 <rdar://problem/51317144> 6 7 Reviewed by Geoffrey Garen. 8 9 Add API test coverage. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm: 12 (-[CheckSessionCookieUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 13 (TEST): 14 1 15 2019-06-04 Michael Catanzaro <mcatanzaro@igalia.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm
r242339 r246097 587 587 588 588 #endif // PLATFORM(MAC) 589 590 @interface CheckSessionCookieUIDelegate : NSObject <WKUIDelegate> 591 @end 592 593 @implementation CheckSessionCookieUIDelegate 594 - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler 595 { 596 EXPECT_STREQ("SessionCookieName=CookieValue", message.UTF8String); 597 finished = true; 598 completionHandler(); 599 } 600 @end 601 602 TEST(WebKit, WKHTTPCookieStoreWithoutProcessPoolEphemeralSession) 603 { 604 RetainPtr<WKWebsiteDataStore> ephemeralStoreWithCookies = [WKWebsiteDataStore nonPersistentDataStore]; 605 606 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 607 configuration.get().websiteDataStore = ephemeralStoreWithCookies.get(); 608 609 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 610 auto delegate = adoptNS([[CheckSessionCookieUIDelegate alloc] init]); 611 webView.get().UIDelegate = delegate.get(); 612 613 RetainPtr<NSHTTPCookie> sessionCookie = [NSHTTPCookie cookieWithProperties:@{ 614 NSHTTPCookiePath: @"/", 615 NSHTTPCookieName: @"SessionCookieName", 616 NSHTTPCookieValue: @"CookieValue", 617 NSHTTPCookieDomain: @"127.0.0.1", 618 }]; 619 620 [ephemeralStoreWithCookies.get().httpCookieStore setCookie:sessionCookie.get() completionHandler:^{ 621 finished = true; 622 }]; 623 TestWebKitAPI::Util::run(&finished); 624 finished = false; 625 626 NSString *alertCookieHTML = @"<script>var cookies = document.cookie.split(';'); for (let i = 0; i < cookies.length; i ++) { cookies[i] = cookies[i].trim(); } cookies.sort(); alert(cookies.join('; '));</script>"; 627 [webView loadHTMLString:alertCookieHTML baseURL:[NSURL URLWithString:@"http://127.0.0.1"]]; 628 TestWebKitAPI::Util::run(&finished); 629 }
Note:
See TracChangeset
for help on using the changeset viewer.