Changeset 246264 in webkit
- Timestamp:
- Jun 10, 2019, 9:16:52 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/Cookie.h (modified) (2 diffs)
-
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/WebCore/ChangeLog
r246238 r246264 1 2019-06-10 Sihui Liu <sihui_liu@apple.com> 2 3 [WKHTTPCookieStore getAllCookies:] may return duplicate cookies 4 https://bugs.webkit.org/show_bug.cgi?id=198635 5 <rdar://problem/46010232> 6 7 Reviewed by Ryosuke Niwa. 8 9 Test: WebKit.WKHTTPCookieStoreWithoutProcessPoolDuplicates 10 11 * platform/Cookie.h: 12 (WebCore::Cookie::isKeyEqual const): 13 (WTF::HashTraits<WebCore::Cookie>::isEmptyValue): 14 1 15 2019-06-09 Rob Buis <rbuis@igalia.com> 2 16 -
trunk/Source/WebCore/platform/Cookie.h
r239427 r246264 77 77 } 78 78 79 bool isKeyEqual(const Cookie& otherCookie) const 80 { 81 return name == otherCookie.name 82 && domain == otherCookie.domain 83 && path == otherCookie.path; 84 } 85 79 86 String name; 80 87 String value; … … 170 177 static void constructDeletedValue(WebCore::Cookie& slot) { slot = WebCore::Cookie(WTF::HashTableDeletedValue); } 171 178 static bool isDeletedValue(const WebCore::Cookie& slot) { return slot.name.isHashTableDeletedValue(); } 179 180 static const bool hasIsEmptyValueFunction = true; 181 static bool isEmptyValue(const WebCore::Cookie& slot) { return slot.isNull(); } 172 182 }; 173 183 template<> struct EnumTraits<WebCore::Cookie::SameSitePolicy> { -
trunk/Source/WebKit/ChangeLog
r246257 r246264 1 2019-06-10 Sihui Liu <sihui_liu@apple.com> 2 3 [WKHTTPCookieStore getAllCookies:] may return duplicate cookies 4 https://bugs.webkit.org/show_bug.cgi?id=198635 5 <rdar://problem/46010232> 6 7 Reviewed by Ryosuke Niwa. 8 9 When there is no process pool, we store cookies set in memory with HashSet m_pendingCookies of WebsiteDataStore. 10 11 HashSet does not contain duplicate Cookies that are completely identical, but it may contain Cookies that have 12 all the other properties identical other than value. This is not correct because Cookies with same name, domain 13 and path should be treated as the same cookie. When a cookie is set via API, we should either insert the 14 cookie into m_pendingCookies if the cookie does not exist, or update the cookie value if it already exists. 15 16 Note that we still use HashSet with CookieHash for m_pendingCookies because in cookie deletion, we only delete 17 cookie when there is a complete match. If some cookie from m_pendingCookies has all other properties the same as 18 the cookie specified in the deletion function, but the value is different, it will not be removed. 19 20 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 21 (WebKit::WebsiteDataStore::addPendingCookie): 22 1 23 2019-06-10 Philippe Normand <pnormand@igalia.com> 2 24 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r246110 r246264 1942 1942 void WebsiteDataStore::addPendingCookie(const WebCore::Cookie& cookie) 1943 1943 { 1944 m_pendingCookies.removeIf([&cookie](auto& pendingCookie) { 1945 return pendingCookie.isKeyEqual(cookie); 1946 }); 1944 1947 m_pendingCookies.add(cookie); 1945 1948 } -
trunk/Tools/ChangeLog
r246262 r246264 1 2019-06-10 Sihui Liu <sihui_liu@apple.com> 2 3 [WKHTTPCookieStore getAllCookies:] may return duplicate cookies 4 https://bugs.webkit.org/show_bug.cgi?id=198635 5 <rdar://problem/46010232> 6 7 Reviewed by Ryosuke Niwa. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm: 10 (areCookiesEqual): 11 (TEST): 12 1 13 2019-06-10 Adrian Perez de Castro <aperez@igalia.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm
r246097 r246264 628 628 TestWebKitAPI::Util::run(&finished); 629 629 } 630 631 static bool areCookiesEqual(NSHTTPCookie *first, NSHTTPCookie *second) 632 { 633 return [first.name isEqual:second.name] && [first.domain isEqual:second.domain] && [first.path isEqual:second.path] && [first.value isEqual:second.value]; 634 } 635 636 TEST(WebKit, WKHTTPCookieStoreWithoutProcessPoolDuplicates) 637 { 638 RetainPtr<WKHTTPCookieStore> httpCookieStore = [WKWebsiteDataStore defaultDataStore].httpCookieStore; 639 RetainPtr<NSHTTPCookie> sessionCookie = [NSHTTPCookie cookieWithProperties:@{ 640 NSHTTPCookiePath: @"/", 641 NSHTTPCookieName: @"SessionCookieName", 642 NSHTTPCookieValue: @"CookieValue", 643 NSHTTPCookieDomain: @"127.0.0.1", 644 }]; 645 646 auto properties = adoptNS([sessionCookie.get().properties mutableCopy]); 647 properties.get()[NSHTTPCookieDomain] = @"localhost"; 648 RetainPtr<NSHTTPCookie> sessionCookieDifferentDomain = [NSHTTPCookie cookieWithProperties:properties.get()]; 649 properties.get()[NSHTTPCookieValue] = @"OtherCookieValue"; 650 RetainPtr<NSHTTPCookie> sessionCookieDifferentValue = [NSHTTPCookie cookieWithProperties:properties.get()]; 651 finished = false; 652 653 [httpCookieStore.get() setCookie:sessionCookie.get() completionHandler:^{ 654 finished = true; 655 }]; 656 TestWebKitAPI::Util::run(&finished); 657 finished = false; 658 659 [httpCookieStore.get() setCookie:sessionCookieDifferentDomain.get() completionHandler:^{ 660 finished = true; 661 }]; 662 TestWebKitAPI::Util::run(&finished); 663 finished = false; 664 665 [httpCookieStore.get() setCookie:sessionCookieDifferentValue.get() completionHandler:^{ 666 finished = true; 667 }]; 668 TestWebKitAPI::Util::run(&finished); 669 finished = false; 670 671 [httpCookieStore.get() getAllCookies:^(NSArray<NSHTTPCookie *> *cookies) { 672 EXPECT_EQ(2u, cookies.count); 673 bool sessionCookieExists = false, otherSessionCookieExists = false; 674 for (NSHTTPCookie* cookie in cookies) { 675 if (areCookiesEqual(cookie, sessionCookie.get())) 676 sessionCookieExists = true; 677 else if (areCookiesEqual(cookie, sessionCookieDifferentValue.get())) 678 otherSessionCookieExists = true; 679 } 680 EXPECT_TRUE(sessionCookieExists && otherSessionCookieExists); 681 finished = true; 682 }]; 683 TestWebKitAPI::Util::run(&finished); 684 }
Note:
See TracChangeset
for help on using the changeset viewer.