Title: [259745] trunk/Tools
Revision
259745
Author
[email protected]
Date
2020-04-08 12:25:31 -0700 (Wed, 08 Apr 2020)

Log Message

[macOS] TestWebKitAPI.WKHTTPCookieStore.WithoutProcessPoolDuplicates is failing
https://bugs.webkit.org/show_bug.cgi?id=209992

Reviewed by Geoffrey Garen.

Make sure existing cookies are cleared before test. Otherwise, they will affect test result.

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

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (259744 => 259745)


--- trunk/Tools/ChangeLog	2020-04-08 19:16:34 UTC (rev 259744)
+++ trunk/Tools/ChangeLog	2020-04-08 19:25:31 UTC (rev 259745)
@@ -1,3 +1,16 @@
+2020-04-08  Sihui Liu  <[email protected]>
+
+        [macOS] TestWebKitAPI.WKHTTPCookieStore.WithoutProcessPoolDuplicates is failing
+        https://bugs.webkit.org/show_bug.cgi?id=209992
+
+        Reviewed by Geoffrey Garen.
+
+        Make sure existing cookies are cleared before test. Otherwise, they will affect test result.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
+        (clearCookies):
+        (TEST):
+
 2020-04-08  Kate Cheney  <[email protected]>
 
         Return app-bound sessions for instances where WKAppBoundDomains is

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm (259744 => 259745)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm	2020-04-08 19:16:34 UTC (rev 259744)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm	2020-04-08 19:25:31 UTC (rev 259745)
@@ -634,6 +634,27 @@
     return [first.name isEqual:second.name] && [first.domain isEqual:second.domain] && [first.path isEqual:second.path] && [first.value isEqual:second.value];
 }
 
+static void clearCookies(WKHTTPCookieStore* cookieStore)
+{
+    finished = false;
+    [cookieStore getAllCookies:^(NSArray<NSHTTPCookie *> *cookies) {
+        if (!cookies || !cookies.count) {
+            finished = true;
+            return;
+        }
+
+        unsigned cookiesCount = cookies.count;
+        __block unsigned deletedCount = 0;
+        for (NSHTTPCookie* cookie in cookies) {
+            [cookieStore deleteCookie:cookie completionHandler:^{
+                if (++deletedCount == cookiesCount)
+                    finished = true;
+            }];
+        }
+    }];
+    TestWebKitAPI::Util::run(&finished);
+}
+
 TEST(WKHTTPCookieStore, WithoutProcessPoolDuplicates)
 {
     RetainPtr<WKHTTPCookieStore> httpCookieStore = [WKWebsiteDataStore defaultDataStore].httpCookieStore;
@@ -650,7 +671,9 @@
     properties.get()[NSHTTPCookieValue] = @"OtherCookieValue";
     RetainPtr<NSHTTPCookie> sessionCookieDifferentValue = [NSHTTPCookie cookieWithProperties:properties.get()];
     finished = false;
-    
+
+    clearCookies(httpCookieStore.get());
+
     [httpCookieStore.get() setCookie:sessionCookie.get() completionHandler:^{
         finished = true;
     }];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to