Diff
Modified: trunk/LayoutTests/ChangeLog (229149 => 229150)
--- trunk/LayoutTests/ChangeLog 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/LayoutTests/ChangeLog 2018-03-01 23:18:28 UTC (rev 229150)
@@ -1,3 +1,16 @@
+2018-03-01 Youenn Fablet <[email protected]>
+
+ Add API test to validate setting of service worker and cache storage directories
+ https://bugs.webkit.org/show_bug.cgi?id=182543
+
+ Reviewed by Chris Dumez.
+
+ Updated tests according new engine representation.
+
+ * http/tests/cache-storage/cache-clearing-origin.https.html:
+ * http/tests/cache-storage/cache-origins.https.html:
+ * http/tests/cache-storage/cache-representation.https.html:
+
2018-03-01 Daniel Bates <[email protected]>
CSS ::selection stroke-color and stroke-width are not applied to selected text in text fields
Modified: trunk/LayoutTests/http/tests/cache-storage/cache-clearing-origin.https.html (229149 => 229150)
--- trunk/LayoutTests/http/tests/cache-storage/cache-clearing-origin.https.html 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/LayoutTests/http/tests/cache-storage/cache-clearing-origin.https.html 2018-03-01 23:18:28 UTC (rev 229150)
@@ -23,7 +23,7 @@
return new Promise((resolve, reject) => {
var counter = 0;
window.addEventListener("message", async (event) => {
- var representation = JSON.parse(await internals.cacheStorageEngineRepresentation());
+ var representation = JSON.parse(await internals.cacheStorageEngineRepresentation()).origins;
test(() => {
representation.sort(compareClientOrigins);
var cache = representation[0].origin.clientOrigin === "https://localhost:8443"
@@ -34,7 +34,7 @@
testRunner.clearDOMCache('https://localhost:8443');
- representation = JSON.parse(await internals.cacheStorageEngineRepresentation());
+ representation = JSON.parse(await internals.cacheStorageEngineRepresentation()).origins;
test(() => {
representation.sort(compareClientOrigins);
assert_equals(representation[0].origin.topOrigin, "https://127.0.0.1:8443", "top origin of cache 1");
Modified: trunk/LayoutTests/http/tests/cache-storage/cache-origins.https.html (229149 => 229150)
--- trunk/LayoutTests/http/tests/cache-storage/cache-origins.https.html 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/LayoutTests/http/tests/cache-storage/cache-origins.https.html 2018-03-01 23:18:28 UTC (rev 229150)
@@ -19,7 +19,7 @@
async function checkCachesAfterClearingOrigins() {
testRunner.clearDOMCache('https://127.0.0.1:8443');
- var representation = JSON.parse(await internals.cacheStorageEngineRepresentation());
+ var representation = JSON.parse(await internals.cacheStorageEngineRepresentation()).origins;
test(() => {
assert_equals(representation[0].origin.topOrigin, "https://127.0.0.1:8443", "top origin of cache 1");
assert_equals(representation[1].origin.topOrigin, "https://127.0.0.1:8443", "top origin of cache 2");
@@ -31,7 +31,7 @@
}
async function checkCacheRepresentation() {
- var representation = JSON.parse(await internals.cacheStorageEngineRepresentation());
+ var representation = JSON.parse(await internals.cacheStorageEngineRepresentation()).origins;
test(() => {
assert_equals(representation[0].origin.topOrigin, "https://127.0.0.1:8443", "top origin of cache 1");
assert_equals(representation[1].origin.topOrigin, "https://127.0.0.1:8443", "top origin of cache 2");
Modified: trunk/LayoutTests/http/tests/cache-storage/cache-representation.https.html (229149 => 229150)
--- trunk/LayoutTests/http/tests/cache-storage/cache-representation.https.html 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/LayoutTests/http/tests/cache-storage/cache-representation.https.html 2018-03-01 23:18:28 UTC (rev 229150)
@@ -14,7 +14,7 @@
function checkCaches(hasPersistent, hasRemoved, name, value) {
test(() => {
- var results = JSON.parse(value);
+ var results = JSON.parse(value).origins;
assert_equals(results.length, 1);
var caches = results[0].caches;
assert_equals(!!caches["persistent"].length, hasPersistent, "persistent");
Modified: trunk/Source/WebCore/ChangeLog (229149 => 229150)
--- trunk/Source/WebCore/ChangeLog 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/Source/WebCore/ChangeLog 2018-03-01 23:18:28 UTC (rev 229150)
@@ -1,5 +1,28 @@
2018-03-01 Youenn Fablet <[email protected]>
+ Add API test to validate setting of service worker and cache storage directories
+ https://bugs.webkit.org/show_bug.cgi?id=182543
+
+ Reviewed by Chris Dumez.
+
+ Covered by API tests.
+
+ Add getters to service worker registration directory.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::serviceWorkerRegistrationDirectory):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+ * workers/service/SWClientConnection.h:
+ * workers/service/server/RegistrationDatabase.h:
+ (WebCore::RegistrationDatabase::serviceWorkerRegistrationDirectory const):
+ * workers/service/server/RegistrationStore.h:
+ (WebCore::RegistrationStore::serviceWorkerRegistrationDirectory const):
+ * workers/service/server/SWServer.h:
+ (WebCore::SWServer::serviceWorkerRegistrationDirectory const):
+
+2018-03-01 Youenn Fablet <[email protected]>
+
SWServer::removeClientServiceWorkerRegistration should not log an error if there is no registration
https://bugs.webkit.org/show_bug.cgi?id=183248
Modified: trunk/Source/WebKit/ChangeLog (229149 => 229150)
--- trunk/Source/WebKit/ChangeLog 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/Source/WebKit/ChangeLog 2018-03-01 23:18:28 UTC (rev 229150)
@@ -1,3 +1,22 @@
+2018-03-01 Youenn Fablet <[email protected]>
+
+ Add API test to validate setting of service worker and cache storage directories
+ https://bugs.webkit.org/show_bug.cgi?id=182543
+
+ Reviewed by Chris Dumez.
+
+ Add cache engine directory path to its representation dump.
+ This is used in API tests to check that the path is correctly set.
+
+ Add a way for to know whether a service worker was registered from a WKWebsiteDataStore.
+ This is used in API tests to check that the path is correctly set.
+
+ * NetworkProcess/cache/CacheStorageEngine.cpp:
+ (WebKit::CacheStorage::Engine::representation):
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (-[WKWebsiteDataStore _hasRegisteredServiceWorker]):
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+
2018-03-01 Wenson Hsieh <[email protected]>
Fix some errors due to some mach port APIs being unavailable on watchOS
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (229149 => 229150)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2018-03-01 23:18:28 UTC (rev 229150)
@@ -475,7 +475,9 @@
{
bool isFirst = true;
StringBuilder builder;
- builder.append("[");
+ builder.append("{ \"path\": \"");
+ builder.append(m_rootPath);
+ builder.append("\", \"origins\": [");
for (auto& keyValue : m_caches) {
if (!isFirst)
builder.append(",");
@@ -489,7 +491,7 @@
keyValue.value->appendRepresentation(builder);
builder.append("}");
}
- builder.append("\n]");
+ builder.append("]}");
return builder.toString();
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (229149 => 229150)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2018-03-01 23:18:28 UTC (rev 229150)
@@ -37,6 +37,7 @@
#import "WebsiteDataFetchOption.h"
#import "_WKWebsiteDataStoreConfiguration.h"
#import <WebCore/URL.h>
+#import <WebKit/ServiceWorkerProcessProxy.h>
#import <wtf/BlockPtr.h>
using namespace WebCore;
@@ -341,6 +342,11 @@
});
}
+- (bool)_hasRegisteredServiceWorker
+{
+ return WebKit::ServiceWorkerProcessProxy::hasRegisteredServiceWorkers(_websiteDataStore->websiteDataStore().serviceWorkerRegistrationDirectory());
+}
+
@end
#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (229149 => 229150)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2018-03-01 23:18:28 UTC (rev 229150)
@@ -57,6 +57,8 @@
- (void)_setResourceLoadStatisticsTestingCallback:(nullable void (^)(WKWebsiteDataStore *, NSString *))callback WK_API_AVAILABLE(macosx(10.13), ios(11.0));
- (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+ (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (bool)_hasRegisteredServiceWorker WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
@end
NS_ASSUME_NONNULL_END
Modified: trunk/Tools/ChangeLog (229149 => 229150)
--- trunk/Tools/ChangeLog 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/Tools/ChangeLog 2018-03-01 23:18:28 UTC (rev 229150)
@@ -1,3 +1,12 @@
+2018-03-01 Youenn Fablet <[email protected]>
+
+ Add API test to validate setting of service worker and cache storage directories
+ https://bugs.webkit.org/show_bug.cgi?id=182543
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+
2018-03-01 Ross Kirsling <[email protected]>
[Win][DRT] Implement setSpatialNavigationEnabled.
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (229149 => 229150)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2018-03-01 23:14:45 UTC (rev 229149)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2018-03-01 23:18:28 UTC (rev 229150)
@@ -54,6 +54,7 @@
static bool done;
static String expectedMessage;
+static String retrievedString;
@interface SWMessageHandler : NSObject <WKScriptMessageHandler>
@end
@@ -978,6 +979,122 @@
TestWebKitAPI::Util::run(&done);
done = false;
}
+
+static const char* regularPageGrabbingCacheStorageDirectory = R"SWRESOURCE(
+<script>
+async function getResult()
+{
+ var result = await window.internals.cacheStorageEngineRepresentation();
+ window.webkit.messageHandlers.sw.postMessage(result);
+}
+getResult();
+</script>
+)SWRESOURCE";
+
+@interface DirectoryPageMessageHandler : NSObject <WKScriptMessageHandler>
+@end
+
+@implementation DirectoryPageMessageHandler
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+ retrievedString = [message body];
+ done = true;
+}
+@end
+
+TEST(ServiceWorkers, ServiceWorkerAndCacheStorageDefaultDirectories)
+{
+ ASSERT(mainBytes);
+ ASSERT(scriptBytes);
+
+ [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
+
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+ configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ setConfigurationInjectedBundlePath(configuration.get());
+
+ RetainPtr<DirectoryPageMessageHandler> directoryPageMessageHandler = adoptNS([[DirectoryPageMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:directoryPageMessageHandler.get() name:@"sw"];
+
+ RetainPtr<SWSchemes> handler = adoptNS([[SWSchemes alloc] init]);
+ handler->resources.set("sw://host/main.html", ResourceInfo { @"text/html", mainBytes });
+ handler->resources.set("sw://host/regularPageGrabbingCacheStorageDirectory.html", ResourceInfo { @"text/html", regularPageGrabbingCacheStorageDirectory });
+ handler->resources.set("sw://host/sw.js", ResourceInfo { @"application/_javascript_", scriptBytes });
+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"SW"];
+
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/main.html"]];
+
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ EXPECT_TRUE([[configuration websiteDataStore] _hasRegisteredServiceWorker]);
+
+ webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ [webView.get().configuration.processPool _registerURLSchemeServiceWorkersCanHandle:@"sw"];
+
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/regularPageGrabbingCacheStorageDirectory.html"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ EXPECT_TRUE(retrievedString.contains("/Caches/TestWebKitAPI/WebKit/CacheStorage"));
+
+ [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
+TEST(ServiceWorkers, ServiceWorkerAndCacheStorageSpecificDirectories)
+{
+ ASSERT(mainBytes);
+ ASSERT(scriptBytes);
+
+ [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
+
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+ configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ setConfigurationInjectedBundlePath(configuration.get());
+ auto websiteDataStore = [configuration websiteDataStore];
+ [websiteDataStore _setCacheStorageDirectory:@"/var/tmp"];
+ [websiteDataStore _setServiceWorkerRegistrationDirectory:@"/var/tmp"];
+
+ RetainPtr<DirectoryPageMessageHandler> directoryPageMessageHandler = adoptNS([[DirectoryPageMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:directoryPageMessageHandler.get() name:@"sw"];
+
+ RetainPtr<SWSchemes> handler = adoptNS([[SWSchemes alloc] init]);
+ handler->resources.set("sw://host/main.html", ResourceInfo { @"text/html", mainBytes });
+ handler->resources.set("sw://host/regularPageGrabbingCacheStorageDirectory.html", ResourceInfo { @"text/html", regularPageGrabbingCacheStorageDirectory });
+ handler->resources.set("sw://host/sw.js", ResourceInfo { @"application/_javascript_", scriptBytes });
+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"SW"];
+
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ [webView.get().configuration.processPool _registerURLSchemeServiceWorkersCanHandle:@"sw"];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/main.html"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ EXPECT_TRUE([websiteDataStore _hasRegisteredServiceWorker]);
+
+ webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/regularPageGrabbingCacheStorageDirectory.html"]];
+
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ EXPECT_TRUE(retrievedString.contains("\"path\": \"/var/tmp\""));
+
+ [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
#endif // WK_HAVE_C_SPI
TEST(ServiceWorkers, NonDefaultSessionID)