Bug 225773

Summary: Add unit test using WKHTTPCookieStoreObserver and cookies received from HTTP
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch ews-feeder: commit-queue-

Description Alex Christensen 2021-05-13 11:03:44 PDT
Add unit test using WKHTTPCookieStoreObserver and cookies received from HTTP
Comment 1 Alex Christensen 2021-05-13 11:04:37 PDT
Created attachment 428534 [details]
Patch
Comment 2 Chris Dumez 2021-05-13 11:12:23 PDT
Comment on attachment 428534 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=428534&action=review

r=me with suggestions.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:462
> +static void deleteAllCookies(WKHTTPCookieStore *store, RetainPtr<NSMutableArray> array, BlockPtr<void(void)> completionBlock)

Maybe we should call this deleteCookies() instead of deleteAllCookies() given that it only deletes the cookies in the provided array.

Maybe we could rename array to cookies too for clarity.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:466
> +    [store deleteCookie:[array lastObject] completionHandler:^(void) {

We're not really testing the parallelism here and it is slower than could be. I wish we'd use WTF's CallbackAggregator and do the removals in parallel.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:479
> +            deleteAllCookies(store, adoptNS([cookies mutableCopy]), ^{

Why `adoptNS([cookies mutableCopy]` instead of just `cookies` ?

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:501
> +            EXPECT_EQ(cookies.count, 1u);

Should probably be ASSERT_EQ() in case we get 0 cookies.
Comment 3 Alex Christensen 2021-05-13 11:15:00 PDT
(In reply to Chris Dumez from comment #2)
> Comment on attachment 428534 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=428534&action=review
> 
> r=me with suggestions.
> 
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:462
> > +static void deleteAllCookies(WKHTTPCookieStore *store, RetainPtr<NSMutableArray> array, BlockPtr<void(void)> completionBlock)
> 
> Maybe we should call this deleteCookies() instead of deleteAllCookies()
> given that it only deletes the cookies in the provided array.
> 
> Maybe we could rename array to cookies too for clarity.
Brilliant.

> > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:466
> > +    [store deleteCookie:[array lastObject] completionHandler:^(void) {
> 
> We're not really testing the parallelism here and it is slower than could
> be. I wish we'd use WTF's CallbackAggregator and do the removals in parallel.
Parallelism isn't important here.  I'm just removing any leftovers from previous tests.

> > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:479
> > +            deleteAllCookies(store, adoptNS([cookies mutableCopy]), ^{
> 
> Why `adoptNS([cookies mutableCopy]` instead of just `cookies` ?
It needs to be mutable because I remove them one by one.
Comment 4 Alex Christensen 2021-05-13 13:09:00 PDT
Created attachment 428552 [details]
Patch
Comment 5 EWS 2021-05-13 14:28:42 PDT
Committed r277451 (237699@main): <https://commits.webkit.org/237699@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 428552 [details].
Comment 6 Radar WebKit Bug Importer 2021-05-13 15:08:23 PDT
<rdar://problem/77988762>