Remove mayHaveServiceWorkerRegisteredForOrigin
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Oct 2019 17:09:59 +0000 (17:09 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Oct 2019 17:09:59 +0000 (17:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203055

Patch by youenn fablet <youenn@apple.com> on 2019-10-22
Reviewed by Alex Christensen.

Source/WebCore:

Remove ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin and existingServiceWorkerConnection since they are no longer useful.
Creation of a service worker connection no longer requires any additional IPC once network connection is created.
Covered by existing tests.

* dom/Document.cpp:
(WebCore::Document::resume):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::matchRegistration):
(WebCore::DocumentLoader::commitData):
* testing/Internals.cpp:
(WebCore::Internals::terminateServiceWorker):
* testing/Internals.h:
* testing/Internals.idl:
* workers/service/SWClientConnection.h:
* workers/service/ServiceWorkerProvider.cpp:
* workers/service/ServiceWorkerProvider.h:
* workers/service/WorkerSWClientConnection.cpp:
* workers/service/WorkerSWClientConnection.h:

Source/WebKit:

This optimization was used for ensuring we would not create a storage process when no service worker registration is stored on disk.
Now that we do not have a storage process and we are doing registration matching direclty in network process, we can safely remove that optimization.
We also move the throttle state handling in WK2 layer. This allows us to not create a network process connection to update throttle state until
there is a network process connection. This allows continuing passing an API test checking network process connections after crashes.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
(WebKit::WebProcessPool::updateServiceWorkerUserAgent):
* UIProcess/WebProcessPool.h:
* WebProcess/Network/NetworkProcessConnection.h:
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebServiceWorkerProvider.cpp:
(WebKit::WebServiceWorkerProvider::serviceWorkerConnection):
(WebKit::WebServiceWorkerProvider::updateThrottleState):
* WebProcess/Storage/WebServiceWorkerProvider.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_textAutoSizingAdjustmentTimer):
(WebKit::WebPage::updateThrottleState):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
Remove obsolete test.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251439 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/workers/service/SWClientConnection.h
Source/WebCore/workers/service/ServiceWorkerProvider.cpp
Source/WebCore/workers/service/ServiceWorkerProvider.h
Source/WebCore/workers/service/WorkerSWClientConnection.cpp
Source/WebCore/workers/service/WorkerSWClientConnection.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/WebProcess/Network/NetworkProcessConnection.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp
Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm

index a1f354a..6ed0867 100644 (file)
@@ -1,3 +1,29 @@
+2019-10-22  youenn fablet  <youenn@apple.com>
+
+        Remove mayHaveServiceWorkerRegisteredForOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=203055
+
+        Reviewed by Alex Christensen.
+
+        Remove ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin and existingServiceWorkerConnection since they are no longer useful.
+        Creation of a service worker connection no longer requires any additional IPC once network connection is created.
+        Covered by existing tests.
+
+        * dom/Document.cpp:
+        (WebCore::Document::resume):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::matchRegistration):
+        (WebCore::DocumentLoader::commitData):
+        * testing/Internals.cpp:
+        (WebCore::Internals::terminateServiceWorker):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        * workers/service/SWClientConnection.h:
+        * workers/service/ServiceWorkerProvider.cpp:
+        * workers/service/ServiceWorkerProvider.h:
+        * workers/service/WorkerSWClientConnection.cpp:
+        * workers/service/WorkerSWClientConnection.h:
+
 2019-10-21  Simon Fraser  <simon.fraser@apple.com>
 
         wpt/css/css-images/gradient/color-stops-parsing.html crashes
index d4b79b2..0ea1d86 100644 (file)
@@ -5237,7 +5237,7 @@ void Document::resume(ReasonForSuspension reason)
 
 #if ENABLE(SERVICE_WORKER)
     if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && reason == ReasonForSuspension::BackForwardCache)
-        setServiceWorkerConnection(ServiceWorkerProvider::singleton().existingServiceWorkerConnection());
+        setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnection());
 #endif
 }
 
index ec1858d..4c17b0b 100644 (file)
@@ -505,8 +505,7 @@ void DocumentLoader::matchRegistration(const URL& url, SWClientConnection::Regis
     }
 
     auto origin = (!m_frame->isMainFrame() && m_frame->document()) ? m_frame->document()->topOrigin().data() : SecurityOriginData::fromURL(url);
-    auto& provider = ServiceWorkerProvider::singleton();
-    if (!provider.mayHaveServiceWorkerRegisteredForOrigin(origin)) {
+    if (!ServiceWorkerProvider::singleton().serviceWorkerConnection().mayHaveServiceWorkerRegisteredForOrigin(origin)) {
         callback(WTF::nullopt);
         return;
     }
@@ -1061,7 +1060,7 @@ void DocumentLoader::commitData(const char* bytes, size_t length)
             }
 
             if (m_frame->document()->activeServiceWorker() || LegacySchemeRegistry::canServiceWorkersHandleURLScheme(m_frame->document()->url().protocol().toStringWithoutCopying()))
-                m_frame->document()->setServiceWorkerConnection(ServiceWorkerProvider::singleton().existingServiceWorkerConnection());
+                m_frame->document()->setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnection());
 
             // We currently unregister the temporary service worker client since we now registered the real document.
             // FIXME: We should make the real document use the temporary client identifier.
index 42b567a..e9a5a09 100644 (file)
@@ -5026,14 +5026,6 @@ void Internals::terminateServiceWorker(ServiceWorker& worker)
 
     ServiceWorkerProvider::singleton().serviceWorkerConnection().syncTerminateWorker(worker.identifier());
 }
-
-bool Internals::hasServiceWorkerConnection()
-{
-    if (!contextDocument())
-        return false;
-
-    return ServiceWorkerProvider::singleton().existingServiceWorkerConnection();
-}
 #endif
 
 #if ENABLE(APPLE_PAY)
index 58d8c8c..fd378e6 100644 (file)
@@ -765,7 +765,6 @@ public:
     using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>;
     void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&);
     void terminateServiceWorker(ServiceWorker&);
-    bool hasServiceWorkerConnection();
 #endif
 
 #if ENABLE(APPLE_PAY)
index f421a65..b23f70c 100644 (file)
@@ -756,7 +756,6 @@ enum CompositingPolicy {
 
     [Conditional=SERVICE_WORKER] Promise<boolean> hasServiceWorkerRegistration(DOMString scopeURL);
     [Conditional=SERVICE_WORKER] void terminateServiceWorker(ServiceWorker worker);
-    [Conditional=SERVICE_WORKER] boolean hasServiceWorkerConnection();
 
     [CallWith=Document, Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator;
 
index 4f6f7ad..1e072da 100644 (file)
@@ -85,9 +85,6 @@ public:
 
     virtual void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) = 0;
 
-    virtual bool isThrottleable() const = 0;
-    virtual void updateThrottleState() = 0;
-
     virtual void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&& callback) { callback(); }
 
 protected:
index 443a92c..a753ce5 100644 (file)
@@ -54,15 +54,6 @@ void ServiceWorkerProvider::setSharedProvider(ServiceWorkerProvider& newProvider
     sharedProvider = &newProvider;
 }
 
-bool ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin(const SecurityOriginData& origin)
-{
-    auto* connection = existingServiceWorkerConnection();
-    if (!connection)
-        return m_mayHaveRegisteredServiceWorkers;
-
-    return connection->mayHaveServiceWorkerRegisteredForOrigin(origin);
-}
-
 void ServiceWorkerProvider::registerServiceWorkerClients()
 {
     setMayHaveRegisteredServiceWorkers();
index d6d5bcf..dee260d 100644 (file)
@@ -40,8 +40,6 @@ public:
     static ServiceWorkerProvider& singleton();
     static void setSharedProvider(ServiceWorkerProvider&);
 
-    bool mayHaveServiceWorkerRegisteredForOrigin(const SecurityOriginData&);
-    virtual SWClientConnection* existingServiceWorkerConnection() = 0;
     virtual SWClientConnection& serviceWorkerConnection() = 0;
 
     void registerServiceWorkerClients();
index 4619d62..4ae81e3 100644 (file)
@@ -184,15 +184,6 @@ void WorkerSWClientConnection::finishFetchingScriptInServer(const ServiceWorkerF
     });
 }
 
-bool WorkerSWClientConnection::isThrottleable() const
-{
-    return true;
-}
-
-void WorkerSWClientConnection::updateThrottleState()
-{
-}
-
 void WorkerSWClientConnection::scheduleJob(DocumentOrWorkerIdentifier identifier, const ServiceWorkerJobData& data)
 {
     callOnMainThread([identifier, data = crossThreadCopy(data)]() mutable {
index 9edfb69..d09b160 100644 (file)
@@ -55,8 +55,6 @@ private:
     void registerServiceWorkerClient(const SecurityOrigin& topOrigin, const ServiceWorkerClientData&, const Optional<ServiceWorkerRegistrationIdentifier>&, const String& userAgent) final;
     void unregisterServiceWorkerClient(DocumentIdentifier) final;
     void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) final;
-    bool isThrottleable() const final;
-    void updateThrottleState() final;
     void scheduleJobInServer(const ServiceWorkerJobData&) final;
     void scheduleJob(DocumentOrWorkerIdentifier, const ServiceWorkerJobData&) final;
 
index eb90436..3d6fb9b 100644 (file)
@@ -1,3 +1,35 @@
+2019-10-22  youenn fablet  <youenn@apple.com>
+
+        Remove mayHaveServiceWorkerRegisteredForOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=203055
+
+        Reviewed by Alex Christensen.
+
+        This optimization was used for ensuring we would not create a storage process when no service worker registration is stored on disk.
+        Now that we do not have a storage process and we are doing registration matching direclty in network process, we can safely remove that optimization.
+        We also move the throttle state handling in WK2 layer. This allows us to not create a network process connection to update throttle state until
+        there is a network process connection. This allows continuing passing an API test checking network process connections after crashes.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
+        (WebKit::WebProcessPool::updateServiceWorkerUserAgent):
+        * UIProcess/WebProcessPool.h:
+        * WebProcess/Network/NetworkProcessConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebServiceWorkerProvider.cpp:
+        (WebKit::WebServiceWorkerProvider::serviceWorkerConnection):
+        (WebKit::WebServiceWorkerProvider::updateThrottleState):
+        * WebProcess/Storage/WebServiceWorkerProvider.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_textAutoSizingAdjustmentTimer):
+        (WebKit::WebPage::updateThrottleState):
+
 2019-10-22  Yury Semikhatsky  <yurys@chromium.org>
 
         [GTK] Web Inspector: add an option for disabling minification and concatenation of inspector UI in release build
index d21b1e5..7f55a88 100644 (file)
@@ -117,9 +117,6 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
 #if ENABLE(APPLICATION_MANIFEST)
     encoder << applicationManifest;
 #endif
-#if ENABLE(SERVICE_WORKER)
-    encoder << hasRegisteredServiceWorkers;
-#endif
     encoder << needsFontAttributes;
     encoder << iceCandidateFilteringEnabled;
     encoder << enumeratingAllNetworkInterfacesEnabled;
@@ -343,11 +340,6 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod
         return WTF::nullopt;
     parameters.applicationManifest = WTFMove(*applicationManifest);
 #endif
-#if ENABLE(SERVICE_WORKER)
-    if (!decoder.decode(parameters.hasRegisteredServiceWorkers))
-        return WTF::nullopt;
-#endif
-
     if (!decoder.decode(parameters.needsFontAttributes))
         return WTF::nullopt;
 
index d5d3639..fbf5439 100644 (file)
@@ -182,10 +182,6 @@ struct WebPageCreationParameters {
     Optional<WebCore::ApplicationManifest> applicationManifest;
 #endif
 
-#if ENABLE(SERVICE_WORKER)
-    bool hasRegisteredServiceWorkers { true };
-#endif
-
     bool needsFontAttributes { false };
 
     // WebRTC members.
index eb90c5a..f9c7763 100644 (file)
@@ -7384,10 +7384,6 @@ WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& proc
     parameters.applicationManifest = m_configuration->applicationManifest() ? Optional<WebCore::ApplicationManifest>(m_configuration->applicationManifest()->applicationManifest()) : WTF::nullopt;
 #endif
 
-#if ENABLE(SERVICE_WORKER)
-    parameters.hasRegisteredServiceWorkers = process.processPool().mayHaveRegisteredServiceWorkers(process.websiteDataStore());
-#endif
-
     parameters.needsFontAttributes = m_needsFontAttributes;
     parameters.backgroundColor = m_backgroundColor;
 
index 13ba195..57d7c07 100644 (file)
@@ -691,8 +691,6 @@ void WebProcessPool::establishWorkerContextConnectionToNetworkProcess(NetworkPro
 {
     ASSERT_UNUSED(proxy, &proxy == m_networkProcess.get());
 
-    m_mayHaveRegisteredServiceWorkers.clear();
-
     auto* websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID);
 
     if (!websiteDataStore) {
@@ -1264,21 +1262,6 @@ void WebProcessPool::updateServiceWorkerUserAgent(const String& userAgent)
     for (auto* serviceWorkerProcess : m_serviceWorkerProcesses.values())
         serviceWorkerProcess->setServiceWorkerUserAgent(m_serviceWorkerUserAgent);
 }
-
-bool WebProcessPool::mayHaveRegisteredServiceWorkers(const WebsiteDataStore& store)
-{
-    if (!m_serviceWorkerProcesses.isEmpty())
-        return true;
-
-    String serviceWorkerRegistrationDirectory = store.resolvedServiceWorkerRegistrationDirectory();
-    if (serviceWorkerRegistrationDirectory.isEmpty())
-        serviceWorkerRegistrationDirectory = WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();
-
-    return m_mayHaveRegisteredServiceWorkers.ensure(serviceWorkerRegistrationDirectory, [&] {
-        // FIXME: Make this computation on a background thread.
-        return FileSystem::fileExists(WebCore::serviceWorkerRegistrationDatabaseFilename(serviceWorkerRegistrationDirectory));
-    }).iterator->value;
-}
 #endif
 
 void WebProcessPool::pageBeginUsingWebsiteDataStore(WebPageProxyIdentifier pageID, WebsiteDataStore& dataStore)
index 77d5ae5..c783044 100644 (file)
@@ -393,7 +393,6 @@ public:
     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)
@@ -612,7 +611,6 @@ private:
     bool m_allowsAnySSLCertificateForServiceWorker { false };
     String m_serviceWorkerUserAgent;
     Optional<WebPreferencesStore> m_serviceWorkerPreferences;
-    HashMap<String, bool> m_mayHaveRegisteredServiceWorkers;
 #endif
 
     Ref<WebPageGroup> m_defaultPageGroup;
index e67b229..2a496a9 100644 (file)
@@ -72,7 +72,6 @@ public:
 #endif
 
 #if ENABLE(SERVICE_WORKER)
-    WebSWClientConnection* existingServiceWorkerConnection() { return m_swConnection.get(); }
     WebSWClientConnection& serviceWorkerConnection();
 #endif
 
index 75a3dc6..439910f 100644 (file)
@@ -64,6 +64,9 @@ public:
 
     void syncTerminateWorker(WebCore::ServiceWorkerIdentifier) final;
 
+    bool isThrottleable() const { return m_isThrottleable; }
+    void updateThrottleState();
+
 private:
     WebSWClientConnection();
 
@@ -84,8 +87,6 @@ private:
     void getRegistrations(WebCore::SecurityOriginData&& topOrigin, const URL& clientURL, GetRegistrationsCallback&&) final;
 
     void didResolveRegistrationPromise(const WebCore::ServiceWorkerRegistrationKey&) final;
-    void updateThrottleState() final;
-    bool isThrottleable() const final { return m_isThrottleable; }
     void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&&) final;
 
     void scheduleStorageJob(const WebCore::ServiceWorkerJobData&);
index 7dcd18e..51e2a63 100644 (file)
@@ -55,15 +55,18 @@ WebServiceWorkerProvider::WebServiceWorkerProvider()
 
 WebCore::SWClientConnection& WebServiceWorkerProvider::serviceWorkerConnection()
 {
+    ASSERT(RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled());
     return WebProcess::singleton().ensureNetworkProcessConnection().serviceWorkerConnection();
 }
 
-WebCore::SWClientConnection* WebServiceWorkerProvider::existingServiceWorkerConnection()
+void WebServiceWorkerProvider::updateThrottleState(bool isThrottleable)
 {
     auto* networkProcessConnection = WebProcess::singleton().existingNetworkProcessConnection();
     if (!networkProcessConnection)
-        return nullptr;
-    return networkProcessConnection->existingServiceWorkerConnection();
+        return;
+    auto& connection = networkProcessConnection->serviceWorkerConnection();
+    if (isThrottleable != connection.isThrottleable())
+        connection.updateThrottleState();
 }
 
 } // namespace WebKit
index c00c047..6997959 100644 (file)
@@ -41,12 +41,12 @@ public:
     static WebServiceWorkerProvider& singleton();
 
     void didReceiveServiceWorkerClientRegistrationMatch(IPC::Connection&, IPC::Decoder&);
+    void updateThrottleState(bool isThrottleable);
 
 private:
     friend NeverDestroyed<WebServiceWorkerProvider>;
     WebServiceWorkerProvider();
 
-    WebCore::SWClientConnection* existingServiceWorkerConnection() final;
     WebCore::SWClientConnection& serviceWorkerConnection() final;
 }; // class WebServiceWorkerProvider
 
index 0f59f6b..6f5e73f 100644 (file)
 #include "WebProcessPoolMessages.h"
 #include "WebProcessProxyMessages.h"
 #include "WebProgressTrackerClient.h"
+#include "WebServiceWorkerProvider.h"
 #include "WebSocketProvider.h"
 #include "WebSpeechSynthesisClient.h"
 #include "WebStorageNamespaceProvider.h"
 #include <WebCore/SWClientConnection.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>
@@ -651,11 +651,6 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
     WebCore::setAdditionalSupportedImageTypes(parameters.additionalSupportedImageTypes);
 #endif
 
-#if ENABLE(SERVICE_WORKER)
-    if (parameters.hasRegisteredServiceWorkers)
-        ServiceWorkerProvider::singleton().setMayHaveRegisteredServiceWorkers();
-#endif
-
     m_needsFontAttributes = parameters.needsFontAttributes;
 
 #if ENABLE(WEB_RTC)
@@ -792,12 +787,11 @@ void WebPage::updateThrottleState()
         m_userActivity.start();
 
 #if ENABLE(SERVICE_WORKER)
-    RunLoop::main().dispatch([isThrottleable] {
-        if (auto* connection = ServiceWorkerProvider::singleton().existingServiceWorkerConnection()) {
-            if (isThrottleable != connection->isThrottleable())
-                connection->updateThrottleState();
-        }
-    });
+    if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) {
+        RunLoop::main().dispatch([isThrottleable] {
+            WebServiceWorkerProvider::singleton().updateThrottleState(isThrottleable);
+        });
+    }
 #endif
 }
 
index 9d67d76..fc6be38 100644 (file)
@@ -1,3 +1,13 @@
+2019-10-22  youenn fablet  <youenn@apple.com>
+
+        Remove mayHaveServiceWorkerRegisteredForOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=203055
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+        Remove obsolete test.
+
 2019-10-22  Antti Koivisto  <antti@apple.com>
 
         operator==(Vector, Vector) should work with different inline capacities
index dd8f0bb..2464c9f 100644 (file)
@@ -866,8 +866,7 @@ void setConfigurationInjectedBundlePath(WKWebViewConfiguration* configuration)
 
 static const char* regularPageWithConnectionBytes = R"SWRESOURCE(
 <script>
-var result = window.internals.hasServiceWorkerConnection() ? "PASS" : "FAIL";
-window.webkit.messageHandlers.regularPage.postMessage(result);
+window.webkit.messageHandlers.regularPage.postMessage("PASS");
 </script>
 )SWRESOURCE";
 
@@ -1052,84 +1051,6 @@ TEST(ServiceWorkers, ServiceWorkerProcessCreation)
     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"];
-
-    ServiceWorkerTCPServer server({
-        { "text/html", mainBytesWithScope },
-        { "application/javascript", scriptBytes },
-    }, {
-        { "text/html", regularPageWithConnectionBytes },
-    }, {
-        { "text/html", regularPageWithConnectionBytes }
-    });
-
-    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-
-    // Load a page that registers a service worker.
-    [webView loadRequest:server.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.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
-    [newConfiguration.get().websiteDataStore _setServiceWorkerRegistrationDirectory: @"~/nonexistingfolder"];
-
-    webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
-    [webView loadRequest:server.request()];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-
-    // 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(2u, webView.get().configuration.processPool._webProcessCountIgnoringPrewarmed);
-    [webView loadRequest:server.request()];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-
-    // Make sure that loading the simple page did not start the service worker process.
-    EXPECT_EQ(2u, webView.get().configuration.processPool._webProcessCountIgnoringPrewarmed);
-
-    [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
-        done = true;
-    }];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-}
-
 static const char* readCacheBytes = R"SWRESOURCE(
 <script>