Bug 238269 - Introduce an SPI to get website data directory for origin and use it in API tests
Summary: Introduce an SPI to get website data directory for origin and use it in API t...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Website Storage (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks: 236977
  Show dependency treegraph
 
Reported: 2022-03-23 10:09 PDT by Sihui Liu
Modified: 2022-03-25 01:56 PDT (History)
6 users (show)

See Also:


Attachments
Patch (70.54 KB, patch)
2022-03-23 10:26 PDT, Sihui Liu
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (70.47 KB, patch)
2022-03-23 11:14 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (69.64 KB, patch)
2022-03-24 22:58 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (69.70 KB, patch)
2022-03-24 23:49 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sihui Liu 2022-03-23 10:09:55 PDT
...
Comment 1 Sihui Liu 2022-03-23 10:26:18 PDT
Created attachment 455514 [details]
Patch
Comment 2 Sihui Liu 2022-03-23 11:14:56 PDT
Created attachment 455523 [details]
Patch
Comment 3 Alex Christensen 2022-03-23 12:51:05 PDT
Comment on attachment 455523 [details]
Patch

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

> Source/WebKit/ChangeLog:12
> +        storage), we need to update these tests with new paths, otherwise the tests will check the wrong paths. Let's 
> +        just add an SPI so these tests can get the paths in use dynamically, which would avoid test breakage when
> +        we do website data migration.

As we do this, we should also add tests that write data to the old location and verify that the migration happens successfully.

> Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp:653
> +        removeOriginStorageManagerIfPossible(origin);

Why is this done in a function that just gets the directory?
Comment 4 Sihui Liu 2022-03-23 14:16:30 PDT
(In reply to Alex Christensen from comment #3)
> Comment on attachment 455523 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=455523&action=review
> 
> > Source/WebKit/ChangeLog:12
> > +        storage), we need to update these tests with new paths, otherwise the tests will check the wrong paths. Let's 
> > +        just add an SPI so these tests can get the paths in use dynamically, which would avoid test breakage when
> > +        we do website data migration.
> 
> As we do this, we should also add tests that write data to the old location
> and verify that the migration happens successfully.

We have test for migration, e.g. WebKit.MigrateLocalStorageDataToGeneralStorageDirectory, where we still use hardcoded paths (since we want to ensure files are moved correctly from old locations to new locations.)

> 
> > Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp:653
> > +        removeOriginStorageManagerIfPossible(origin);
> 
> Why is this done in a function that just gets the directory?

Because localOriginStorageManager(origin) may create a new OriginStorageManager to get directory, and we don't want to hold the object if it is not in use after getting directory.
Comment 5 Chris Dumez 2022-03-23 15:39:48 PDT
Comment on attachment 455523 [details]
Patch

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

> Source/WebKit/Scripts/webkit/messages.py:965
> +        'WebKit::WebsiteDataType': ['"WebsiteDataType.h"'],

Why is this needed? The header name matches the class name so it shouldn't be needed.

> Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm:854
> +    _websiteDataStore->originDirectoryForTesting(origin, topOrigin, *websiteDataType, [completionHandlerCopy](auto result) {

completionHandlerCopy = WTFMove(completionHandlerCopy)
Comment 6 Sihui Liu 2022-03-24 22:58:43 PDT
Created attachment 455727 [details]
Patch for landing
Comment 7 EWS 2022-03-24 22:59:47 PDT
Tools/Scripts/svn-apply failed to apply attachment 455727 [details] to trunk.
Please resolve the conflicts and upload a new patch.
Comment 8 Sihui Liu 2022-03-24 23:49:23 PDT
Created attachment 455730 [details]
Patch for landing
Comment 9 EWS 2022-03-25 01:55:25 PDT
Committed r291851 (248863@main): <https://commits.webkit.org/248863@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 455730 [details].
Comment 10 Radar WebKit Bug Importer 2022-03-25 01:56:16 PDT
<rdar://problem/90825693>