Title: [233308] trunk
Revision
233308
Author
[email protected]
Date
2018-06-28 10:03:24 -0700 (Thu, 28 Jun 2018)

Log Message

Cookie API: cookie creation time is wrong
https://bugs.webkit.org/show_bug.cgi?id=187101

Reviewed by Geoffrey Garen.

Source/WebCore:

Covered by API test: WebKit.WKHTTPCookieStoreCreationTime.

* platform/network/cocoa/CookieCocoa.mm:
(WebCore::Cookie::operator NSHTTPCookie * _Nullable  const):

Tools:

Add test coverage: make sure the cookie creation time returned is the same as set.

* TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233307 => 233308)


--- trunk/Source/WebCore/ChangeLog	2018-06-28 15:42:42 UTC (rev 233307)
+++ trunk/Source/WebCore/ChangeLog	2018-06-28 17:03:24 UTC (rev 233308)
@@ -1,3 +1,15 @@
+2018-06-28  Sihui Liu  <[email protected]>
+
+        Cookie API: cookie creation time is wrong
+        https://bugs.webkit.org/show_bug.cgi?id=187101
+
+        Reviewed by Geoffrey Garen.
+
+        Covered by API test: WebKit.WKHTTPCookieStoreCreationTime.
+
+        * platform/network/cocoa/CookieCocoa.mm:
+        (WebCore::Cookie::operator NSHTTPCookie * _Nullable  const):
+
 2018-06-28  Zalan Bujtas  <[email protected]>
 
         [LFC] Add Display::Box::nonCollapsedMarginBox for verification purposes.

Modified: trunk/Source/WebCore/platform/network/cocoa/CookieCocoa.mm (233307 => 233308)


--- trunk/Source/WebCore/platform/network/cocoa/CookieCocoa.mm	2018-06-28 15:42:42 UTC (rev 233307)
+++ trunk/Source/WebCore/platform/network/cocoa/CookieCocoa.mm	2018-06-28 17:03:24 UTC (rev 233308)
@@ -161,7 +161,7 @@
         [properties setObject:[NSString stringWithFormat:@"%f", maxAge] forKey:NSHTTPCookieMaximumAge];
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
-    [properties setObject:[NSNumber numberWithDouble:created / 1000.0] forKey:@"Created"];
+    [properties setObject:[NSNumber numberWithDouble:created / 1000.0 - NSTimeIntervalSince1970] forKey:@"Created"];
 #endif
 
     auto* portString = portStringFromVector(ports);

Modified: trunk/Tools/ChangeLog (233307 => 233308)


--- trunk/Tools/ChangeLog	2018-06-28 15:42:42 UTC (rev 233307)
+++ trunk/Tools/ChangeLog	2018-06-28 17:03:24 UTC (rev 233308)
@@ -1,3 +1,15 @@
+2018-06-28  Sihui Liu  <[email protected]>
+
+        Cookie API: cookie creation time is wrong
+        https://bugs.webkit.org/show_bug.cgi?id=187101
+
+        Reviewed by Geoffrey Garen.
+
+        Add test coverage: make sure the cookie creation time returned is the same as set.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
+        (TEST):
+
 2018-06-28  Simon Fraser  <[email protected]>
 
         The lldb vector summary provider always shows zero capacity

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm (233307 => 233308)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm	2018-06-28 15:42:42 UTC (rev 233307)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm	2018-06-28 17:03:24 UTC (rev 233308)
@@ -367,12 +367,14 @@
 
     globalCookieStore = dataStore.httpCookieStore;
 
-    RetainPtr<NSHTTPCookie> cookie = [NSHTTPCookie cookieWithProperties:@{
-        NSHTTPCookiePath: @"/path",
-        NSHTTPCookieName: @"CookieName",
-        NSHTTPCookieValue: @"CookieValue",
-        NSHTTPCookieDomain: @".www.webkit.org",
-    }];
+    NSMutableDictionary *cookieProperties = [[NSMutableDictionary alloc] init];
+    [cookieProperties setObject:@"cookieName" forKey:NSHTTPCookieName];
+    [cookieProperties setObject:@"cookieValue" forKey:NSHTTPCookieValue];
+    [cookieProperties setObject:@".www.webkit.org" forKey:NSHTTPCookieDomain];
+    [cookieProperties setObject:@"/path" forKey:NSHTTPCookiePath];
+    RetainPtr<NSNumber> creationTime = [NSNumber numberWithDouble:100000];
+    [cookieProperties setObject:creationTime.get() forKey:@"Created"];
+    RetainPtr<NSHTTPCookie> cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
 
     [globalCookieStore setCookie:cookie.get() completionHandler:[]() {
         gotFlag = true;
@@ -380,10 +382,10 @@
     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"];
+        NSNumber* createdTime = [cookies objectAtIndex:0].properties[@"Created"];
+        EXPECT_TRUE([creationTime.get() isEqual:createdTime]);
         gotFlag = true;
     }];
     TestWebKitAPI::Util::run(&gotFlag);
@@ -393,8 +395,8 @@
 
     [globalCookieStore getAllCookies:^(NSArray<NSHTTPCookie *> *cookies) {
         ASSERT_EQ(1u, cookies.count);
-        NSNumber* creationTime2 = [cookies objectAtIndex:0].properties[@"Created"];
-        EXPECT_TRUE([creationTime.get() isEqual:creationTime2]);
+        NSNumber* createdTime = [cookies objectAtIndex:0].properties[@"Created"];
+        EXPECT_TRUE([creationTime.get() isEqual:createdTime]);
         gotFlag = true;
     }];
     TestWebKitAPI::Util::run(&gotFlag);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to