Diff
Modified: trunk/Source/WebKit/ChangeLog (247732 => 247733)
--- trunk/Source/WebKit/ChangeLog 2019-07-23 19:18:13 UTC (rev 247732)
+++ trunk/Source/WebKit/ChangeLog 2019-07-23 19:32:48 UTC (rev 247733)
@@ -1,3 +1,23 @@
+2019-07-23 Alex Christensen <[email protected]>
+
+ Add SPI for setting media cache and key location on _WKWebsiteDataStoreConfiguration
+ https://bugs.webkit.org/show_bug.cgi?id=199972
+
+ Reviewed by Jer Noble.
+
+ This is a step towards removing WebsiteDataStore::legacyDefaultDataStoreConfiguration
+ I added a unit test for the media cache location,
+ but the media key location can't reasonably be unit tested in an open source project.
+
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (-[WKWebsiteDataStore _initWithConfiguration:]):
+ * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
+ * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
+ (-[_WKWebsiteDataStoreConfiguration mediaCacheDirectory]):
+ (-[_WKWebsiteDataStoreConfiguration setMediaCacheDirectory:]):
+ (-[_WKWebsiteDataStoreConfiguration mediaKeysStorageDirectory]):
+ (-[_WKWebsiteDataStoreConfiguration setMediaKeysStorageDirectory:]):
+
2019-07-23 Wenson Hsieh <[email protected]>
[macOS 10.15] Web process crashes when attempting to show the font panel via Font > Show Fonts
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (247732 => 247733)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-07-23 19:18:13 UTC (rev 247732)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-07-23 19:32:48 UTC (rev 247733)
@@ -256,6 +256,10 @@
config->setApplicationCacheDirectory(configuration.applicationCacheDirectory.path);
if (configuration.applicationCacheFlatFileSubdirectoryName)
config->setApplicationCacheFlatFileSubdirectoryName(configuration.applicationCacheFlatFileSubdirectoryName);
+ if (configuration.mediaCacheDirectory)
+ config->setMediaCacheDirectory(configuration.mediaCacheDirectory.path);
+ if (configuration.mediaKeysStorageDirectory)
+ config->setMediaKeysStorageDirectory(configuration.mediaKeysStorageDirectory.path);
} else {
RELEASE_ASSERT(!configuration._webStorageDirectory);
RELEASE_ASSERT(!configuration._webSQLDatabaseDirectory);
@@ -267,6 +271,8 @@
RELEASE_ASSERT(!configuration.networkCacheDirectory);
RELEASE_ASSERT(!configuration.deviceIdHashSaltsStorageDirectory);
RELEASE_ASSERT(!configuration.applicationCacheDirectory);
+ RELEASE_ASSERT(!configuration.mediaCacheDirectory);
+ RELEASE_ASSERT(!configuration.mediaKeysStorageDirectory);
}
if (configuration.sourceApplicationBundleIdentifier)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h (247732 => 247733)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h 2019-07-23 19:18:13 UTC (rev 247732)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h 2019-07-23 19:32:48 UTC (rev 247733)
@@ -57,6 +57,8 @@
@property (nonatomic, nullable, copy) NSURL *deviceIdHashSaltsStorageDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, nullable, copy) NSURL *applicationCacheDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, nullable, copy) NSString *applicationCacheFlatFileSubdirectoryName WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, nullable, copy) NSURL *mediaCacheDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, nullable, copy) NSURL *mediaKeysStorageDirectory WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
// Testing only.
@property (nonatomic) BOOL allLoadsBlockedByDeviceManagementRestrictionsForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm (247732 => 247733)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm 2019-07-23 19:18:13 UTC (rev 247732)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm 2019-07-23 19:32:48 UTC (rev 247733)
@@ -248,6 +248,32 @@
_configuration->setApplicationCacheFlatFileSubdirectoryName(name);
}
+- (NSURL *)mediaCacheDirectory
+{
+ return [NSURL fileURLWithPath:_configuration->mediaCacheDirectory() isDirectory:YES];
+}
+
+- (void)setMediaCacheDirectory:(NSURL *)url
+{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set mediaCacheDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
+ checkURLArgument(url);
+ _configuration->setMediaCacheDirectory(url.path);
+}
+
+- (NSURL *)mediaKeysStorageDirectory
+{
+ return [NSURL fileURLWithPath:_configuration->mediaKeysStorageDirectory() isDirectory:YES];
+}
+
+- (void)setMediaKeysStorageDirectory:(NSURL *)url
+{
+ if (!_configuration->isPersistent())
+ [NSException raise:NSInvalidArgumentException format:@"Cannot set mediaKeysStorageDirectory on a non-persistent _WKWebsiteDataStoreConfiguration."];
+ checkURLArgument(url);
+ _configuration->setMediaKeysStorageDirectory(url.path);
+}
+
- (BOOL)deviceManagementRestrictionsEnabled
{
return _configuration->deviceManagementRestrictionsEnabled();
Modified: trunk/Tools/ChangeLog (247732 => 247733)
--- trunk/Tools/ChangeLog 2019-07-23 19:18:13 UTC (rev 247732)
+++ trunk/Tools/ChangeLog 2019-07-23 19:32:48 UTC (rev 247733)
@@ -1,3 +1,13 @@
+2019-07-23 Alex Christensen <[email protected]>
+
+ Add SPI for setting media cache and key location on _WKWebsiteDataStoreConfiguration
+ https://bugs.webkit.org/show_bug.cgi?id=199972
+
+ Reviewed by Jer Noble.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+ (TEST):
+
2019-07-23 Alicia Boya GarcĂa <[email protected]>
[WTF] Add DataMutex and MainThreadData wrappers
Modified: trunk/Tools/TestWebKitAPI/TCPServer.cpp (247732 => 247733)
--- trunk/Tools/TestWebKitAPI/TCPServer.cpp 2019-07-23 19:18:13 UTC (rev 247732)
+++ trunk/Tools/TestWebKitAPI/TCPServer.cpp 2019-07-23 19:32:48 UTC (rev 247733)
@@ -284,7 +284,8 @@
{
uint8_t buffer[1000];
auto bytesRead = ::read(socket, buffer, sizeof(buffer));
- ASSERT_UNUSED(bytesRead, bytesRead > 0);
+ if (bytesRead <= 0)
+ return { };
ASSERT(static_cast<size_t>(bytesRead) < sizeof(buffer));
Vector<uint8_t> vector;
@@ -303,7 +304,8 @@
{
uint8_t buffer[1000];
auto bytesRead = SSL_read(ssl, buffer, sizeof(buffer));
- ASSERT_UNUSED(bytesRead, bytesRead > 0);
+ if (bytesRead <= 0)
+ return { };
ASSERT(static_cast<size_t>(bytesRead) < sizeof(buffer));
Vector<uint8_t> vector;
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (247732 => 247733)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm 2019-07-23 19:18:13 UTC (rev 247732)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm 2019-07-23 19:32:48 UTC (rev 247733)
@@ -42,6 +42,7 @@
#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
#import <wtf/Deque.h>
#import <wtf/RetainPtr.h>
+#import <wtf/text/WTFString.h>
static bool receivedScriptMessage;
static Deque<RetainPtr<WKScriptMessage>> scriptMessages;
@@ -611,3 +612,78 @@
[fileManager removeItemAtPath:path error:&error];
EXPECT_FALSE(error);
}
+
+// FIXME: investigate why this test times out on High Sierra
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS_FAMILY)
+TEST(WebKit, MediaCache)
+{
+ std::atomic<bool> done = false;
+ using namespace TestWebKitAPI;
+ RetainPtr<NSData> data = "" dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"test" withExtension:@"mp4" subdirectory:@"TestWebKitAPI.resources"]];
+ uint64_t dataLength = [data length];
+
+ TCPServer server([&] (int socket) {
+ TCPServer::read(socket);
+ const char* firstResponse =
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Type: text/html\r\n"
+ "Content-Length: 55\r\n\r\n"
+ "<video><source src='' type='video/mp4'></video>";
+ TCPServer::write(socket, firstResponse, strlen(firstResponse));
+
+ while (!done) {
+ auto bytes = TCPServer::read(socket);
+ if (done)
+ break;
+ StringView request(static_cast<const LChar*>(bytes.data()), bytes.size());
+ String rangeBytes = "Range: bytes="_s;
+ auto begin = request.find(StringView(rangeBytes), 0);
+ ASSERT(begin != notFound);
+ auto dash = request.find('-', begin);
+ ASSERT(dash != notFound);
+ auto end = request.find('\r', dash);
+ ASSERT(end != notFound);
+
+ auto rangeBegin = *request.substring(begin + rangeBytes.length(), dash - begin - rangeBytes.length()).toUInt64Strict();
+ auto rangeEnd = *request.substring(dash + 1, end - dash - 1).toUInt64Strict();
+
+ NSString *responseHeaderString = [NSString stringWithFormat:
+ @"HTTP/1.1 206 Partial Content\r\n"
+ "Content-Range: bytes %llu-%llu/%llu\r\n"
+ "Content-Length: %llu\r\n\r\n",
+ rangeBegin, rangeEnd, dataLength, rangeEnd - rangeBegin];
+ NSData *responseHeader = [responseHeaderString dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *responseBody = [data subdataWithRange:NSMakeRange(rangeBegin, rangeEnd - rangeBegin)];
+ NSMutableData *response = [NSMutableData dataWithCapacity:responseHeader.length + responseBody.length];
+ [response appendData:responseHeader];
+ [response appendData:responseBody];
+ TCPServer::write(socket, response.bytes, response.length);
+ }
+ });
+
+ NSURL *tempDir = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"CustomPathsTest"] isDirectory:YES];
+ NSString *path = tempDir.path;
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ EXPECT_FALSE([fileManager fileExistsAtPath:path]);
+
+ auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+ [websiteDataStoreConfiguration setMediaCacheDirectory:tempDir];
+
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setWebsiteDataStore:[[[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()] autorelease]];
+
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ [webView synchronouslyLoadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]]];
+
+ NSError *error = nil;
+ while (![fileManager contentsOfDirectoryAtPath:path error:&error].count)
+ Util::spinRunLoop();
+ EXPECT_FALSE(error);
+
+ done = true;
+ [[webView configuration].processPool _terminateNetworkProcess];
+
+ [fileManager removeItemAtPath:path error:&error];
+ EXPECT_FALSE(error);
+}
+#endif