WebKit Bugzilla
Attachment 371368 Details for
Bug 198553
: Cookies set via [WKHTTPCookieStore setCookie:] on store right after constructing WKWebView get lost
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198553-20190604201050.patch (text/plain), 6.13 KB, created by
Chris Dumez
on 2019-06-04 20:10:53 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2019-06-04 20:10:53 PDT
Size:
6.13 KB
patch
obsolete
>Subversion Revision: 246084 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index a0a03192d0179108cbebb7ba2a59541711cd0bfb..4b586a2cba5d42e922c3d8e91584d4e815865f87 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,28 @@ >+2019-06-04 Chris Dumez <cdumez@apple.com> >+ >+ Cookies set via [WKHTTPCookieStore setCookie:] on store right after constructing WKWebView get lost >+ https://bugs.webkit.org/show_bug.cgi?id=198553 >+ <rdar://problem/51317144> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ If you call [WKHTTPCookieStore setCookie:] right after you construct the WKWebView and before the >+ WebContent process has finished launching, then WebsiteDataStore::processPoolForCookieStorageOperations() >+ would return null, even though there is already a view/page/WebProcessProxy/WebProcessPool for this data >+ store. As a result, the cookie would get added to the WebsiteDataStore's m_pendingCookies but it will >+ not be used since we've already previously launched a network process when we constructed the web view. >+ >+ The reason processPoolForCookieStorageOperations() would return null is because WebsiteDataStore::processPools() >+ relies on WebProcessLifetimeObserver::processes() but processes only register themselves with the >+ WebProcessLifetimeObservers when they have pages *and* after they are finished launching. >+ >+ This patch updates processPoolForCookieStorageOperations() to fallback to iterating over all process pools >+ and find a process pool with a process using the current data store and which has pages. This way, even if >+ the process is still launching, we'll properly find its associated process pool. >+ >+ * UIProcess/WebsiteData/WebsiteDataStore.cpp: >+ (WebKit::WebsiteDataStore::processPoolForCookieStorageOperations): >+ > 2019-06-04 Sihui Liu <sihui_liu@apple.com> > > WKWebsiteDataStore API fails to fetch web storage data for non-persistent data store >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >index 233b6b76f7ac81d65e4fb7bc132f0b9662ca0d55..79ca9cc7448ea65e59b73add4860db5385aed38a 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >@@ -166,7 +166,17 @@ WebsiteDataStore* WebsiteDataStore::existingNonDefaultDataStoreForSessionID(PAL: > WebProcessPool* WebsiteDataStore::processPoolForCookieStorageOperations() > { > auto pools = processPools(1, false); >- return pools.isEmpty() ? nullptr : pools.begin()->get(); >+ if (!pools.isEmpty()) >+ return pools.begin()->get(); >+ >+ for (auto* processPool : WebProcessPool::allProcessPools()) { >+ for (auto& process : processPool->processes()) { >+ if (process->pageCount() && &process->websiteDataStore() == this) >+ return processPool; >+ } >+ } >+ >+ return nullptr; > } > > void WebsiteDataStore::resolveDirectoriesIfNecessary() >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 5c3ca1ed4c9b21a4f0df1ac41482ebb072812fa6..db2a3d500839b6ba4e3e16285f6f7948a6970737 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,17 @@ >+2019-06-04 Chris Dumez <cdumez@apple.com> >+ >+ Cookies set via [WKHTTPCookieStore setCookie:] on store right after constructing WKWebView get lost >+ https://bugs.webkit.org/show_bug.cgi?id=198553 >+ <rdar://problem/51317144> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add API test coverage. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm: >+ (-[CheckSessionCookieUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): >+ (TEST): >+ > 2019-06-04 Aakash Jain <aakash_jain@apple.com> > > [ews-app] Add authentication while fetching bugs >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm >index 6c304ed11ea5eb25ebf70e5c42a95a6194bfe316..0f1e79ee16029dcb1ca8651e48efbe697b04020c 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm >@@ -586,3 +586,44 @@ TEST(WebKit, WKHTTPCookieStoreWithoutProcessPoolWithPrewarming) > } > > #endif // PLATFORM(MAC) >+ >+@interface CheckSessionCookieUIDelegate : NSObject <WKUIDelegate> >+@end >+ >+@implementation CheckSessionCookieUIDelegate >+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler >+{ >+ EXPECT_STREQ("SessionCookieName=CookieValue", message.UTF8String); >+ finished = true; >+ completionHandler(); >+} >+@end >+ >+TEST(WebKit, WKHTTPCookieStoreWithoutProcessPoolEphemeralSession) >+{ >+ RetainPtr<WKWebsiteDataStore> ephemeralStoreWithCookies = [WKWebsiteDataStore nonPersistentDataStore]; >+ >+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ configuration.get().websiteDataStore = ephemeralStoreWithCookies.get(); >+ >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); >+ auto delegate = adoptNS([[CheckSessionCookieUIDelegate alloc] init]); >+ webView.get().UIDelegate = delegate.get(); >+ >+ RetainPtr<NSHTTPCookie> sessionCookie = [NSHTTPCookie cookieWithProperties:@{ >+ NSHTTPCookiePath: @"/", >+ NSHTTPCookieName: @"SessionCookieName", >+ NSHTTPCookieValue: @"CookieValue", >+ NSHTTPCookieDomain: @"127.0.0.1", >+ }]; >+ >+ [ephemeralStoreWithCookies.get().httpCookieStore setCookie:sessionCookie.get() completionHandler:^{ >+ finished = true; >+ }]; >+ TestWebKitAPI::Util::run(&finished); >+ finished = false; >+ >+ 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>"; >+ [webView loadHTMLString:alertCookieHTML baseURL:[NSURL URLWithString:@"http://127.0.0.1"]]; >+ TestWebKitAPI::Util::run(&finished); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198553
: 371368 |
371409