Title: [231491] trunk
- Revision
- 231491
- Author
- [email protected]
- Date
- 2018-05-08 10:44:02 -0700 (Tue, 08 May 2018)
Log Message
[WKHTTPCookieStore getAllCookies] returns inconsistent creation time
https://bugs.webkit.org/show_bug.cgi?id=185041
<rdar://problem/34684214>
Patch by Sihui Liu <[email protected]> on 2018-05-08
Reviewed by Geoffrey Garen.
Source/WebCore:
Set creationtime property when creating Cookie object to keep consistency after conversion.
New API test: WebKit.WKHTTPCookieStoreCreationTime.
* platform/network/cocoa/CookieCocoa.mm:
(WebCore::Cookie::operator NSHTTPCookie * const):
Tools:
Add API test Coverage.
* TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (231490 => 231491)
--- trunk/Source/WebCore/ChangeLog 2018-05-08 17:20:09 UTC (rev 231490)
+++ trunk/Source/WebCore/ChangeLog 2018-05-08 17:44:02 UTC (rev 231491)
@@ -1,3 +1,18 @@
+2018-05-08 Sihui Liu <[email protected]>
+
+ [WKHTTPCookieStore getAllCookies] returns inconsistent creation time
+ https://bugs.webkit.org/show_bug.cgi?id=185041
+ <rdar://problem/34684214>
+
+ Reviewed by Geoffrey Garen.
+
+ Set creationtime property when creating Cookie object to keep consistency after conversion.
+
+ New API test: WebKit.WKHTTPCookieStoreCreationTime.
+
+ * platform/network/cocoa/CookieCocoa.mm:
+ (WebCore::Cookie::operator NSHTTPCookie * const):
+
2018-05-08 Eric Carlson <[email protected]>
Text track cue logging should include cue text
Modified: trunk/Source/WebCore/platform/network/cocoa/CookieCocoa.mm (231490 => 231491)
--- trunk/Source/WebCore/platform/network/cocoa/CookieCocoa.mm 2018-05-08 17:20:09 UTC (rev 231490)
+++ trunk/Source/WebCore/platform/network/cocoa/CookieCocoa.mm 2018-05-08 17:44:02 UTC (rev 231491)
@@ -82,7 +82,7 @@
if (isNull())
return nil;
- NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithCapacity:12];
+ NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithCapacity:13];
if (!comment.isNull())
[properties setObject:(NSString *)comment forKey:NSHTTPCookieComment];
@@ -106,6 +106,8 @@
auto maxAge = ceil([expirationDate timeIntervalSinceNow]);
if (maxAge > 0)
[properties setObject:[NSString stringWithFormat:@"%f", maxAge] forKey:NSHTTPCookieMaximumAge];
+
+ [properties setObject:[NSNumber numberWithDouble:created / 1000.0] forKey:@"Created"];
auto* portString = portStringFromVector(ports);
if (portString)
Modified: trunk/Tools/ChangeLog (231490 => 231491)
--- trunk/Tools/ChangeLog 2018-05-08 17:20:09 UTC (rev 231490)
+++ trunk/Tools/ChangeLog 2018-05-08 17:44:02 UTC (rev 231491)
@@ -1,3 +1,16 @@
+2018-05-08 Sihui Liu <[email protected]>
+
+ [WKHTTPCookieStore getAllCookies] returns inconsistent creation time
+ https://bugs.webkit.org/show_bug.cgi?id=185041
+ <rdar://problem/34684214>
+
+ Reviewed by Geoffrey Garen.
+
+ Add API test Coverage.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
+ (TEST):
+
2018-05-08 Chris Dumez <[email protected]>
Unreviewed, fix issue with running Speedometer PerfTest after r231450.
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm (231490 => 231491)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm 2018-05-08 17:20:09 UTC (rev 231490)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm 2018-05-08 17:44:02 UTC (rev 231491)
@@ -33,6 +33,7 @@
#import <WebKit/WKWebsiteDataStorePrivate.h>
#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
#import <wtf/RetainPtr.h>
+#import <wtf/Seconds.h>
#if WK_API_ENABLED
@@ -310,6 +311,59 @@
[cookies release];
}
+TEST(WebKit, WKHTTPCookieStoreCreationTime)
+{
+ WKWebsiteDataStore* dataStore = [WKWebsiteDataStore defaultDataStore];
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ configuration.get().websiteDataStore = dataStore;
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ [webView loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit.org"]];
+ [webView _test_waitForDidFinishNavigation];
+
+ [dataStore removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:[] {
+ gotFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&gotFlag);
+ gotFlag = false;
+
+ globalCookieStore = dataStore.httpCookieStore;
+
+ RetainPtr<NSHTTPCookie> cookie = [NSHTTPCookie cookieWithProperties:@{
+ NSHTTPCookiePath: @"/path",
+ NSHTTPCookieName: @"CookieName",
+ NSHTTPCookieValue: @"CookieValue",
+ NSHTTPCookieDomain: @".www.webkit.org",
+ }];
+
+ [globalCookieStore setCookie:cookie.get() completionHandler:[]() {
+ gotFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&gotFlag);
+ gotFlag = false;
+
+ RetainPtr<NSNumber> creationTime = nil;
+ [globalCookieStore getAllCookies:[&](NSArray<NSHTTPCookie *> *cookies) {
+ ASSERT_EQ(1u, cookies.count);
+ creationTime = [cookies objectAtIndex:0].properties[@"Created"];
+ gotFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&gotFlag);
+ gotFlag = false;
+
+ sleep(1_s);
+
+ [globalCookieStore getAllCookies:^(NSArray<NSHTTPCookie *> *cookies) {
+ ASSERT_EQ(1u, cookies.count);
+ NSNumber* creationTime2 = [cookies objectAtIndex:0].properties[@"Created"];
+ EXPECT_TRUE([creationTime.get() isEqual:creationTime2]);
+ gotFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&gotFlag);
+ gotFlag = false;
+}
+
// FIXME: This should be removed once <rdar://problem/35344202> is resolved and bots are updated.
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED <= 101301) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED <= 110102)
TEST(WebKit, WKHTTPCookieStoreNonPersistent)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes