Bug 225773 - Add unit test using WKHTTPCookieStoreObserver and cookies received from HTTP
Summary: Add unit test using WKHTTPCookieStoreObserver and cookies received from HTTP
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-13 11:03 PDT by Alex Christensen
Modified: 2021-05-13 15:08 PDT (History)
2 users (show)

See Also:


Attachments
Patch (3.98 KB, patch)
2021-05-13 11:04 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (3.99 KB, patch)
2021-05-13 13:09 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>