Modified: branches/safari-605-branch/Source/WebKit/ChangeLog (228961 => 228962)
--- branches/safari-605-branch/Source/WebKit/ChangeLog 2018-02-23 21:39:02 UTC (rev 228961)
+++ branches/safari-605-branch/Source/WebKit/ChangeLog 2018-02-23 21:39:04 UTC (rev 228962)
@@ -1,5 +1,22 @@
2018-02-23 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r228930. rdar://problem/37836719
+
+ 2018-02-22 Youenn Fablet <you...@apple.com>
+
+ Fetch event release assert should take into account the fetch mode
+ https://bugs.webkit.org/show_bug.cgi?id=183047
+
+ Reviewed by Chris Dumez.
+
+ In case of navigation tasks, we should use the request URL and not the origin of the loading client.
+
+ * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+ (WebKit::isValidFetch):
+ (WebKit::WebSWContextManagerConnection::startFetch):
+
+2018-02-23 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r228919. rdar://problem/37836719
2018-02-22 Youenn Fablet <you...@apple.com>
Modified: branches/safari-605-branch/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (228961 => 228962)
--- branches/safari-605-branch/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2018-02-23 21:39:02 UTC (rev 228961)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp 2018-02-23 21:39:04 UTC (rev 228962)
@@ -174,6 +174,23 @@
m_connectionToStorageProcess->send(Messages::WebSWServerToContextConnection::ScriptContextFailedToStart(jobDataIdentifier, serviceWorkerIdentifier, exceptionMessage), 0);
}
+static inline bool isValidFetch(const ResourceRequest& request, const FetchOptions& options, const URL& serviceWorkerURL, const String& referrer)
+{
+ // For exotic service workers, do not enforce checks.
+ if (!serviceWorkerURL.protocolIsInHTTPFamily())
+ return true;
+
+ if (options.mode == FetchOptions::Mode::Navigate)
+ return protocolHostAndPortAreEqual(request.url(), serviceWorkerURL);
+
+ String origin = request.httpOrigin();
+ URL url { URL(), origin.isEmpty() ? referrer : origin };
+ if (!url.protocolIsInHTTPFamily())
+ return true;
+
+ return protocolHostAndPortAreEqual(url, serviceWorkerURL);
+}
+
void WebSWContextManagerConnection::startFetch(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, ResourceRequest&& request, FetchOptions&& options, IPC::FormDataReference&& formData, String&& referrer)
{
auto* serviceWorkerThreadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(serviceWorkerIdentifier);
@@ -182,10 +199,7 @@
return;
}
- String origin = request.httpOrigin();
- URL url { URL(), origin.isEmpty() ? referrer : origin };
- URL serviceWorkerURL = serviceWorkerThreadProxy->scriptURL();
- RELEASE_ASSERT(!url.protocolIsInHTTPFamily() || !serviceWorkerURL.protocolIsInHTTPFamily() || protocolHostAndPortAreEqual(url, serviceWorkerURL));
+ RELEASE_ASSERT(isValidFetch(request, options, serviceWorkerThreadProxy->scriptURL(), referrer));
auto client = WebServiceWorkerFetchTaskClient::create(m_connectionToStorageProcess.copyRef(), serviceWorkerIdentifier, serverConnectionIdentifier, fetchIdentifier);
std::optional<ServiceWorkerClientIdentifier> clientId;