Diff
Modified: branches/safari-608-branch/Source/WebCore/workers/service/server/SWServer.h (251802 => 251803)
--- branches/safari-608-branch/Source/WebCore/workers/service/server/SWServer.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebCore/workers/service/server/SWServer.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -143,7 +143,7 @@
void updateWorker(Connection&, const ServiceWorkerJobDataIdentifier&, SWServerRegistration&, const URL&, const String& script, const ContentSecurityPolicyResponseHeaders&, const String& referrerPolicy, WorkerType, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&);
void terminateWorker(SWServerWorker&);
- void syncTerminateWorker(SWServerWorker&);
+ WEBCORE_EXPORT void syncTerminateWorker(SWServerWorker&);
void fireInstallEvent(SWServerWorker&);
void fireActivateEvent(SWServerWorker&);
Modified: branches/safari-608-branch/Source/WebCore/workers/service/server/SWServerWorker.h (251802 => 251803)
--- branches/safari-608-branch/Source/WebCore/workers/service/server/SWServerWorker.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebCore/workers/service/server/SWServerWorker.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -112,6 +112,9 @@
WEBCORE_EXPORT SWServerToContextConnection* contextConnection();
String userAgent() const;
+ void setHasTimedOutAnyFetchTasks() { m_hasTimedOutAnyFetchTasks = true; }
+ bool hasTimedOutAnyFetchTasks() const { return m_hasTimedOutAnyFetchTasks; }
+
private:
SWServerWorker(SWServer&, SWServerRegistration&, const URL&, const String& script, const ContentSecurityPolicyResponseHeaders&, String&& referrerPolicy, WorkerType, ServiceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&);
@@ -130,6 +133,7 @@
bool m_isSkipWaitingFlagSet { false };
Vector<Function<void(bool)>> m_whenActivatedHandlers;
HashMap<URL, ServiceWorkerContextData::ImportedScript> m_scriptResourceMap;
+ bool m_hasTimedOutAnyFetchTasks { false };
};
} // namespace WebCore
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-10-30 21:29:02 UTC (rev 251803)
@@ -2740,4 +2740,17 @@
});
}
+const Seconds NetworkProcess::defaultServiceWorkerFetchTimeout = 70_s;
+void NetworkProcess::setServiceWorkerFetchTimeoutForTesting(Seconds timeout, CompletionHandler<void()>&& completionHandler)
+{
+ m_serviceWorkerFetchTimeout = timeout;
+ completionHandler();
+}
+
+void NetworkProcess::resetServiceWorkerFetchTimeoutForTesting(CompletionHandler<void()>&& completionHandler)
+{
+ m_serviceWorkerFetchTimeout = defaultServiceWorkerFetchTimeout;
+ completionHandler();
+}
+
} // namespace WebKit
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.h (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -345,6 +345,10 @@
void addKeptAliveLoad(Ref<NetworkResourceLoader>&&);
void removeKeptAliveLoad(NetworkResourceLoader&);
+ void setServiceWorkerFetchTimeoutForTesting(Seconds, CompletionHandler<void()>&&);
+ void resetServiceWorkerFetchTimeoutForTesting(CompletionHandler<void()>&&);
+ Seconds serviceWorkerFetchTimeout() const { return m_serviceWorkerFetchTimeout; }
+
private:
void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&);
std::unique_ptr<WebCore::NetworkStorageSession> platformCreateDefaultStorageSession() const;
@@ -567,6 +571,9 @@
uint32_t m_downloadMonitorSpeedMultiplier { 1 };
HashMap<IPC::Connection::UniqueID, PAL::SessionID> m_sessionByConnection;
+
+ static const Seconds defaultServiceWorkerFetchTimeout;
+ Seconds m_serviceWorkerFetchTimeout { defaultServiceWorkerFetchTimeout };
};
} // namespace WebKit
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2019-10-30 21:29:02 UTC (rev 251803)
@@ -172,4 +172,7 @@
SetAdClickAttributionConversionURLForTesting(PAL::SessionID sessionID, URL url) -> () Async
MarkAdClickAttributionsAsExpiredForTesting(PAL::SessionID sessionID) -> () Async
GetLocalStorageOriginDetails(PAL::SessionID sessionID) -> (Vector<WebKit::LocalStorageDatabaseTracker::OriginDetails> details) Async
+
+ SetServiceWorkerFetchTimeoutForTesting(Seconds seconds) -> () Synchronous
+ ResetServiceWorkerFetchTimeoutForTesting() -> () Synchronous
}
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp 2019-10-30 21:29:02 UTC (rev 251803)
@@ -34,6 +34,8 @@
#include "Logging.h"
#include "ServiceWorkerClientFetchMessages.h"
#include "WebCoreArgumentCoders.h"
+#include "WebSWServerConnection.h"
+#include "WebSWServerToContextConnection.h"
#define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(m_sessionID.isAlwaysOnLoggingAllowed(), ServiceWorker, "%p - ServiceWorkerFetchTask::" fmt, this, ##__VA_ARGS__)
#define RELEASE_LOG_ERROR_IF_ALLOWED(fmt, ...) RELEASE_LOG_ERROR_IF(m_sessionID.isAlwaysOnLoggingAllowed(), ServiceWorker, "%p - ServiceWorkerFetchTask::" fmt, this, ##__VA_ARGS__)
@@ -42,45 +44,84 @@
namespace WebKit {
+ServiceWorkerFetchTask::ServiceWorkerFetchTask(PAL::SessionID sessionID, WebSWServerConnection& connection, WebSWServerToContextConnection& contextConnection, FetchIdentifier fetchIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, Seconds timeout)
+ : m_sessionID(sessionID)
+ , m_connection(makeWeakPtr(connection))
+ , m_contextConnection(contextConnection)
+ , m_identifier { connection.identifier(), fetchIdentifier }
+ , m_serviceWorkerIdentifier(serviceWorkerIdentifier)
+ , m_timeout(timeout)
+ , m_timeoutTimer(*this, &ServiceWorkerFetchTask::timeoutTimerFired)
+{
+ m_timeoutTimer.startOneShot(m_timeout);
+}
+
void ServiceWorkerFetchTask::didReceiveRedirectResponse(const ResourceResponse& response)
{
RELEASE_LOG_IF_ALLOWED("didReceiveRedirectResponse: %s", m_identifier.fetchIdentifier.loggingString().utf8().data());
- m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveRedirectResponse { response }, m_identifier.fetchIdentifier);
+ m_wasHandled = true;
+ if (m_connection)
+ m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveRedirectResponse { response }, m_identifier.fetchIdentifier);
}
void ServiceWorkerFetchTask::didReceiveResponse(const ResourceResponse& response, bool needsContinueDidReceiveResponseMessage)
{
- m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveResponse { response, needsContinueDidReceiveResponseMessage }, m_identifier.fetchIdentifier);
+ RELEASE_LOG_IF_ALLOWED("didReceiveResponse: %s", m_identifier.fetchIdentifier.loggingString().utf8().data());
+ m_wasHandled = true;
+ if (m_connection)
+ m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveResponse { response, needsContinueDidReceiveResponseMessage }, m_identifier.fetchIdentifier);
}
void ServiceWorkerFetchTask::didReceiveData(const IPC::DataReference& data, int64_t encodedDataLength)
{
- m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveData { data, encodedDataLength }, m_identifier.fetchIdentifier);
+ if (m_connection)
+ m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveData { data, encodedDataLength }, m_identifier.fetchIdentifier);
}
void ServiceWorkerFetchTask::didReceiveFormData(const IPC::FormDataReference& formData)
{
- m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveFormData { formData }, m_identifier.fetchIdentifier);
+ if (m_connection)
+ m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveFormData { formData }, m_identifier.fetchIdentifier);
}
void ServiceWorkerFetchTask::didFinish()
{
RELEASE_LOG_IF_ALLOWED("didFinishFetch: fetchIdentifier: %s", m_identifier.fetchIdentifier.loggingString().utf8().data());
- m_connection->send(Messages::ServiceWorkerClientFetch::DidFinish { }, m_identifier.fetchIdentifier);
+ m_timeoutTimer.stop();
+ if (!m_didReachTerminalState && m_connection)
+ m_connection->send(Messages::ServiceWorkerClientFetch::DidFinish { }, m_identifier.fetchIdentifier);
+ m_didReachTerminalState = true;
}
void ServiceWorkerFetchTask::didFail(const ResourceError& error)
{
RELEASE_LOG_ERROR_IF_ALLOWED("didFailFetch: fetchIdentifier: %s", m_identifier.fetchIdentifier.loggingString().utf8().data());
- m_connection->send(Messages::ServiceWorkerClientFetch::DidFail { error }, m_identifier.fetchIdentifier);
+ m_timeoutTimer.stop();
+ if (!m_didReachTerminalState && m_connection)
+ m_connection->send(Messages::ServiceWorkerClientFetch::DidFail { error }, m_identifier.fetchIdentifier);
+ m_didReachTerminalState = true;
}
void ServiceWorkerFetchTask::didNotHandle()
{
RELEASE_LOG_IF_ALLOWED("didNotHandleFetch: fetchIdentifier: %s", m_identifier.fetchIdentifier.loggingString().utf8().data());
- m_connection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, m_identifier.fetchIdentifier);
+ m_timeoutTimer.stop();
+ if (!m_didReachTerminalState && m_connection)
+ m_connection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, m_identifier.fetchIdentifier);
+ m_didReachTerminalState = true;
}
+void ServiceWorkerFetchTask::timeoutTimerFired()
+{
+ RELEASE_LOG_IF_ALLOWED("timeoutTimerFired: fetchIdentifier: %s", m_identifier.fetchIdentifier.loggingString().utf8().data());
+ if (!m_wasHandled)
+ didNotHandle();
+ else
+ didFail({ errorDomainWebKitInternal, 0, { }, "Service Worker fetch timed out"_s });
+
+ m_contextConnection.fetchTaskTimedOut(*this);
+}
+
} // namespace WebKit
#endif // ENABLE(SERVICE_WORKER)
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -27,8 +27,10 @@
#if ENABLE(SERVICE_WORKER)
+#include "WebSWServerConnection.h"
#include <WebCore/FetchIdentifier.h>
#include <WebCore/ServiceWorkerTypes.h>
+#include <WebCore/Timer.h>
#include <pal/SessionID.h>
#include <wtf/RefCounted.h>
@@ -46,10 +48,16 @@
namespace WebKit {
+class WebSWServerToContextConnection;
+
class ServiceWorkerFetchTask : public RefCounted<ServiceWorkerFetchTask> {
public:
- static Ref<ServiceWorkerFetchTask> create(PAL::SessionID sessionID, Ref<IPC::Connection>&& connection, WebCore::SWServerConnectionIdentifier connectionIdentifier, WebCore::FetchIdentifier fetchIdentifier) { return adoptRef(*new ServiceWorkerFetchTask(sessionID, WTFMove(connection), connectionIdentifier, fetchIdentifier)); }
+ template<typename... Args> static Ref<ServiceWorkerFetchTask> create(Args&&... args)
+ {
+ return adoptRef(*new ServiceWorkerFetchTask(std::forward<Args>(args)...));
+ }
+ void didNotHandle();
void fail(const WebCore::ResourceError& error) { didFail(error); }
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
@@ -67,13 +75,13 @@
};
const Identifier& identifier() const { return m_identifier; }
+ const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier() const { return m_serviceWorkerIdentifier; }
+ bool wasHandled() const { return m_wasHandled; }
+ WebSWServerConnection* swServerConnection() { return m_connection.get(); }
+
private:
- ServiceWorkerFetchTask(PAL::SessionID sessionID, Ref<IPC::Connection>&& connection, WebCore::SWServerConnectionIdentifier connectionIdentifier, WebCore::FetchIdentifier fetchIdentifier)
- : m_sessionID(sessionID)
- , m_connection(WTFMove(connection))
- , m_identifier { connectionIdentifier, fetchIdentifier }
- { }
+ ServiceWorkerFetchTask(PAL::SessionID, WebSWServerConnection&, WebSWServerToContextConnection&, WebCore::FetchIdentifier, WebCore::ServiceWorkerIdentifier, Seconds timeout);
void didReceiveRedirectResponse(const WebCore::ResourceResponse&);
void didReceiveResponse(const WebCore::ResourceResponse&, bool needsContinueDidReceiveResponseMessage);
@@ -81,11 +89,17 @@
void didReceiveFormData(const IPC::FormDataReference&);
void didFinish();
void didFail(const WebCore::ResourceError&);
- void didNotHandle();
+ void timeoutTimerFired();
PAL::SessionID m_sessionID;
- Ref<IPC::Connection> m_connection;
+ WeakPtr<WebSWServerConnection> m_connection;
+ WebSWServerToContextConnection& m_contextConnection;
Identifier m_identifier;
+ WebCore::ServiceWorkerIdentifier m_serviceWorkerIdentifier;
+ Seconds m_timeout;
+ WebCore::Timer m_timeoutTimer;
+ bool m_wasHandled { false };
+ bool m_didReachTerminalState { false };
};
inline bool operator==(const ServiceWorkerFetchTask::Identifier& a, const ServiceWorkerFetchTask::Identifier& b)
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2019-10-30 21:29:02 UTC (rev 251803)
@@ -175,7 +175,7 @@
}
auto* worker = server().workerByID(serviceWorkerIdentifier);
- if (!worker) {
+ if (!worker || worker->hasTimedOutAnyFetchTasks()) {
m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, fetchIdentifier);
return;
}
@@ -189,7 +189,7 @@
if (contextConnection) {
SWSERVERCONNECTION_RELEASE_LOG_IF_ALLOWED("startFetch: Starting fetch %s via service worker %s", fetchIdentifier.loggingString().utf8().data(), serviceWorkerIdentifier.loggingString().utf8().data());
- static_cast<WebSWServerToContextConnection&>(*contextConnection).startFetch(m_sessionID, m_contentConnection.get(), this->identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options, formData, referrer);
+ static_cast<WebSWServerToContextConnection&>(*contextConnection).startFetch(m_sessionID, *this, fetchIdentifier, serviceWorkerIdentifier, request, options, formData, referrer);
} else {
SWSERVERCONNECTION_RELEASE_LOG_ERROR_IF_ALLOWED("startFetch: fetchIdentifier: %s DidNotHandle because failed to run service worker", fetchIdentifier.loggingString().utf8().data());
m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, fetchIdentifier);
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -29,11 +29,11 @@
#include "MessageReceiver.h"
#include "MessageSender.h"
-#include "ServiceWorkerFetchTask.h"
#include <WebCore/FetchIdentifier.h>
#include <WebCore/SWServer.h>
#include <pal/SessionID.h>
#include <wtf/HashMap.h>
+#include <wtf/WeakPtr.h>
namespace IPC {
class FormDataReference;
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp 2019-10-30 21:29:02 UTC (rev 251803)
@@ -34,6 +34,7 @@
#include "ServiceWorkerFetchTaskMessages.h"
#include "WebCoreArgumentCoders.h"
#include "WebSWContextManagerConnectionMessages.h"
+#include "WebSWServerConnection.h"
#include <WebCore/ServiceWorkerContextData.h>
namespace WebKit {
@@ -126,16 +127,18 @@
send(Messages::WebSWContextManagerConnection::TerminateProcess());
}
-void WebSWServerToContextConnection::startFetch(PAL::SessionID sessionID, Ref<IPC::Connection>&& contentConnection, WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, FetchIdentifier contentFetchIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options, const IPC::FormDataReference& data, const String& referrer)
+void WebSWServerToContextConnection::startFetch(PAL::SessionID sessionID, WebSWServerConnection& contentConnection, FetchIdentifier contentFetchIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options, const IPC::FormDataReference& data, const String& referrer)
{
+ auto serverConnectionIdentifier = contentConnection.identifier();
auto fetchIdentifier = FetchIdentifier::generate();
-
- m_ongoingFetches.add(fetchIdentifier, ServiceWorkerFetchTask::create(sessionID, WTFMove(contentConnection), serverConnectionIdentifier, contentFetchIdentifier));
- ASSERT(!m_ongoingFetchIdentifiers.contains({serverConnectionIdentifier, contentFetchIdentifier}));
- m_ongoingFetchIdentifiers.add({serverConnectionIdentifier, contentFetchIdentifier}, fetchIdentifier);
+ auto result = m_ongoingFetches.add(fetchIdentifier, ServiceWorkerFetchTask::create(sessionID, contentConnection, *this, contentFetchIdentifier, serviceWorkerIdentifier, m_networkProcess->serviceWorkerFetchTimeout()));
- send(Messages::WebSWContextManagerConnection::StartFetch { serverConnectionIdentifier, serviceWorkerIdentifier, fetchIdentifier, request, options, data, referrer });
+ ASSERT(!m_ongoingFetchIdentifiers.contains({ serverConnectionIdentifier, contentFetchIdentifier }));
+ m_ongoingFetchIdentifiers.add({ serverConnectionIdentifier, contentFetchIdentifier }, fetchIdentifier);
+
+ if (!send(Messages::WebSWContextManagerConnection::StartFetch { serverConnectionIdentifier, serviceWorkerIdentifier, fetchIdentifier, request, options, data, referrer }))
+ result.iterator->value->didNotHandle();
}
void WebSWServerToContextConnection::cancelFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, FetchIdentifier contentFetchIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier)
@@ -179,6 +182,44 @@
}
}
+void WebSWServerToContextConnection::fetchTaskTimedOut(ServiceWorkerFetchTask& task)
+{
+ ASSERT(m_ongoingFetchIdentifiers.contains(task.identifier()));
+ auto takenIdentifier = m_ongoingFetchIdentifiers.take(task.identifier());
+
+ ASSERT(m_ongoingFetches.contains(takenIdentifier));
+ auto takenTask = m_ongoingFetches.take(takenIdentifier);
+ ASSERT(takenTask);
+ ASSERT(takenTask->ptr() == &task);
+
+ // Gather all other fetches in this service worker
+ HashSet<Ref<ServiceWorkerFetchTask>> otherFetches;
+ for (auto& fetchTask : m_ongoingFetches.values()) {
+ if (fetchTask->serviceWorkerIdentifier() == task.serviceWorkerIdentifier())
+ otherFetches.add(fetchTask.copyRef());
+ }
+
+ // Signal load failure for them
+ for (auto& fetchTask : otherFetches) {
+ if (fetchTask->wasHandled())
+ fetchTask->fail({ errorDomainWebKitInternal, 0, { }, "Service Worker context closed"_s });
+ else
+ fetchTask->didNotHandle();
+
+ auto identifier = m_ongoingFetchIdentifiers.take(fetchTask->identifier());
+ m_ongoingFetches.remove(identifier);
+ }
+
+ if (auto* connection = task.swServerConnection()) {
+ auto& server = connection->server();
+ if (auto* worker = server.workerByID(task.serviceWorkerIdentifier())) {
+ worker->setHasTimedOutAnyFetchTasks();
+ if (worker->isRunning())
+ server.syncTerminateWorker(*worker);
+ }
+ }
+}
+
} // namespace WebKit
#endif // ENABLE(SERVICE_WORKER)
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -48,6 +48,7 @@
namespace WebKit {
class NetworkProcess;
+class WebSWServerConnection;
class WebSWServerToContextConnection : public WebCore::SWServerToContextConnection, public IPC::MessageSender, public IPC::MessageReceiver {
public:
@@ -65,7 +66,7 @@
void terminate();
- void startFetch(PAL::SessionID, Ref<IPC::Connection>&&, WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier, WebCore::ServiceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const IPC::FormDataReference&, const String&);
+ void startFetch(PAL::SessionID, WebSWServerConnection&, WebCore::FetchIdentifier, WebCore::ServiceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const IPC::FormDataReference&, const String&);
void cancelFetch(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier, WebCore::ServiceWorkerIdentifier);
void continueDidReceiveFetchResponse(WebCore::SWServerConnectionIdentifier, WebCore::FetchIdentifier, WebCore::ServiceWorkerIdentifier);
@@ -74,6 +75,8 @@
void setThrottleState(bool isThrottleable);
bool isThrottleable() const { return m_isThrottleable; }
+ void fetchTaskTimedOut(ServiceWorkerFetchTask&);
+
private:
WebSWServerToContextConnection(NetworkProcess&, const WebCore::RegistrableDomain&, Ref<IPC::Connection>&&);
~WebSWServerToContextConnection();
Modified: branches/safari-608-branch/Source/WebKit/UIProcess/API/C/WKContext.h (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/UIProcess/API/C/WKContext.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/API/C/WKContext.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -168,6 +168,9 @@
WK_EXPORT void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef contextRef, WKStringRef name);
+WK_EXPORT void WKContextSetServiceWorkerFetchTimeoutForTesting(WKContextRef contextRef, double seconds);
+WK_EXPORT void WKContextResetServiceWorkerFetchTimeoutForTesting(WKContextRef contextRef);
+
#ifdef __cplusplus
}
#endif
Modified: branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-10-30 21:29:02 UTC (rev 251803)
@@ -1490,6 +1490,16 @@
completionHandler({ });
}
+void WebProcessPool::setServiceWorkerTimeoutForTesting(Seconds seconds)
+{
+ sendSyncToNetworkingProcess(Messages::NetworkProcess::SetServiceWorkerFetchTimeoutForTesting(seconds), Messages::NetworkProcess::SetServiceWorkerFetchTimeoutForTesting::Reply());
+}
+
+void WebProcessPool::resetServiceWorkerTimeoutForTesting()
+{
+ sendSyncToNetworkingProcess(Messages::NetworkProcess::ResetServiceWorkerFetchTimeoutForTesting(), Messages::NetworkProcess::ResetServiceWorkerFetchTimeoutForTesting::Reply());
+}
+
void WebProcessPool::setAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText)
{
m_alwaysUsesComplexTextCodePath = alwaysUseComplexText;
Modified: branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.h (251802 => 251803)
--- branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -260,6 +260,8 @@
ProcessID prewarmedProcessIdentifier();
void activePagesOriginsInWebProcessForTesting(ProcessID, CompletionHandler<void(Vector<String>&&)>&&);
bool networkProcessHasEntitlementForTesting(const String&);
+ void setServiceWorkerTimeoutForTesting(Seconds);
+ void resetServiceWorkerTimeoutForTesting();
WebPageGroup& defaultPageGroup() { return m_defaultPageGroup.get(); }
Modified: branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (251802 => 251803)
--- branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2019-10-30 21:29:02 UTC (rev 251803)
@@ -389,6 +389,8 @@
void sendDisplayConfigurationChangedMessageForTesting();
+ void setServiceWorkerFetchTimeout(double seconds);
+
// WebAuthn
void addTestKeyToKeychain(DOMString privateKeyBase64, DOMString attrLabel, DOMString applicationTagBase64);
void cleanUpKeychain(DOMString attrLabel);
Modified: branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (251802 => 251803)
--- branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2019-10-30 21:29:02 UTC (rev 251803)
@@ -2536,6 +2536,13 @@
WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), nullptr, nullptr);
}
+void TestRunner::setServiceWorkerFetchTimeout(double seconds)
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetServiceWorkerFetchTimeout"));
+ WKRetainPtr<WKDoubleRef> messageBody = adoptWK(WKDoubleCreate(seconds));
+ WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
// WebAuthn
void TestRunner::addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64)
{
Modified: branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (251802 => 251803)
--- branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -488,6 +488,8 @@
void sendDisplayConfigurationChangedMessageForTesting();
+ void setServiceWorkerFetchTimeout(double seconds);
+
// FIXME(189876)
void addTestKeyToKeychain(JSStringRef privateKeyBase64, JSStringRef attrLabel, JSStringRef applicationTagBase64);
void cleanUpKeychain(JSStringRef attrLabel);
Modified: branches/safari-608-branch/Tools/WebKitTestRunner/TestController.cpp (251802 => 251803)
--- branches/safari-608-branch/Tools/WebKitTestRunner/TestController.cpp 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/TestController.cpp 2019-10-30 21:29:02 UTC (rev 251803)
@@ -3608,6 +3608,11 @@
WKSendDisplayConfigurationChangedMessageForTesting(platformContext());
}
+void TestController::setServiceWorkerFetchTimeoutForTesting(double seconds)
+{
+ WKContextSetServiceWorkerFetchTimeoutForTesting(platformContext(), seconds);
+}
+
struct AdClickAttributionStringResultCallbackContext {
explicit AdClickAttributionStringResultCallbackContext(TestController& controller)
: testController(controller)
Modified: branches/safari-608-branch/Tools/WebKitTestRunner/TestController.h (251802 => 251803)
--- branches/safari-608-branch/Tools/WebKitTestRunner/TestController.h 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/TestController.h 2019-10-30 21:29:02 UTC (rev 251803)
@@ -288,6 +288,8 @@
void sendDisplayConfigurationChangedMessageForTesting();
+ void setServiceWorkerFetchTimeoutForTesting(double seconds);
+
void addTestKeyToKeychain(const String& privateKeyBase64, const String& attrLabel, const String& applicationTagBase64);
void cleanUpKeychain(const String& attrLabel);
bool keyExistsInKeychain(const String& attrLabel, const String& applicationTagBase64);
Modified: branches/safari-608-branch/Tools/WebKitTestRunner/TestInvocation.cpp (251802 => 251803)
--- branches/safari-608-branch/Tools/WebKitTestRunner/TestInvocation.cpp 2019-10-30 21:08:48 UTC (rev 251802)
+++ branches/safari-608-branch/Tools/WebKitTestRunner/TestInvocation.cpp 2019-10-30 21:29:02 UTC (rev 251803)
@@ -1552,6 +1552,13 @@
return nullptr;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "SetServiceWorkerFetchTimeout")) {
+ ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
+ WKDoubleRef seconds = static_cast<WKDoubleRef>(messageBody);
+ TestController::singleton().setServiceWorkerFetchTimeoutForTesting(WKDoubleGetValue(seconds));
+ return nullptr;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "TerminateNetworkProcess")) {
ASSERT(!messageBody);
TestController::singleton().terminateNetworkProcess();