Title: [232252] trunk/Tools
Revision
232252
Author
[email protected]
Date
2018-05-28 20:46:35 -0700 (Mon, 28 May 2018)

Log Message

Add an API test to check process privilege when using Cookie API
https://bugs.webkit.org/show_bug.cgi?id=185406

Reviewed by Geoffrey Garen.

Add API test coverage.

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

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (232251 => 232252)


--- trunk/Tools/ChangeLog	2018-05-29 02:40:43 UTC (rev 232251)
+++ trunk/Tools/ChangeLog	2018-05-29 03:46:35 UTC (rev 232252)
@@ -1,3 +1,15 @@
+2018-05-28  Sihui Liu  <[email protected]>
+
+        Add an API test to check process privilege when using Cookie API
+        https://bugs.webkit.org/show_bug.cgi?id=185406
+
+        Reviewed by Geoffrey Garen.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
+        (TEST):
+
 2018-05-28  Thibault Saunier  <[email protected]>
 
         [GStreamer] Handle changes in the "drm-preferred-decryption-system-id" NEED_CONTEXT message.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm (232251 => 232252)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm	2018-05-29 02:40:43 UTC (rev 232251)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm	2018-05-29 03:46:35 UTC (rev 232252)
@@ -32,6 +32,7 @@
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/_WKWebsiteDataStoreConfiguration.h>
+#import <wtf/ProcessPrivilege.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Seconds.h>
 #import <wtf/text/WTFString.h>
@@ -194,6 +195,41 @@
     runTestWithWebsiteDataStore([WKWebsiteDataStore defaultDataStore]);
 }
 
+TEST(WebKit, WKHTTPCookieStoreProcessPrivilege)
+{
+    // Make sure UI process has no privilege at the beginning.
+    WTF::setProcessPrivileges({ });
+
+    [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:[] {
+        gotFlag = true;
+    }];
+    TestWebKitAPI::Util::run(&gotFlag);
+    gotFlag = false;
+
+    globalCookieStore = [[WKWebsiteDataStore defaultDataStore] httpCookieStore];
+
+    RetainPtr<NSHTTPCookie> cookie = [NSHTTPCookie cookieWithProperties:@{
+        NSHTTPCookiePath: @"/",
+        NSHTTPCookieName: @"Cookie",
+        NSHTTPCookieValue: @"Value",
+        NSHTTPCookieDomain: @".www.webkit.org",
+    }];
+
+    [globalCookieStore setCookie:cookie.get() completionHandler:[]() {
+        gotFlag = true;
+    }];
+    TestWebKitAPI::Util::run(&gotFlag);
+    gotFlag = false;
+
+
+    [globalCookieStore getAllCookies:^(NSArray<NSHTTPCookie *>*cookies) {
+        ASSERT_EQ(1u, cookies.count);
+        gotFlag = true;
+    }];
+    TestWebKitAPI::Util::run(&gotFlag);
+    gotFlag = false;
+}
+
 TEST(WebKit, WKHTTPCookieStoreHttpOnly) 
 {
     WKWebsiteDataStore* dataStore = [WKWebsiteDataStore defaultDataStore];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to