Diff
Modified: trunk/Source/WebCore/ChangeLog (228187 => 228188)
--- trunk/Source/WebCore/ChangeLog 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebCore/ChangeLog 2018-02-06 21:24:09 UTC (rev 228188)
@@ -1,3 +1,18 @@
+2018-02-06 Youenn Fablet <you...@apple.com>
+
+ HasServiceWorkerRegistration bit should be sent when creating a new page
+ https://bugs.webkit.org/show_bug.cgi?id=182410
+
+ Reviewed by Chris Dumez.
+
+ Covered by new API test.
+
+ Changed the default value of service workers being registered to false.
+ Every page created in the process will be responsible to change the value to true,
+ at which time the value will be kept to true for the lifetime of the process.
+
+ * workers/service/ServiceWorkerProvider.h:
+
2018-02-06 Ross Kirsling <ross.kirsl...@sony.com>
Add missing #if ENABLE(VIDEO) after r228092.
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerProvider.cpp (228187 => 228188)
--- trunk/Source/WebCore/workers/service/ServiceWorkerProvider.cpp 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerProvider.cpp 2018-02-06 21:24:09 UTC (rev 228188)
@@ -49,7 +49,7 @@
{
auto* connection = existingServiceWorkerConnectionForSession(sessionID);
if (!connection)
- return m_hasRegisteredServiceWorkers;
+ return m_mayHaveRegisteredServiceWorkers;
return connection->mayHaveServiceWorkerRegisteredForOrigin(origin);
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerProvider.h (228187 => 228188)
--- trunk/Source/WebCore/workers/service/ServiceWorkerProvider.h 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerProvider.h 2018-02-06 21:24:09 UTC (rev 228188)
@@ -49,10 +49,10 @@
WEBCORE_EXPORT void registerServiceWorkerClients(PAL::SessionID);
- void setHasRegisteredServiceWorkers(bool value) { m_hasRegisteredServiceWorkers = value; }
+ void setMayHaveRegisteredServiceWorkers() { m_mayHaveRegisteredServiceWorkers = true; }
private:
- bool m_hasRegisteredServiceWorkers { true };
+ bool m_mayHaveRegisteredServiceWorkers { false };
};
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (228187 => 228188)
--- trunk/Source/WebKit/ChangeLog 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/ChangeLog 2018-02-06 21:24:09 UTC (rev 228188)
@@ -1,3 +1,38 @@
+2018-02-06 Youenn Fablet <you...@apple.com>
+
+ HasServiceWorkerRegistration bit should be sent when creating a new page
+ https://bugs.webkit.org/show_bug.cgi?id=182410
+
+ Reviewed by Chris Dumez.
+
+ Move the bit computation at page creation time.
+ This allows computing the bit based on the web site data store and not only on the pool configuration.
+ WebPage uses that bit to activate service worker registration matching for the whole process.
+
+ In case there is a service worker process proxy created, the bit is set to true by default.
+
+ Bit is computed by checking for database file presence.
+ This information is cached in a map for efficiency reasons and cleared when a service worker process proxy is created.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * Shared/WebProcessCreationParameters.cpp:
+ (WebKit::WebProcessCreationParameters::encode const):
+ (WebKit::WebProcessCreationParameters::decode):
+ * Shared/WebProcessCreationParameters.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::initializeWebPage):
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::establishWorkerContextConnectionToStorageProcess):
+ (WebKit::WebProcessPool::initializeNewWebProcess):
+ (WebKit::WebProcessPool::mayHaveRegisteredServiceWorkers):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::m_cpuLimit):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::initializeWebProcess):
+
2018-02-06 Michael Catanzaro <mcatanz...@igalia.com>
Unreviewed, fix format specifiers added in r228116
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (228187 => 228188)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-02-06 21:24:09 UTC (rev 228188)
@@ -104,6 +104,9 @@
#if ENABLE(APPLICATION_MANIFEST)
encoder << applicationManifest;
#endif
+#if ENABLE(SERVICE_WORKER)
+ encoder << hasRegisteredServiceWorkers;
+#endif
encoder << iceCandidateFilteringEnabled;
encoder << enumeratingAllNetworkInterfacesEnabled;
encoder << userContentWorlds;
@@ -283,6 +286,10 @@
return std::nullopt;
parameters.applicationManifest = WTFMove(*applicationManifest);
#endif
+#if ENABLE(SERVICE_WORKER)
+ if (!decoder.decode(parameters.hasRegisteredServiceWorkers))
+ return std::nullopt;
+#endif
if (!decoder.decode(parameters.iceCandidateFilteringEnabled))
return std::nullopt;
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (228187 => 228188)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2018-02-06 21:24:09 UTC (rev 228188)
@@ -166,6 +166,10 @@
std::optional<WebCore::ApplicationManifest> applicationManifest;
#endif
+#if ENABLE(SERVICE_WORKER)
+ bool hasRegisteredServiceWorkers { true };
+#endif
+
// WebRTC members.
bool iceCandidateFilteringEnabled { true };
bool enumeratingAllNetworkInterfacesEnabled { false };
Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (228187 => 228188)
--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp 2018-02-06 21:24:09 UTC (rev 228188)
@@ -127,10 +127,6 @@
encoder << hasRichContentServices;
#endif
-#if ENABLE(SERVICE_WORKER)
- encoder << hasRegisteredServiceWorkers;
-#endif
-
#if ENABLE(NETSCAPE_PLUGIN_API)
encoder << pluginLoadClientPolicies;
#endif
@@ -365,11 +361,6 @@
return false;
#endif
-#if ENABLE(SERVICE_WORKER)
- if (!decoder.decode(parameters.hasRegisteredServiceWorkers))
- return false;
-#endif
-
#if ENABLE(NETSCAPE_PLUGIN_API)
if (!decoder.decode(parameters.pluginLoadClientPolicies))
return false;
Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (228187 => 228188)
--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h 2018-02-06 21:24:09 UTC (rev 228188)
@@ -131,10 +131,6 @@
bool hasRichContentServices { false };
#endif
-#if ENABLE(SERVICE_WORKER)
- bool hasRegisteredServiceWorkers { true };
-#endif
-
Seconds terminationTimeout;
TextCheckerState textCheckerState;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (228187 => 228188)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-02-06 21:24:09 UTC (rev 228188)
@@ -730,8 +730,14 @@
}
#endif
- process().send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
+ auto parameters = creationParameters();
+#if ENABLE(SERVICE_WORKER)
+ parameters.hasRegisteredServiceWorkers = process().processPool().mayHaveRegisteredServiceWorkers(m_websiteDataStore);
+#endif
+
+ process().send(Messages::WebProcess::CreateWebPage(m_pageID, parameters), 0);
+
m_needsToFinishInitializingWebPageAfterProcessLaunch = true;
finishInitializingWebPageAfterProcessLaunch();
}
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (228187 => 228188)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-02-06 21:24:09 UTC (rev 228188)
@@ -601,6 +601,8 @@
if (m_serviceWorkerProcess)
return;
+ m_mayHaveRegisteredServiceWorkers.clear();
+
WebsiteDataStore* websiteDataStore = nullptr;
if (sessionID)
websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(*sessionID);
@@ -816,13 +818,6 @@
serviceController.refreshExistingServices();
#endif
-#if ENABLE(SERVICE_WORKER)
- String serviceWorkerRegistrationDirectory = websiteDataStore.resolvedServiceWorkerRegistrationDirectory();
- if (serviceWorkerRegistrationDirectory.isEmpty())
- serviceWorkerRegistrationDirectory = API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();
- parameters.hasRegisteredServiceWorkers = ServiceWorkerProcessProxy::hasRegisteredServiceWorkers(serviceWorkerRegistrationDirectory);
-#endif
-
#if ENABLE(NETSCAPE_PLUGIN_API)
parameters.pluginLoadClientPolicies = m_pluginLoadClientPolicies;
#endif
@@ -1054,6 +1049,21 @@
if (m_serviceWorkerProcess)
m_serviceWorkerProcess->setUserAgent(m_serviceWorkerUserAgent);
}
+
+bool WebProcessPool::mayHaveRegisteredServiceWorkers(const WebsiteDataStore& store)
+{
+ if (serviceWorkerProxy())
+ return true;
+
+ String serviceWorkerRegistrationDirectory = store.resolvedServiceWorkerRegistrationDirectory();
+ if (serviceWorkerRegistrationDirectory.isEmpty())
+ serviceWorkerRegistrationDirectory = API::WebsiteDataStore::defaultDataStoreConfiguration().serviceWorkerRegistrationDirectory;
+
+ return m_mayHaveRegisteredServiceWorkers.ensure(serviceWorkerRegistrationDirectory, [&] {
+ // FIXME: Make this computation on a background thread.
+ return ServiceWorkerProcessProxy::hasRegisteredServiceWorkers(serviceWorkerRegistrationDirectory);
+ }).iterator->value;
+}
#endif
void WebProcessPool::pageBeginUsingWebsiteDataStore(WebPageProxy& page)
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (228187 => 228188)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2018-02-06 21:24:09 UTC (rev 228188)
@@ -330,6 +330,7 @@
void setAllowsAnySSLCertificateForServiceWorker(bool allows) { m_allowsAnySSLCertificateForServiceWorker = allows; }
bool allowsAnySSLCertificateForServiceWorker() const { return m_allowsAnySSLCertificateForServiceWorker; }
void updateServiceWorkerUserAgent(const String& userAgent);
+ bool mayHaveRegisteredServiceWorkers(const WebsiteDataStore&);
#endif
#if PLATFORM(COCOA)
@@ -505,6 +506,7 @@
bool m_allowsAnySSLCertificateForServiceWorker { false };
String m_serviceWorkerUserAgent;
std::optional<WebPreferencesStore> m_serviceWorkerPreferences;
+ HashMap<String, bool> m_mayHaveRegisteredServiceWorkers;
#endif
Ref<WebPageGroup> m_defaultPageGroup;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (228187 => 228188)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-02-06 21:24:09 UTC (rev 228188)
@@ -186,6 +186,7 @@
#include <WebCore/SchemeRegistry.h>
#include <WebCore/ScriptController.h>
#include <WebCore/SerializedScriptValue.h>
+#include <WebCore/ServiceWorkerProvider.h>
#include <WebCore/Settings.h>
#include <WebCore/ShadowRoot.h>
#include <WebCore/SharedBuffer.h>
@@ -566,6 +567,11 @@
setSmartInsertDeleteEnabled(parameters.smartInsertDeleteEnabled);
#endif
+#if ENABLE(SERVICE_WORKER)
+ if (parameters.hasRegisteredServiceWorkers)
+ ServiceWorkerProvider::singleton().setMayHaveRegisteredServiceWorkers();
+#endif
+
#if ENABLE(WEB_RTC)
if (!parameters.iceCandidateFilteringEnabled)
disableICECandidateFiltering();
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (228187 => 228188)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2018-02-06 21:24:09 UTC (rev 228188)
@@ -411,9 +411,7 @@
#endif
#if ENABLE(SERVICE_WORKER)
- auto& serviceWorkerProvider = WebServiceWorkerProvider::singleton();
- serviceWorkerProvider.setHasRegisteredServiceWorkers(parameters.hasRegisteredServiceWorkers);
- ServiceWorkerProvider::setSharedProvider(serviceWorkerProvider);
+ ServiceWorkerProvider::setSharedProvider(WebServiceWorkerProvider::singleton());
#endif
#if ENABLE(WEBASSEMBLY)
Modified: trunk/Tools/ChangeLog (228187 => 228188)
--- trunk/Tools/ChangeLog 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Tools/ChangeLog 2018-02-06 21:24:09 UTC (rev 228188)
@@ -1,3 +1,12 @@
+2018-02-06 Youenn Fablet <you...@apple.com>
+
+ HasServiceWorkerRegistration bit should be sent when creating a new page
+ https://bugs.webkit.org/show_bug.cgi?id=182410
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+
2018-02-06 Andres Gomez <ago...@igalia.com>
[GTK][WPE] Add dependencies watching lists for WKGTK+ and WPE
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (228187 => 228188)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2018-02-06 21:00:52 UTC (rev 228187)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2018-02-06 21:24:09 UTC (rev 228188)
@@ -33,6 +33,7 @@
#import <WebKit/WKURLSchemeTaskPrivate.h>
#import <WebKit/WKWebViewConfigurationPrivate.h>
#import <WebKit/WKWebsiteDataStorePrivate.h>
+#import <WebKit/WKWebsiteDataStoreRef.h>
#import <WebKit/WebKit.h>
#import <WebKit/_WKExperimentalFeature.h>
#import <wtf/Deque.h>
@@ -838,6 +839,96 @@
done = false;
}
+TEST(ServiceWorkers, HasServiceWorkerRegistrationBit)
+{
+ [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
+
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ setConfigurationInjectedBundlePath(configuration.get());
+
+ done = false;
+
+ [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [[configuration websiteDataStore] fetchDataRecordsOfTypes:[NSSet setWithObject:WKWebsiteDataTypeServiceWorkerRegistrations] completionHandler:^(NSArray<WKWebsiteDataRecord *> *websiteDataRecords) {
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ RetainPtr<SWMessageHandler> messageHandler = adoptNS([[SWMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
+ RetainPtr<RegularPageMessageHandler> regularPageMessageHandler = adoptNS([[RegularPageMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];
+
+ RetainPtr<SWSchemes> handler = adoptNS([[SWSchemes alloc] init]);
+ handler->resources.set("sw://host/regularPageWithoutConnection.html", ResourceInfo { @"text/html", regularPageWithoutConnectionBytes });
+ handler->resources.set("sw://host/regularPageWithConnection.html", ResourceInfo { @"text/html", regularPageWithConnectionBytes });
+ handler->resources.set("sw://host/mainWithScope.html", ResourceInfo { @"text/html", mainBytesWithScope });
+ handler->resources.set("sw://host/main.html", ResourceInfo { @"text/html", mainBytes });
+ 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()]);
+
+ // Load a page that registers a service worker.
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/mainWithScope.html"]];
+
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ webView = nullptr;
+
+ // Now that a sw is registered, let's create a new configuration and try loading a regular page
+ RetainPtr<WKWebViewConfiguration> newConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ setConfigurationInjectedBundlePath(newConfiguration.get());
+
+ [[newConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
+ [[newConfiguration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];
+ [newConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"SW"];
+
+ newConfiguration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
+ [newConfiguration.get().websiteDataStore _setServiceWorkerRegistrationDirectory: @"~/nonexistingfolder"];
+
+ [newConfiguration.get().processPool _setMaximumNumberOfProcesses:1];
+
+ webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/regularPageWithoutConnection.html"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ // There should be no storage process created.
+ EXPECT_EQ(0, webView.get().configuration.processPool._storageProcessIdentifier);
+
+ // Let's use the web site data store that has service worker and load a page.
+ newConfiguration.get().websiteDataStore = [configuration websiteDataStore];
+
+ webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
+ EXPECT_EQ(1u, webView.get().configuration.processPool._webProcessCount);
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/regularPageWithConnection.html"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ // Make sure that storage process is launched.
+ EXPECT_NE(0, webView.get().configuration.processPool._storageProcessIdentifier);
+
+ // Make sure that loading the simple page did not start the service worker process.
+ EXPECT_EQ(1u, webView.get().configuration.processPool._webProcessCount);
+
+ [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
#endif // WK_HAVE_C_SPI
#endif // WK_API_ENABLED