Skip to content
Permalink
Browse files
REGRESSION (r294469): [ iOS ] TestWebKitAPI.NSAttributedStringWebKitA…
…dditions.DirectoriesNotCreated is a consistent failure

https://bugs.webkit.org/show_bug.cgi?id=240690

Reviewed by Chris Dumez.

r294469 failed to check if WebsiteDataStore is persistent before getting and creating directories in WebProcessPool. To
fix this and to avoid future issues, we make WebsiteDataStore return null for directory getters if it's not persistent.

* Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::GPUProcessProxy):
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::webProcessDataStoreParameters):
* Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::cookieStorageDirectory const):
(WebKit::WebsiteDataStore::containerCachesDirectory const):
(WebKit::WebsiteDataStore::parentBundleDirectory const):
(WebKit::WebsiteDataStore::networkingCachesDirectory const):
(WebKit::WebsiteDataStore::containerTemporaryDirectory const):
(WebKit::WebsiteDataStore::defaultContainerTemporaryDirectory):
(WebKit::WebsiteDataStore::cookieStorageDirectory): Deleted.
(WebKit::WebsiteDataStore::containerCachesDirectory): Deleted.
(WebKit::WebsiteDataStore::parentBundleDirectory): Deleted.
(WebKit::WebsiteDataStore::networkingCachesDirectory): Deleted.
(WebKit::WebsiteDataStore::containerTemporaryDirectory): Deleted.
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h:

Canonical link: https://commits.webkit.org/250884@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294670 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
szewai committed May 23, 2022
1 parent e612652 commit edcaae5cbf3c6f7ec6bbb55b818ce1bcfb39aabe
Showing 4 changed files with 33 additions and 14 deletions.
@@ -142,7 +142,7 @@ GPUProcessProxy::GPUProcessProxy()

#if USE(SANDBOX_EXTENSIONS_FOR_CACHE_AND_TEMP_DIRECTORY_ACCESS)
auto containerCachesDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(gpuProcessCachesDirectory());
auto containerTemporaryDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(WebsiteDataStore::containerTemporaryDirectory());
auto containerTemporaryDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(WebsiteDataStore::defaultContainerTemporaryDirectory());

if (!containerCachesDirectory.isEmpty()) {
if (auto handle = SandboxExtension::createHandleWithoutResolvingPath(containerCachesDirectory, SandboxExtension::Type::ReadWrite))
@@ -767,7 +767,7 @@ WebProcessDataStoreParameters WebProcessPool::webProcessDataStoreParameters(WebP
if (auto directory = websiteDataStore.containerCachesDirectory(); !directory.isEmpty())
containerCachesDirectoryExtensionHandle = SandboxExtension::createHandleForReadWriteDirectory(directory);
std::optional<SandboxExtension::Handle> containerTemporaryDirectoryExtensionHandle;
if (auto directory = WebsiteDataStore::containerTemporaryDirectory(); !directory.isEmpty())
if (auto directory = websiteDataStore.containerTemporaryDirectory(); !directory.isEmpty())
containerTemporaryDirectoryExtensionHandle = SandboxExtension::createHandleForReadWriteDirectory(directory);
#endif

@@ -642,15 +642,20 @@ static NavigatingToAppBoundDomain schemeOrDomainIsAppBound(const String& host, c
return path;
}

String WebsiteDataStore::cookieStorageDirectory()
String WebsiteDataStore::cookieStorageDirectory() const
{
if (!isPersistent())
return { };

return cacheDirectoryInContainerOrHomeDirectory("/Library/Cookies"_s);
}

String WebsiteDataStore::containerCachesDirectory()
String WebsiteDataStore::containerCachesDirectory() const
{
String path = cacheDirectoryInContainerOrHomeDirectory("/Library/Caches/com.apple.WebKit.WebContent/"_s);
if (!isPersistent())
return { };

String path = cacheDirectoryInContainerOrHomeDirectory("/Library/Caches/com.apple.WebKit.WebContent/"_s);
NSError *error = nil;
NSString* nsPath = path;
if (![[NSFileManager defaultManager] createDirectoryAtPath:nsPath withIntermediateDirectories:YES attributes:nil error:&error]) {
@@ -661,15 +666,20 @@ static NavigatingToAppBoundDomain schemeOrDomainIsAppBound(const String& host, c
return path;
}

String WebsiteDataStore::parentBundleDirectory()
String WebsiteDataStore::parentBundleDirectory() const
{
if (!isPersistent())
return { };

return [[[NSBundle mainBundle] bundlePath] stringByStandardizingPath];
}

String WebsiteDataStore::networkingCachesDirectory()
String WebsiteDataStore::networkingCachesDirectory() const
{
String path = cacheDirectoryInContainerOrHomeDirectory("/Library/Caches/com.apple.WebKit.Networking/"_s);
if (!isPersistent())
return { };

String path = cacheDirectoryInContainerOrHomeDirectory("/Library/Caches/com.apple.WebKit.Networking/"_s);
NSError *error = nil;
NSString* nsPath = path;
if (![[NSFileManager defaultManager] createDirectoryAtPath:nsPath withIntermediateDirectories:YES attributes:nil error:&error]) {
@@ -680,7 +690,15 @@ static NavigatingToAppBoundDomain schemeOrDomainIsAppBound(const String& host, c
return path;
}

String WebsiteDataStore::containerTemporaryDirectory()
String WebsiteDataStore::containerTemporaryDirectory() const
{
if (!isPersistent())
return { };

return defaultContainerTemporaryDirectory();
}

String WebsiteDataStore::defaultContainerTemporaryDirectory()
{
String path = NSTemporaryDirectory();
return stringByResolvingSymlinksInPath(path);
@@ -161,9 +161,10 @@ class WebsiteDataStore : public API::ObjectImpl<API::Object::Type::WebsiteDataSt
const String& cacheStorageDirectory() const { return m_resolvedConfiguration->cacheStorageDirectory(); }

#if PLATFORM(IOS_FAMILY)
String cookieStorageDirectory();
String containerCachesDirectory();
static String containerTemporaryDirectory();
String cookieStorageDirectory() const;
String containerCachesDirectory() const;
String containerTemporaryDirectory() const;
static String defaultContainerTemporaryDirectory();
static String cacheDirectoryInContainerOrHomeDirectory(const String& subpath);
#endif

@@ -429,8 +430,8 @@ class WebsiteDataStore : public API::ObjectImpl<API::Object::Type::WebsiteDataSt
#endif

#if PLATFORM(IOS_FAMILY)
String networkingCachesDirectory();
String parentBundleDirectory();
String networkingCachesDirectory() const;
String parentBundleDirectory() const;
#endif

const PAL::SessionID m_sessionID;

0 comments on commit edcaae5

Please sign in to comment.