WebKit Bugzilla
Attachment 368329 Details for
Bug 196807
: Use normal loading path for ping loads
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-196807-20190426101605.patch (text/plain), 62.33 KB, created by
youenn fablet
on 2019-04-26 10:16:06 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-04-26 10:16:06 PDT
Size:
62.33 KB
patch
obsolete
>Subversion Revision: 244694 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 0f0c8d084e93e5ce038ec05f49bb78a8e4fb204a..802f7d17faedc6b0f2c5e4ffd8cdfb3fca0de08f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,58 @@ >+2019-04-26 Youenn Fablet <youenn@apple.com> >+ >+ Use normal loading path for ping loads >+ https://bugs.webkit.org/show_bug.cgi?id=196807 >+ >+ Reviewed by Alex Christensen. >+ >+ Make use of regular code path for ping loads and beacon. >+ This is done conditionally on KeepAlive flag. >+ The benefits are a single loading code path and service worker interception. >+ >+ For that purpose, introduce a LoaderStrategy switch based on KeepAlive runtime flag. >+ This switch is used to use ping loads when keepAlive is set or regular loads. >+ In case of regular loads, the keepAlive flag should be used to extend the lifetime of the load. >+ >+ Migrate ping loads to use CachedResourceLoader instead of PingLoad. >+ For that purpose, introduce a new Ping CachedResource type. >+ >+ Covered by existing tests. >+ >+ * Modules/beacon/NavigatorBeacon.cpp: >+ (WebCore::NavigatorBeacon::sendBeacon): >+ * inspector/agents/InspectorPageAgent.cpp: >+ (WebCore::InspectorPageAgent::inspectorResourceType): >+ * loader/LinkLoader.cpp: >+ (WebCore::createLinkPreloadResourceClient): >+ * loader/LoaderStrategy.h: >+ * loader/PingLoader.cpp: >+ (WebCore::PingLoader::loadImage): >+ (WebCore::PingLoader::sendPing): >+ (WebCore::PingLoader::sendViolationReport): >+ (WebCore::PingLoader::startPingLoad): >+ * loader/PingLoader.h: >+ * loader/ResourceLoadInfo.cpp: >+ (WebCore::toResourceType): >+ * loader/SubresourceLoader.cpp: >+ (WebCore::logResourceLoaded): >+ * loader/cache/CachedResource.cpp: >+ (WebCore::CachedResource::defaultPriorityForResourceType): >+ (WebCore::CachedResource::load): >+ (WebCore::CachedResource::cancelLoad): >+ * loader/cache/CachedResource.h: >+ (WebCore::CachedResource::shouldUsePingLoad): >+ (WebCore::CachedResource::isMainOrMediaOrIconOrRawResource const): >+ * loader/cache/CachedResourceLoader.cpp: >+ (WebCore::createResource): >+ (WebCore::CachedResourceLoader::requestPingResource): >+ (WebCore::contentTypeFromResourceType): >+ (WebCore::CachedResourceLoader::checkInsecureContent const): >+ (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const): >+ (WebCore::CachedResourceLoader::canRequest): >+ (WebCore::isResourceSuitableForDirectReuse): >+ (WebCore::destinationForType): >+ * loader/cache/CachedResourceLoader.h: >+ > 2019-04-26 Youenn Fablet <youenn@apple.com> > > Remove no longer needed mDNS ICE candidate resolution code >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index fbc00016f104ca3016b1104d38a435cc0f84e65c..69c97a99b8938d9c134f227a01e161929e7215f1 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,40 @@ >+2019-04-26 Youenn Fablet <youenn@apple.com> >+ >+ Use normal loading path for ping loads >+ https://bugs.webkit.org/show_bug.cgi?id=196807 >+ >+ Reviewed by Alex Christensen. >+ >+ In case a NetworkResourceLoader has the keepAlive option we do the following: >+ - Always use NetworkLoadChecker as we might need it to do checks after the Web context is gone. >+ - In case of aborting a KeepAlive loader, remove it from NetworkConnectionToWebProcess map >+ and add it to a kept-alive NetworkSession load set. The loader is only kept alive if it >+ has not yet received a response. Mark the loader as kept-alive. >+ - In case loader is kept-alive, cancel the load as soon as a response is gathered. >+ >+ * NetworkProcess/NetworkConnectionToWebProcess.cpp: >+ (WebKit::NetworkConnectionToWebProcess::transferKeptAliveLoad): >+ * NetworkProcess/NetworkConnectionToWebProcess.h: >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::addKeptAliveLoad): >+ (WebKit::NetworkProcess::removeKeptAliveLoad): >+ * NetworkProcess/NetworkProcess.h: >+ * NetworkProcess/NetworkResourceLoadMap.cpp: >+ (WebKit::NetworkResourceLoadMap::remove): >+ (WebKit::NetworkResourceLoadMap::take): >+ * NetworkProcess/NetworkResourceLoadMap.h: >+ * NetworkProcess/NetworkResourceLoader.cpp: >+ (WebKit::m_shouldCaptureExtraNetworkLoadMetrics): >+ (WebKit::NetworkResourceLoader::cleanup): >+ (WebKit::NetworkResourceLoader::abort): >+ (WebKit::NetworkResourceLoader::didReceiveResponse): >+ (WebKit::NetworkResourceLoader::continueWillSendRedirectedRequest): >+ * NetworkProcess/NetworkResourceLoader.h: >+ * WebProcess/Network/WebLoaderStrategy.cpp: >+ (WebKit::maximumBufferingTime): >+ (WebKit::WebLoaderStrategy::usePingLoad const): >+ * WebProcess/Network/WebLoaderStrategy.h: >+ > 2019-04-26 Alex Christensen <achristensen@webkit.org> > > Fix an internal High Sierra build after r244653 >diff --git a/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp b/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >index cf1e3fc00546c41bbdd71a45a9d3fb95fcd32b1b..007f721a062f33acfa6c37b9a666afbbb63c7c1b 100644 >--- a/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >+++ b/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >@@ -122,10 +122,12 @@ ExceptionOr<bool> NavigatorBeacon::sendBeacon(Document& document, const String& > ResourceRequest request(parsedUrl); > request.setHTTPMethod("POST"_s); > >- FetchOptions options; >+ ResourceLoaderOptions options; > options.credentials = FetchOptions::Credentials::Include; > options.cache = FetchOptions::Cache::NoCache; > options.keepAlive = true; >+ options.sendLoadCallbacks = SendCallbackPolicy::SendCallbacks; >+ > if (body) { > options.mode = FetchOptions::Mode::Cors; > String mimeType; >diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >index dbdfa366ff8ae37d38ebc926b40c4cddb74fa1c7..f44f0feb21968ff9c3c3471669a83a3be790a618 100644 >--- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >@@ -280,6 +280,8 @@ InspectorPageAgent::ResourceType InspectorPageAgent::inspectorResourceType(Cache > case CachedResource::Type::ApplicationManifest: > return InspectorPageAgent::ApplicationManifestResource; > #endif >+ case CachedResource::Type::Ping: >+ return InspectorPageAgent::PingResource; > case CachedResource::Type::MediaResource: > case CachedResource::Type::Icon: > case CachedResource::Type::RawResource: >diff --git a/Source/WebCore/loader/LinkLoader.cpp b/Source/WebCore/loader/LinkLoader.cpp >index 9f55ae8a325b7e3ff315a4616a5415e91b716477..91861e1397eaafe9b2daf0f96d3adb5ca9050ba1 100644 >--- a/Source/WebCore/loader/LinkLoader.cpp >+++ b/Source/WebCore/loader/LinkLoader.cpp >@@ -163,6 +163,7 @@ static std::unique_ptr<LinkPreloadResourceClient> createLinkPreloadResourceClien > case CachedResource::Type::XSLStyleSheet: > #endif > case CachedResource::Type::Beacon: >+ case CachedResource::Type::Ping: > case CachedResource::Type::LinkPrefetch: > #if ENABLE(APPLICATION_MANIFEST) > case CachedResource::Type::ApplicationManifest: >diff --git a/Source/WebCore/loader/LoaderStrategy.h b/Source/WebCore/loader/LoaderStrategy.h >index b35c6fb0e2864d5f8efc4b80fac7a3ff0411193e..8a82381f018165e653e3c4b254e5697b63c09f70 100644 >--- a/Source/WebCore/loader/LoaderStrategy.h >+++ b/Source/WebCore/loader/LoaderStrategy.h >@@ -67,6 +67,7 @@ public: > virtual void suspendPendingRequests() = 0; > virtual void resumePendingRequests() = 0; > >+ virtual bool usePingLoad() const { return true; } > using PingLoadCompletionHandler = WTF::Function<void(const ResourceError&, const ResourceResponse&)>; > virtual void startPingLoad(Frame&, ResourceRequest&, const HTTPHeaderMap& originalRequestHeaders, const FetchOptions&, ContentSecurityPolicyImposition, PingLoadCompletionHandler&& = { }) = 0; > >diff --git a/Source/WebCore/loader/PingLoader.cpp b/Source/WebCore/loader/PingLoader.cpp >index 54c18a710a5a6c374fa75bb241f5b43d314d8780..426b2cb6ef5e9ce54767b201c89e9d3e02cc89c5 100644 >--- a/Source/WebCore/loader/PingLoader.cpp >+++ b/Source/WebCore/loader/PingLoader.cpp >@@ -34,6 +34,8 @@ > #include "config.h" > #include "PingLoader.h" > >+#include "CachedResourceLoader.h" >+#include "CachedResourceRequest.h" > #include "ContentRuleListResults.h" > #include "ContentSecurityPolicy.h" > #include "Document.h" >@@ -109,7 +111,7 @@ void PingLoader::loadImage(Frame& frame, const URL& url) > request.setHTTPReferrer(referrer); > frame.loader().addExtraFieldsToSubresourceRequest(request); > >- startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::Yes, ContentSecurityPolicyImposition::DoPolicyCheck); >+ startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::Yes, ContentSecurityPolicyImposition::DoPolicyCheck, ReferrerPolicy::EmptyString); > } > > // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing >@@ -148,7 +150,7 @@ void PingLoader::sendPing(Frame& frame, const URL& pingURL, const URL& destinati > } > } > >- startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::Yes, ContentSecurityPolicyImposition::DoPolicyCheck); >+ startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::Yes, ContentSecurityPolicyImposition::DoPolicyCheck, request.httpReferrer().isEmpty() ? ReferrerPolicy::NoReferrer : ReferrerPolicy::UnsafeUrl); > } > > void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, Ref<FormData>&& report, ViolationReportType reportType) >@@ -187,10 +189,10 @@ void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, Ref<For > if (!referrer.isEmpty()) > request.setHTTPReferrer(referrer); > >- startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::No, ContentSecurityPolicyImposition::SkipPolicyCheck); >+ startPingLoad(frame, request, WTFMove(originalRequestHeader), ShouldFollowRedirects::No, ContentSecurityPolicyImposition::SkipPolicyCheck, ReferrerPolicy::EmptyString); > } > >-void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request, HTTPHeaderMap&& originalRequestHeaders, ShouldFollowRedirects shouldFollowRedirects, ContentSecurityPolicyImposition policyCheck) >+void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request, HTTPHeaderMap&& originalRequestHeaders, ShouldFollowRedirects shouldFollowRedirects, ContentSecurityPolicyImposition policyCheck, ReferrerPolicy referrerPolicy) > { > unsigned long identifier = frame.page()->progress().createUniqueIdentifier(); > // FIXME: Why activeDocumentLoader? I would have expected documentLoader(). >@@ -199,22 +201,33 @@ void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request, HTTPHeade > // with the provisional DocumentLoader if there is a provisional > // DocumentLoader. > bool shouldUseCredentialStorage = frame.loader().client().shouldUseCredentialStorage(frame.loader().activeDocumentLoader(), identifier); >- FetchOptions options; >+ ResourceLoaderOptions options; > options.credentials = shouldUseCredentialStorage ? FetchOptions::Credentials::Include : FetchOptions::Credentials::Omit; > options.redirect = shouldFollowRedirects == ShouldFollowRedirects::Yes ? FetchOptions::Redirect::Follow : FetchOptions::Redirect::Error; >+ options.keepAlive = true; >+ options.contentSecurityPolicyImposition = policyCheck; >+ options.referrerPolicy = referrerPolicy; >+ options.sendLoadCallbacks = SendCallbackPolicy::SendCallbacks; >+ options.cache = FetchOptions::Cache::NoCache; >+ >+ // FIXME: Deprecate the ping load code path. >+ if (platformStrategies()->loaderStrategy()->usePingLoad()) { >+ InspectorInstrumentation::willSendRequestOfType(&frame, identifier, frame.loader().activeDocumentLoader(), request, InspectorInstrumentation::LoadType::Ping); >+ >+ platformStrategies()->loaderStrategy()->startPingLoad(frame, request, WTFMove(originalRequestHeaders), options, policyCheck, [protectedFrame = makeRef(frame), identifier] (const ResourceError& error, const ResourceResponse& response) { >+ if (!response.isNull()) >+ InspectorInstrumentation::didReceiveResourceResponse(protectedFrame, identifier, protectedFrame->loader().activeDocumentLoader(), response, nullptr); >+ if (!error.isNull()) { >+ InspectorInstrumentation::didFailLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, error); >+ return; >+ } >+ InspectorInstrumentation::didFinishLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, { }, nullptr); >+ }); >+ return; >+ } > >- // FIXME: Move ping loads to normal subresource loading to get normal inspector request instrumentation hooks. >- InspectorInstrumentation::willSendRequestOfType(&frame, identifier, frame.loader().activeDocumentLoader(), request, InspectorInstrumentation::LoadType::Ping); >- >- platformStrategies()->loaderStrategy()->startPingLoad(frame, request, WTFMove(originalRequestHeaders), options, policyCheck, [protectedFrame = makeRef(frame), identifier] (const ResourceError& error, const ResourceResponse& response) { >- if (!response.isNull()) >- InspectorInstrumentation::didReceiveResourceResponse(protectedFrame, identifier, protectedFrame->loader().activeDocumentLoader(), response, nullptr); >- if (error.isNull()) { >- NetworkLoadMetrics emptyMetrics; >- InspectorInstrumentation::didFinishLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, emptyMetrics, nullptr); >- } else >- InspectorInstrumentation::didFailLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, error); >- }); >+ CachedResourceRequest cachedResourceRequest { ResourceRequest { request }, options }; >+ frame.document()->cachedResourceLoader().requestPingResource(WTFMove(cachedResourceRequest)); > } > > } >diff --git a/Source/WebCore/loader/PingLoader.h b/Source/WebCore/loader/PingLoader.h >index 8d82d71bf8db905c1241eb253da9bfb6cd06a19b..5b4d6f2ec5b1b7b481075a13c8b00845a525d2e4 100644 >--- a/Source/WebCore/loader/PingLoader.h >+++ b/Source/WebCore/loader/PingLoader.h >@@ -32,6 +32,7 @@ > > #pragma once > >+#include "ReferrerPolicy.h" > #include <wtf/Forward.h> > #include <wtf/Ref.h> > >@@ -57,7 +58,7 @@ public: > > private: > enum class ShouldFollowRedirects { No, Yes }; >- static void startPingLoad(Frame&, ResourceRequest&, HTTPHeaderMap&& originalRequestHeaders, ShouldFollowRedirects, ContentSecurityPolicyImposition); >+ static void startPingLoad(Frame&, ResourceRequest&, HTTPHeaderMap&& originalRequestHeaders, ShouldFollowRedirects, ContentSecurityPolicyImposition, ReferrerPolicy); > }; > > } // namespace WebCore >diff --git a/Source/WebCore/loader/ResourceLoadInfo.cpp b/Source/WebCore/loader/ResourceLoadInfo.cpp >index 9d92dba8c0184cd85b6d214888f1234f13cf4586..902084bb4b29c8302892c2707122927ca462e62f 100644 >--- a/Source/WebCore/loader/ResourceLoadInfo.cpp >+++ b/Source/WebCore/loader/ResourceLoadInfo.cpp >@@ -59,6 +59,7 @@ ResourceType toResourceType(CachedResource::Type type) > return ResourceType::Media; > > case CachedResource::Type::Beacon: >+ case CachedResource::Type::Ping: > case CachedResource::Type::Icon: > case CachedResource::Type::RawResource: > return ResourceType::Raw; >diff --git a/Source/WebCore/loader/SubresourceLoader.cpp b/Source/WebCore/loader/SubresourceLoader.cpp >index 23de15449a05ec14932922ccbc37443d4703d98b..29c228637d810f398ad17116f3a3dc012daf6a0d 100644 >--- a/Source/WebCore/loader/SubresourceLoader.cpp >+++ b/Source/WebCore/loader/SubresourceLoader.cpp >@@ -518,8 +518,7 @@ static void logResourceLoaded(Frame* frame, CachedResource::Type type) > resourceType = DiagnosticLoggingKeys::fontKey(); > break; > case CachedResource::Type::Beacon: >- ASSERT_NOT_REACHED(); >- break; >+ case CachedResource::Type::Ping: > case CachedResource::Type::MediaResource: > case CachedResource::Type::Icon: > case CachedResource::Type::RawResource: >@@ -687,10 +686,9 @@ void SubresourceLoader::didFail(const ResourceError& error) > ASSERT(!reachedTerminalState()); > LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data()); > >- if (m_frame->document() && error.isAccessControl()) >+ if (m_frame->document() && error.isAccessControl() && m_resource->type() != CachedResource::Type::Ping) > m_frame->document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, error.localizedDescription()); > >- > Ref<SubresourceLoader> protectedThis(*this); > CachedResourceHandle<CachedResource> protectResource(m_resource); > m_state = Finishing; >diff --git a/Source/WebCore/loader/cache/CachedResource.cpp b/Source/WebCore/loader/cache/CachedResource.cpp >index d29e4ad1fae0b45faf3e98b2f1c9188d721f8767..e430e447ac494636c984e74d40b91e65cdebb50b 100644 >--- a/Source/WebCore/loader/cache/CachedResource.cpp >+++ b/Source/WebCore/loader/cache/CachedResource.cpp >@@ -89,6 +89,7 @@ ResourceLoadPriority CachedResource::defaultPriorityForResourceType(Type type) > case Type::SVGDocumentResource: > return ResourceLoadPriority::Low; > case Type::Beacon: >+ case Type::Ping: > return ResourceLoadPriority::VeryLow; > case Type::LinkPrefetch: > return ResourceLoadPriority::VeryLow; >@@ -271,36 +272,34 @@ void CachedResource::load(CachedResourceLoader& cachedResourceLoader) > m_fragmentIdentifierForRequest = String(); > } > >- if (m_options.keepAlive) { >- if (!cachedResourceLoader.keepaliveRequestTracker().tryRegisterRequest(*this)) { >- setResourceError({ errorDomainWebKitInternal, 0, request.url(), "Reached maximum amount of queued data of 64Kb for keepalive requests"_s, ResourceError::Type::AccessControl }); >- failBeforeStarting(); >- return; >- } >- // FIXME: We should not special-case Beacon here. >- if (shouldUsePingLoad(type())) { >- ASSERT(m_originalRequest); >- CachedResourceHandle<CachedResource> protectedThis(this); >- >- // FIXME: Move beacon loads to normal subresource loading to get normal inspector request instrumentation hooks. >- unsigned long identifier = frame.page()->progress().createUniqueIdentifier(); >- InspectorInstrumentation::willSendRequestOfType(&frame, identifier, frameLoader.activeDocumentLoader(), request, InspectorInstrumentation::LoadType::Beacon); >- >- platformStrategies()->loaderStrategy()->startPingLoad(frame, request, m_originalRequest->httpHeaderFields(), m_options, m_options.contentSecurityPolicyImposition, [this, protectedThis = WTFMove(protectedThis), protectedFrame = makeRef(frame), identifier] (const ResourceError& error, const ResourceResponse& response) { >- if (!response.isNull()) >- InspectorInstrumentation::didReceiveResourceResponse(protectedFrame, identifier, protectedFrame->loader().activeDocumentLoader(), response, nullptr); >- if (error.isNull()) { >- finishLoading(nullptr); >- NetworkLoadMetrics emptyMetrics; >- InspectorInstrumentation::didFinishLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, emptyMetrics, nullptr); >- } else { >- setResourceError(error); >- this->error(LoadError); >- InspectorInstrumentation::didFailLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, error); >- } >- }); >- return; >- } >+ if (m_options.keepAlive && type() != Type::Ping && !cachedResourceLoader.keepaliveRequestTracker().tryRegisterRequest(*this)) { >+ setResourceError({ errorDomainWebKitInternal, 0, request.url(), "Reached maximum amount of queued data of 64Kb for keepalive requests"_s, ResourceError::Type::AccessControl }); >+ failBeforeStarting(); >+ return; >+ } >+ >+ // FIXME: Deprecate that code path. >+ if (m_options.keepAlive && shouldUsePingLoad(type()) && platformStrategies()->loaderStrategy()->usePingLoad()) { >+ ASSERT(m_originalRequest); >+ CachedResourceHandle<CachedResource> protectedThis(this); >+ >+ unsigned long identifier = frame.page()->progress().createUniqueIdentifier(); >+ InspectorInstrumentation::willSendRequestOfType(&frame, identifier, frameLoader.activeDocumentLoader(), request, InspectorInstrumentation::LoadType::Beacon); >+ >+ platformStrategies()->loaderStrategy()->startPingLoad(frame, request, m_originalRequest->httpHeaderFields(), m_options, m_options.contentSecurityPolicyImposition, [this, protectedThis = WTFMove(protectedThis), protectedFrame = makeRef(frame), identifier] (const ResourceError& error, const ResourceResponse& response) { >+ if (!response.isNull()) >+ InspectorInstrumentation::didReceiveResourceResponse(protectedFrame, identifier, protectedFrame->loader().activeDocumentLoader(), response, nullptr); >+ if (!error.isNull()) { >+ setResourceError(error); >+ this->error(LoadError); >+ InspectorInstrumentation::didFailLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, error); >+ return; >+ } >+ finishLoading(nullptr); >+ NetworkLoadMetrics emptyMetrics; >+ InspectorInstrumentation::didFinishLoading(protectedFrame.ptr(), protectedFrame->loader().activeDocumentLoader(), identifier, emptyMetrics, nullptr); >+ }); >+ return; > } > > platformStrategies()->loaderStrategy()->loadResource(frame, *this, WTFMove(request), m_options, [this, protectedThis = CachedResourceHandle<CachedResource>(this), frame = makeRef(frame), loggingAllowed = cachedResourceLoader.isAlwaysOnLoggingAllowed()] (RefPtr<SubresourceLoader>&& loader) { >@@ -384,7 +383,12 @@ void CachedResource::cancelLoad() > if (!isLoading() && !stillNeedsLoad()) > return; > >- setStatus(LoadError); >+ auto* documentLoader = (m_loader && m_loader->frame()) ? m_loader->frame()->loader().activeDocumentLoader() : nullptr; >+ if (m_options.keepAlive && (!documentLoader || documentLoader->isStopping())) >+ m_error = { }; >+ else >+ setStatus(LoadError); >+ > setLoading(false); > checkNotify(); > } >diff --git a/Source/WebCore/loader/cache/CachedResource.h b/Source/WebCore/loader/cache/CachedResource.h >index aa8530d80e1ae2769afb93edfa64342e15ae8517..9bf51e0b22744aa62e775d9ee75537f31ba88204 100644 >--- a/Source/WebCore/loader/cache/CachedResource.h >+++ b/Source/WebCore/loader/cache/CachedResource.h >@@ -74,6 +74,7 @@ public: > RawResource, > Icon, > Beacon, >+ Ping, > SVGDocumentResource > #if ENABLE(XSLT) > , XSLStyleSheet >@@ -122,7 +123,7 @@ public: > String mimeType() const { return m_response.mimeType(); } > long long expectedContentLength() const { return m_response.expectedContentLength(); } > >- static bool shouldUsePingLoad(Type type) { return type == Type::Beacon; } >+ static bool shouldUsePingLoad(Type type) { return type == Type::Beacon || type == Type::Ping; } > > ResourceLoadPriority loadPriority() const { return m_loadPriority; } > void setLoadPriority(const Optional<ResourceLoadPriority>&); >@@ -168,7 +169,7 @@ public: > > bool isImage() const { return type() == Type::ImageResource; } > // FIXME: CachedRawResource could be a main resource, an audio/video resource, or a raw XHR/icon resource. >- bool isMainOrMediaOrIconOrRawResource() const { return type() == Type::MainResource || type() == Type::MediaResource || type() == Type::Icon || type() == Type::RawResource || type() == Type::Beacon; } >+ bool isMainOrMediaOrIconOrRawResource() const { return type() == Type::MainResource || type() == Type::MediaResource || type() == Type::Icon || type() == Type::RawResource || type() == Type::Beacon || type() == Type::Ping; } > > // Whether this request should impact request counting and delay window.onload. > bool ignoreForRequestCount() const >@@ -176,6 +177,8 @@ public: > return m_ignoreForRequestCount > || type() == Type::MainResource > || type() == Type::LinkPrefetch >+ || type() == Type::Beacon >+ || type() == Type::Ping > || type() == Type::Icon > || type() == Type::RawResource; > } >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >index b65cf173f54aef05a502086d039bd47fe1254a46..35ea881307bb58008fe1999ba689f8d8906508ca 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >@@ -120,6 +120,7 @@ static CachedResource* createResource(CachedResource::Type type, CachedResourceR > case CachedResource::Type::FontResource: > return new CachedFont(WTFMove(request), sessionID, cookieJar); > case CachedResource::Type::Beacon: >+ case CachedResource::Type::Ping: > case CachedResource::Type::MediaResource: > case CachedResource::Type::RawResource: > case CachedResource::Type::Icon: >@@ -308,6 +309,12 @@ ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::r > return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::Type::Beacon, WTFMove(request))); > } > >+ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestPingResource(CachedResourceRequest&& request) >+{ >+ ASSERT(request.options().destination == FetchOptions::Destination::EmptyString); >+ return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::Type::Ping, WTFMove(request))); >+} >+ > ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestMainResource(CachedResourceRequest&& request) > { > return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::Type::MainResource, WTFMove(request))); >@@ -341,6 +348,7 @@ static MixedContentChecker::ContentType contentTypeFromResourceType(CachedResour > #endif > > case CachedResource::Type::Beacon: >+ case CachedResource::Type::Ping: > case CachedResource::Type::RawResource: > case CachedResource::Type::Icon: > case CachedResource::Type::SVGDocumentResource: >@@ -412,6 +420,7 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const > } > case CachedResource::Type::MainResource: > case CachedResource::Type::Beacon: >+ case CachedResource::Type::Ping: > case CachedResource::Type::LinkPrefetch: > // Prefetch cannot affect the current document. > #if ENABLE(APPLICATION_MANIFEST) >@@ -463,6 +472,7 @@ bool CachedResourceLoader::allowedByContentSecurityPolicy(CachedResource::Type t > return false; > break; > case CachedResource::Type::Beacon: >+ case CachedResource::Type::Ping: > case CachedResource::Type::RawResource: > return true; > #if ENABLE(APPLICATION_MANIFEST) >@@ -501,7 +511,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, > return false; > } > >- if (options.mode == FetchOptions::Mode::NoCors && options.redirect != FetchOptions::Redirect::Follow) { >+ if (options.mode == FetchOptions::Mode::NoCors && options.redirect != FetchOptions::Redirect::Follow && type != CachedResource::Type::Ping) { > ASSERT(type != CachedResource::Type::MainResource); > frame()->document()->addConsoleMessage(MessageSource::Security, MessageLevel::Error, "No-Cors mode requires follow redirect mode"_s); > return false; >@@ -669,7 +679,7 @@ static inline bool isResourceSuitableForDirectReuse(const CachedResource& resour > if (resource.type() == CachedResource::Type::RawResource || resource.type() == CachedResource::Type::MediaResource) > return false; > >- if (resource.type() == CachedResource::Type::Beacon) >+ if (resource.type() == CachedResource::Type::Beacon || resource.type() == CachedResource::Type::Ping) > return false; > > return true; >@@ -762,6 +772,7 @@ static FetchOptions::Destination destinationForType(CachedResource::Type type) > return FetchOptions::Destination::Manifest; > #endif > case CachedResource::Type::Beacon: >+ case CachedResource::Type::Ping: > case CachedResource::Type::LinkPrefetch: > case CachedResource::Type::RawResource: > case CachedResource::Type::MediaResource: >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.h b/Source/WebCore/loader/cache/CachedResourceLoader.h >index 0f6d60012fda18e61914de744e8a866ec8d23026..4e9c1a050da4512ec7344cd6d3cd208270915322 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.h >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.h >@@ -87,6 +87,7 @@ public: > ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestMedia(CachedResourceRequest&&); > ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestIcon(CachedResourceRequest&&); > ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestBeaconResource(CachedResourceRequest&&); >+ ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestPingResource(CachedResourceRequest&&); > ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestMainResource(CachedResourceRequest&&); > ResourceErrorOr<CachedResourceHandle<CachedSVGDocument>> requestSVGDocument(CachedResourceRequest&&); > #if ENABLE(XSLT) >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >index cab434ebfdf1e4ed6db4f9f5033af392ee783a8b..dc74a613b9d9c4c489d671e30aa8a673460455fb 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >@@ -111,11 +111,25 @@ void NetworkConnectionToWebProcess::didCleanupResourceLoader(NetworkResourceLoad > { > RELEASE_ASSERT(loader.identifier()); > RELEASE_ASSERT(RunLoop::isMain()); >- ASSERT(m_networkResourceLoaders.get(loader.identifier()) == &loader); > >+ if (loader.isKeptAlive()) { >+ networkProcess().removeKeptAliveLoad(loader); >+ return; >+ } >+ >+ ASSERT(m_networkResourceLoaders.get(loader.identifier()) == &loader); > m_networkResourceLoaders.remove(loader.identifier()); > } > >+void NetworkConnectionToWebProcess::transferKeptAliveLoad(NetworkResourceLoader& loader) >+{ >+ RELEASE_ASSERT(RunLoop::isMain()); >+ ASSERT(loader.isKeptAlive()); >+ ASSERT(m_networkResourceLoaders.get(loader.identifier()) == &loader); >+ if (auto takenLoader = m_networkResourceLoaders.take(loader.identifier())) >+ m_networkProcess->addKeptAliveLoad(takenLoader.releaseNonNull()); >+} >+ > void NetworkConnectionToWebProcess::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder) > { > if (decoder.messageReceiverName() == Messages::NetworkConnectionToWebProcess::messageReceiverName()) { >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >index 98cf4478705594c7c56d86dec43f6d7fba2b3893..c69e325e618e9ce86ba8af2c31036eaeaec12a0f 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >@@ -82,6 +82,7 @@ public: > NetworkProcess& networkProcess() { return m_networkProcess.get(); } > > void didCleanupResourceLoader(NetworkResourceLoader&); >+ void transferKeptAliveLoad(NetworkResourceLoader&); > void setOnLineState(bool); > > bool captureExtraNetworkLoadMetricsEnabled() const { return m_captureExtraNetworkLoadMetricsEnabled; } >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 5f73208ebac556d04964359ebb3a043d22cd88bf..69226f0063ba4e37afbac685f92067ce67854b59 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -2574,4 +2574,16 @@ void NetworkProcess::markAdClickAttributionsAsExpiredForTesting(PAL::SessionID s > completionHandler(); > } > >+void NetworkProcess::addKeptAliveLoad(Ref<NetworkResourceLoader>&& loader) >+{ >+ if (auto session = m_networkSessions.get(loader->sessionID())) >+ session->addKeptAliveLoad(WTFMove(loader)); >+} >+ >+void NetworkProcess::removeKeptAliveLoad(NetworkResourceLoader& loader) >+{ >+ if (auto session = m_networkSessions.get(loader.sessionID())) >+ session->removeKeptAliveLoad(loader); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.h b/Source/WebKit/NetworkProcess/NetworkProcess.h >index c0449a186b718d88be5649530adf43f24e8d50ee..d46443d0b7adeb9d4fbd1881f1d0f68465778323 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.h >@@ -92,6 +92,7 @@ class AuthenticationManager; > class NetworkConnectionToWebProcess; > class NetworkProcessSupplement; > class NetworkProximityManager; >+class NetworkResourceLoader; > class WebSWServerConnection; > class WebSWServerToContextConnection; > enum class ShouldGrandfatherStatistics : bool; >@@ -334,6 +335,9 @@ public: > > WebCore::StorageQuotaManager& storageQuotaManager(PAL::SessionID, const WebCore::ClientOrigin&); > >+ void addKeptAliveLoad(Ref<NetworkResourceLoader>&&); >+ void removeKeptAliveLoad(NetworkResourceLoader&); >+ > private: > void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&); > std::unique_ptr<WebCore::NetworkStorageSession> platformCreateDefaultStorageSession() const; >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoadMap.cpp b/Source/WebKit/NetworkProcess/NetworkResourceLoadMap.cpp >index b0868f10239732910dcba6b10e8494c31a85573e..e3332cee14d418aed48ffdeac779a38b1cc4d1af 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoadMap.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoadMap.cpp >@@ -45,10 +45,15 @@ NetworkResourceLoadMap::MapType::AddResult NetworkResourceLoadMap::add(ResourceL > } > > bool NetworkResourceLoadMap::remove(ResourceLoadIdentifier identifier) >+{ >+ return !!take(identifier); >+} >+ >+RefPtr<NetworkResourceLoader> NetworkResourceLoadMap::take(ResourceLoadIdentifier identifier) > { > auto loader = m_loaders.take(identifier); > if (!loader) >- return false; >+ return nullptr; > > if ((*loader)->originalRequest().hasUpload()) { > m_loadersWithUploads.remove(loader->ptr()); >@@ -56,7 +61,7 @@ bool NetworkResourceLoadMap::remove(ResourceLoadIdentifier identifier) > m_connectionToWebProcess.clearConnectionHasUploads(); > } > >- return true; >+ return WTFMove(*loader); > } > > NetworkResourceLoader* NetworkResourceLoadMap::get(ResourceLoadIdentifier identifier) const >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoadMap.h b/Source/WebKit/NetworkProcess/NetworkResourceLoadMap.h >index e38cbdc4c2f310012d7c7488f21450351bc90b47..6d4079ca64522af7b1b6d387f8fe4bb3d13c700d 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoadMap.h >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoadMap.h >@@ -56,6 +56,7 @@ public: > MapType::AddResult add(ResourceLoadIdentifier, Ref<NetworkResourceLoader>&&); > NetworkResourceLoader* get(ResourceLoadIdentifier) const; > bool remove(ResourceLoadIdentifier); >+ RefPtr<NetworkResourceLoader> take(ResourceLoadIdentifier); > > private: > NetworkConnectionToWebProcess& m_connectionToWebProcess; >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >index 1742c1218b2ff2c349c3f477b8b0a8cc2d366d99..048f077f90bbceb276d452c3e90e0ebaf2e373aa 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >@@ -106,7 +106,7 @@ NetworkResourceLoader::NetworkResourceLoader(NetworkResourceLoadParameters&& par > // Once bug 116233 is resolved, this ASSERT can just be "m_webPageID && m_webFrameID" > ASSERT((m_parameters.webPageID && m_parameters.webFrameID) || m_parameters.clientCredentialPolicy == ClientCredentialPolicy::CannotAskClientForCredentials); > >- if (synchronousReply || parameters.shouldRestrictHTTPResponseAccess) { >+ if (synchronousReply || parameters.shouldRestrictHTTPResponseAccess || parameters.options.keepAlive) { > NetworkLoadChecker::LoadType requestLoadType = isMainFrameLoad() ? NetworkLoadChecker::LoadType::MainFrame : NetworkLoadChecker::LoadType::Other; > m_networkLoadChecker = std::make_unique<NetworkLoadChecker>(connection.networkProcess(), FetchOptions { m_parameters.options }, m_parameters.sessionID, m_parameters.webPageID, m_parameters.webFrameID, HTTPHeaderMap { m_parameters.originalRequestHeaders }, URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.preflightPolicy, originalRequest().httpReferrer(), m_parameters.isHTTPSUpgradeEnabled, shouldCaptureExtraNetworkLoadMetrics(), requestLoadType); > if (m_parameters.cspResponseHeaders) >@@ -333,6 +333,12 @@ void NetworkResourceLoader::abort() > RELEASE_LOG_IF_ALLOWED("abort: Canceling resource load (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", > m_parameters.webPageID, m_parameters.webFrameID, m_parameters.identifier); > >+ if (m_parameters.options.keepAlive && m_response.isNull() && !m_isKeptAlive) { >+ m_isKeptAlive = true; >+ m_connection->transferKeptAliveLoad(*this); >+ return; >+ } >+ > if (m_networkLoad) { > if (canUseCache(m_networkLoad->currentRequest())) { > // We might already have used data from this incomplete load. Ensure older versions don't remain in the cache after cancel. >@@ -467,10 +473,21 @@ void NetworkResourceLoader::didReceiveResponse(ResourceResponse&& receivedRespon > // a main resource because the embedding client must decide whether to allow the load. > bool willWaitForContinueDidReceiveResponse = isMainResource(); > send(Messages::WebResourceLoader::DidReceiveResponse { response, willWaitForContinueDidReceiveResponse }); >- if (willWaitForContinueDidReceiveResponse) >+ >+ if (willWaitForContinueDidReceiveResponse) { > m_responseCompletionHandler = WTFMove(completionHandler); >- else >- completionHandler(PolicyAction::Use); >+ return; >+ } >+ >+ if (m_isKeptAlive) { >+ m_responseCompletionHandler = WTFMove(completionHandler); >+ RunLoop::main().dispatch([protectedThis = makeRef(*this)] { >+ protectedThis->didFinishLoading(NetworkLoadMetrics { }); >+ }); >+ return; >+ } >+ >+ completionHandler(PolicyAction::Use); > } > > void NetworkResourceLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, int reportedEncodedDataLength) >@@ -650,6 +667,11 @@ void NetworkResourceLoader::continueWillSendRedirectedRequest(ResourceRequest&& > { > ASSERT(!isSynchronous()); > >+ if (m_isKeptAlive) { >+ continueWillSendRequest(WTFMove(request), false); >+ return; >+ } >+ > if (adClickConversion) > handleAdClickAttributionConversion(WTFMove(*adClickConversion), request.url(), redirectRequest); > send(Messages::WebResourceLoader::WillSendRequest(redirectRequest, sanitizeResponseIfPossible(WTFMove(redirectResponse), ResourceResponse::SanitizationType::Redirection))); >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoader.h b/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >index 029851122ae36ae6b34cb5af02a65788cdfe59b6..c7de3c0c1f3dd4ca9f73cfe00524e369a8224c0f 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >@@ -114,6 +114,8 @@ public: > > void disableExtraNetworkLoadMetricsCapture() { m_shouldCaptureExtraNetworkLoadMetrics = false; } > >+ bool isKeptAlive() const { return m_isKeptAlive; } >+ > private: > NetworkResourceLoader(NetworkResourceLoadParameters&&, NetworkConnectionToWebProcess&, Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply&&); > >@@ -208,6 +210,7 @@ private: > bool m_shouldRestartLoad { false }; > ResponseCompletionHandler m_responseCompletionHandler; > bool m_shouldCaptureExtraNetworkLoadMetrics { false }; >+ bool m_isKeptAlive { false }; > > Optional<NetworkActivityTracker> m_networkActivityTracker; > }; >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.cpp b/Source/WebKit/NetworkProcess/NetworkSession.cpp >index 4261b6a423f3729fba1e3d5b21bf6c6473565ca5..5b442bf282f15cb2e99bb28490772f08fdb97141 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkSession.cpp >@@ -30,6 +30,7 @@ > #include "NetworkProcess.h" > #include "NetworkProcessProxyMessages.h" > #include "NetworkResourceLoadParameters.h" >+#include "NetworkResourceLoader.h" > #include "PingLoad.h" > #include "WebPageProxy.h" > #include "WebPageProxyMessages.h" >@@ -183,4 +184,18 @@ void NetworkSession::markAdClickAttributionsAsExpiredForTesting() > m_adClickAttribution->markAllUnconvertedAsExpiredForTesting(); > } > >+void NetworkSession::addKeptAliveLoad(Ref<NetworkResourceLoader>&& loader) >+{ >+ ASSERT(m_sessionID == loader->sessionID()); >+ ASSERT(!m_keptAliveLoads.contains(loader)); >+ m_keptAliveLoads.add(WTFMove(loader)); >+} >+ >+void NetworkSession::removeKeptAliveLoad(NetworkResourceLoader& loader) >+{ >+ ASSERT(m_sessionID == loader.sessionID()); >+ ASSERT(m_keptAliveLoads.contains(loader)); >+ m_keptAliveLoads.remove(loader); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.h b/Source/WebKit/NetworkProcess/NetworkSession.h >index 32e15222cd7b14985a187fc0541984528cbd1516..7099db815dfdd455061b0a4443c44a09b1500fc6 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.h >+++ b/Source/WebKit/NetworkProcess/NetworkSession.h >@@ -48,6 +48,7 @@ namespace WebKit { > class AdClickAttributionManager; > class NetworkDataTask; > class NetworkProcess; >+class NetworkResourceLoader; > class WebResourceLoadStatisticsStore; > struct NetworkSessionCreationParameters; > >@@ -88,6 +89,9 @@ public: > void setAdClickAttributionConversionURLForTesting(URL&&); > void markAdClickAttributionsAsExpiredForTesting(); > >+ void addKeptAliveLoad(Ref<NetworkResourceLoader>&&); >+ void removeKeptAliveLoad(NetworkResourceLoader&); >+ > protected: > NetworkSession(NetworkProcess&, PAL::SessionID); > >@@ -102,6 +106,8 @@ protected: > WebCore::RegistrableDomain m_resourceLoadStatisticsManualPrevalentResource; > #endif > UniqueRef<AdClickAttributionManager> m_adClickAttribution; >+ >+ HashSet<Ref<NetworkResourceLoader>> m_keptAliveLoads; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >index 25ccca05f5453b303eee09faf26516ac9c9dc227..04ae0e45d5e9d29ca0f270a06418a6ab2d501fcb 100644 >--- a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >+++ b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >@@ -116,6 +116,7 @@ static Seconds maximumBufferingTime(CachedResource* resource) > > switch (resource->type()) { > case CachedResource::Type::Beacon: >+ case CachedResource::Type::Ping: > case CachedResource::Type::CSSStyleSheet: > case CachedResource::Type::Script: > #if ENABLE(SVG_FONTS) >@@ -286,7 +287,7 @@ void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceL > auto* document = resourceLoader.frame() ? resourceLoader.frame()->document() : nullptr; > if (resourceLoader.options().cspResponseHeaders) > loadParameters.cspResponseHeaders = resourceLoader.options().cspResponseHeaders; >- else if (document && !document->shouldBypassMainWorldContentSecurityPolicy()) { >+ else if (document && !document->shouldBypassMainWorldContentSecurityPolicy() && resourceLoader.options().contentSecurityPolicyImposition == ContentSecurityPolicyImposition::DoPolicyCheck) { > if (auto* contentSecurityPolicy = document->contentSecurityPolicy()) > loadParameters.cspResponseHeaders = contentSecurityPolicy->responseHeaders(); > } >@@ -571,6 +572,11 @@ static uint64_t generateLoadIdentifier() > return ++identifier; > } > >+bool WebLoaderStrategy::usePingLoad() const >+{ >+ return !RuntimeEnabledFeatures::sharedFeatures().fetchAPIKeepAliveEnabled(); >+} >+ > void WebLoaderStrategy::startPingLoad(Frame& frame, ResourceRequest& request, const HTTPHeaderMap& originalRequestHeaders, const FetchOptions& options, ContentSecurityPolicyImposition policyCheck, PingLoadCompletionHandler&& completionHandler) > { > auto* document = frame.document(); >diff --git a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h >index 1efc93c02a3ca2b9bf0edf0aa905e5f9bb0d3bd3..4af59941e34f72ad26e81efb560606751811f8c6 100644 >--- a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h >+++ b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h >@@ -62,6 +62,7 @@ public: > void suspendPendingRequests() final; > void resumePendingRequests() final; > >+ bool usePingLoad() const final; > void startPingLoad(WebCore::Frame&, WebCore::ResourceRequest&, const WebCore::HTTPHeaderMap& originalRequestHeaders, const WebCore::FetchOptions&, WebCore::ContentSecurityPolicyImposition, PingLoadCompletionHandler&&) final; > void didFinishPingLoad(uint64_t pingLoadIdentifier, WebCore::ResourceError&&, WebCore::ResourceResponse&&); > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 15398b0e226c6179c648d9a01d4524de233bd931..4987ccfdeb24fad97bab9c065d31cd0fa70cebf9 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,26 @@ >+2019-04-26 Youenn Fablet <youenn@apple.com> >+ >+ Use normal loading path for ping loads >+ https://bugs.webkit.org/show_bug.cgi?id=196807 >+ >+ Reviewed by Alex Christensen. >+ >+ * TestExpectations: >+ * http/tests/blink/sendbeacon/beacon-cross-origin.https-expected.txt: >+ * http/tests/blink/sendbeacon/connect-src-beacon-allowed.html: >+ * http/tests/security/contentSecurityPolicy/connect-src-beacon-allowed.html: >+ * http/tests/security/contentSecurityPolicy/report-only-connect-src-beacon-redirect-blocked-expected.txt: >+ * http/tests/security/contentSecurityPolicy/report-only-connect-src-beacon-redirect-blocked.php: >+ * http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt: >+ * http/wpt/beacon/beacon-async-error-logging-expected.txt: >+ * http/wpt/beacon/beacon-async-error-logging.html: >+ * http/wpt/beacon/connect-src-beacon-redirect-blocked.sub-expected.txt: >+ * http/wpt/beacon/contentextensions/beacon-redirect-blocked-expected.txt: >+ * http/wpt/beacon/resources/beacon-preflight.py: >+ (respondToCORSPreflight): >+ (main): >+ * platform/wk2/http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-css-in-iframe-report-only-expected.txt: >+ > 2019-04-26 Youenn Fablet <youenn@apple.com> > > Mark some cache-storage as slow on iOS-simulator >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 22480e7daeb378cb7c4f38edc86a8f69c5178b5c..3396ced2312272ad6a3d6151561c2ef12ad7caf2 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,12 @@ >+2019-04-26 Youenn Fablet <youenn@apple.com> >+ >+ Use normal loading path for ping loads >+ https://bugs.webkit.org/show_bug.cgi?id=196807 >+ >+ Reviewed by Alex Christensen. >+ >+ * web-platform-tests/beacon/headers/header-content-type-expected.txt: >+ > 2019-04-26 Youenn Fablet <youenn@apple.com> > > [Mac WK2 iOS Sim] Layout Test imported/w3c/web-platform-tests/webrtc/RTCRtpReceiver-getSynchronizationSources.https.html is a flaky failure >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index bdc45ae7888fb4d0ddc132317aaf91d56c850e10..f0c42eb1db265d2682e7f69bd14a6558e872a9e3 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -1787,6 +1787,16 @@ webkit.org/b/168238 imported/w3c/web-platform-tests/dom/events/EventListener-inv > imported/w3c/web-platform-tests/fetch/nosniff [ DumpJSConsoleLogInStdErr ] > imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/sandbox-ascii-case-insensitive.html [ DumpJSConsoleLogInStdErr ] > >+http/wpt/beacon/cors/cors-preflight-blob-failure.html [ DumpJSConsoleLogInStdErr ] >+http/wpt/beacon/cors/cors-preflight-blob-success.html [ DumpJSConsoleLogInStdErr ] >+http/wpt/beacon/cors/cors-preflight-cookie.html [ DumpJSConsoleLogInStdErr ] >+http/wpt/beacon/cors/cors-preflight-redirect-failure.html [ DumpJSConsoleLogInStdErr ] >+http/wpt/beacon/cors/cors-preflight-redirect-from-crossorigin-to-sameorigin.html [ DumpJSConsoleLogInStdErr ] >+http/wpt/beacon/cors/cors-preflight-redirect-success.html [ DumpJSConsoleLogInStdErr ] >+http/wpt/beacon/cors/crossorigin-arraybufferview-no-preflight.html [ DumpJSConsoleLogInStdErr ] >+ >+http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-css-in-iframe-report-only.html [ Pass Failure ] >+ > # Imported css-text test suite from WPT > webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/hanging-punctuation/hanging-punctuation-first-001.xht [ ImageOnlyFailure ] > webkit.org/b/183258 imported/w3c/web-platform-tests/css/css-text/hanging-punctuation/hanging-punctuation-force-end-001.xht [ ImageOnlyFailure ] >diff --git a/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin.https-expected.txt b/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin.https-expected.txt >index dcf06b485a14c655ef9dd1b693413f8c4caef346..c5664edabc13618dbaa547e45ef39245059bfbab 100644 >--- a/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin.https-expected.txt >+++ b/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin.https-expected.txt >@@ -1,11 +1,12 @@ >+Blocked access to external URL http://example.test:8000/blink/sendbeacon/resources/save-beacon.php?name=cross-origin >+CONSOLE MESSAGE: line 1: Beacon API cannot load http://example.test:8000/blink/sendbeacon/resources/save-beacon.php?name=cross-origin due to access control checks. > Verify navigator.sendBeacon() mixed content checking. > > On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". > > >-FAIL navigator.sendBeacon("http://example.test:8000/blink/sendbeacon/resources/save-beacon.php?name=cross-origin", "CrossOrigin"); should be false. Was true. >+PASS navigator.sendBeacon("http://example.test:8000/blink/sendbeacon/resources/save-beacon.php?name=cross-origin", "CrossOrigin"); is false > PASS successfullyParsed is true >-Some tests failed. > > TEST COMPLETE > >diff --git a/LayoutTests/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt b/LayoutTests/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt >index 2b96adf2adbceaa2af61bfb86ccbe1aac06ea723..5b7176881ff7deba3249d03221c11c0730d6d158 100644 >--- a/LayoutTests/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt >+++ b/LayoutTests/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt >@@ -1,4 +1,6 @@ > CONSOLE MESSAGE: Refused to load http://127.0.0.1:8000/security/contentSecurityPolicy/example_font.woff because it does not appear in the font-src directive of the Content Security Policy. >+Blocked access to external URL http://webkit.org/report > CONSOLE MESSAGE: Refused to load http://127.0.0.1:8000/security/contentSecurityPolicy/example_font.woff because it does not appear in the font-src directive of the Content Security Policy. >+Blocked access to external URL http://webkit.org/report > The iframe below triggers a violation report creating the initial empty document. It should not crash the web process. > >diff --git a/LayoutTests/http/wpt/beacon/beacon-async-error-logging-expected.txt b/LayoutTests/http/wpt/beacon/beacon-async-error-logging-expected.txt >index 82008d97f3738c4f2c2bf5852b3384a0ce98c982..49d1e748c1e6819a7746bd7fcf035f39dfbbbe0b 100644 >--- a/LayoutTests/http/wpt/beacon/beacon-async-error-logging-expected.txt >+++ b/LayoutTests/http/wpt/beacon/beacon-async-error-logging-expected.txt >@@ -1,4 +1,4 @@ >-CONSOLE MESSAGE: Beacon API cannot load http://invalid.localhost/. A server with the specified hostname could not be found. >+CONSOLE MESSAGE: Beacon API cannot load http://localhost:1/. Not allowed to use restricted network port > > PASS Should log an error message in the console > >diff --git a/LayoutTests/http/wpt/beacon/beacon-async-error-logging.html b/LayoutTests/http/wpt/beacon/beacon-async-error-logging.html >index 00bc9d7a65238c0aca4f0b0fa8c724a2ffd60af7..701799f48e73a9fcc60ae2149e4bdac25d183314 100644 >--- a/LayoutTests/http/wpt/beacon/beacon-async-error-logging.html >+++ b/LayoutTests/http/wpt/beacon/beacon-async-error-logging.html >@@ -14,8 +14,8 @@ > } else { > setTimeout(function() { t.done(); }, 500); > } >- let invalidHost = "http://invalid.localhost"; >- assert_true(navigator.sendBeacon(invalidHost, 'test'), "sendBeacon should return true"); >+ let hostWithInvalidPort = "http://localhost:1"; >+ assert_true(navigator.sendBeacon(hostWithInvalidPort, 'test'), "sendBeacon should return true"); > }, "Should log an error message in the console"); > </script> > </body> >diff --git a/LayoutTests/http/wpt/beacon/connect-src-beacon-redirect-blocked.sub-expected.txt b/LayoutTests/http/wpt/beacon/connect-src-beacon-redirect-blocked.sub-expected.txt >index fc75d81db1d72b27cc7abdaa1acc6b96a79cd353..935e47973b786dbe02d7241e3259213675751d06 100644 >--- a/LayoutTests/http/wpt/beacon/connect-src-beacon-redirect-blocked.sub-expected.txt >+++ b/LayoutTests/http/wpt/beacon/connect-src-beacon-redirect-blocked.sub-expected.txt >@@ -1,3 +1,5 @@ >+CONSOLE MESSAGE: Refused to connect to http://127.0.0.1:8800/WebKit/beacon/resources/beacon-preflight.py?allowCors=1&cmd=put&id=2539e883-7dfb-4dde-a227-a41c670d5fe1&redirect_status=307&location=http%3A%2F%2F127.0.0.1%3A8800%2FWebKit%2Fbeacon%2Fresources%2Fbeacon-preflight.py%3FallowCors%3D1%26cmd%3Dput%26id%3D2539e883-7dfb-4dde-a227-a41c670d5fe1&count=1 because it does not appear in the connect-src directive of the Content Security Policy. >+CONSOLE MESSAGE: Blocked by Content Security Policy. > CONSOLE MESSAGE: Beacon API cannot load http://127.0.0.1:8800/WebKit/beacon/resources/beacon-preflight.py?allowCors=1&cmd=put&id=2539e883-7dfb-4dde-a227-a41c670d5fe1&redirect_status=307&location=http%3A%2F%2F127.0.0.1%3A8800%2FWebKit%2Fbeacon%2Fresources%2Fbeacon-preflight.py%3FallowCors%3D1%26cmd%3Dput%26id%3D2539e883-7dfb-4dde-a227-a41c670d5fe1&count=1. Blocked by Content Security Policy. > > PASS Redirect is blocked by CSP >diff --git a/LayoutTests/http/wpt/beacon/contentextensions/beacon-redirect-blocked-expected.txt b/LayoutTests/http/wpt/beacon/contentextensions/beacon-redirect-blocked-expected.txt >index 97b7952fa814de2e324b5d11580a4efec2ab1747..e46327e37ea1d9178436e24d45dea67ce971cc2a 100644 >--- a/LayoutTests/http/wpt/beacon/contentextensions/beacon-redirect-blocked-expected.txt >+++ b/LayoutTests/http/wpt/beacon/contentextensions/beacon-redirect-blocked-expected.txt >@@ -1,4 +1,5 @@ >-CONSOLE MESSAGE: Beacon API cannot load http://127.0.0.1:8800/WebKit/beacon/resources/beacon-preflight.py?allowCors=1&cmd=put&id=f470f43c-258c-4c82-b880-ace3bcdb211c&redirect_status=307&location=http%3A%2F%2F127.0.0.1%3A8800%2FWebKit%2Fbeacon%2Fresources%2Fbeacon-preflight.py%3FallowCors%3D1%26cmd%3Dput%26id%3Df470f43c-258c-4c82-b880-ace3bcdb211c&count=1. Blocked by content extension >+CONSOLE MESSAGE: Content blocker prevented frame displaying http://localhost:8800/WebKit/beacon/contentextensions/beacon-redirect-blocked.html from loading a resource from http://127.0.0.1:8800/WebKit/beacon/resources/beacon-preflight.py?allowCors=1&cmd=put&id=f470f43c-258c-4c82-b880-ace3bcdb211c&redirect_status=307&location=http%3A%2F%2F127.0.0.1%3A8800%2FWebKit%2Fbeacon%2Fresources%2Fbeacon-preflight.py%3FallowCors%3D1%26cmd%3Dput%26id%3Df470f43c-258c-4c82-b880-ace3bcdb211c&count=1 >+CONSOLE MESSAGE: Beacon API cannot load http://localhost:8800/WebKit/beacon/resources/redirect.py?redirect_status=307&location=http%3A%2F%2F127.0.0.1%3A8800%2FWebKit%2Fbeacon%2Fresources%2Fbeacon-preflight.py%3FallowCors%3D1%26cmd%3Dput%26id%3Df470f43c-258c-4c82-b880-ace3bcdb211c. The URL was blocked by a content blocker > > PASS Content extensions should be able to block beacon redirects > >diff --git a/LayoutTests/http/wpt/beacon/resources/beacon-preflight.py b/LayoutTests/http/wpt/beacon/resources/beacon-preflight.py >index 9e64e76ffd6e3b9ca9a1a5c032d62e565d5d5848..1d49cf3937accfa018b57fe85c2b5197ac6b4601 100644 >--- a/LayoutTests/http/wpt/beacon/resources/beacon-preflight.py >+++ b/LayoutTests/http/wpt/beacon/resources/beacon-preflight.py >@@ -1,17 +1,17 @@ > import json > > def respondToCORSPreflight(request, response): >+ headers = [("Content-Type", "text/plain")] > allow_cors = int(request.GET.first("allowCors", 0)) != 0; > > if not allow_cors: > response.set_error(400, "Not allowed") >- return "ERROR: Not allowed" >+ return headers, "ERROR: Not allowed" > > if not "Access-Control-Request-Method" in request.headers: > response.set_error(400, "No Access-Control-Request-Method header") >- return "ERROR: No access-control-request-method in preflight!" >+ return headers, "ERROR: No access-control-request-method in preflight!" > >- headers = [("Content-Type", "text/plain")] > headers.append(("Access-Control-Allow-Origin", request.headers.get("Origin", "*"))) > headers.append(("Access-Control-Allow-Credentials", "true")) > requested_method = request.headers.get("Access-Control-Request-Method", None) >@@ -51,4 +51,4 @@ def main(request, response): > return [("Content-Type", "text/plain")], "" > > response.set_error(400, "Bad Command") >- return "ERROR: Bad Command!" >+ return [("Content-Type", "text/plain")], "ERROR: Bad Command!" >diff --git a/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt >index 3d8e9dc55d8ab8f3c81f784e926eb2b296709fb2..60ee6e5eac9398982e63cc40a81e3f6f626c754a 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt >@@ -1,10 +1,8 @@ > >-Harness Error (TIMEOUT), message = null >- >-TIMEOUT Test content-type header for a body string Test timed out >-NOTRUN Test content-type header for a body ArrayBufferView >-NOTRUN Test content-type header for a body ArrayBuffer >-NOTRUN Test content-type header for a body Blob >-NOTRUN Test content-type header for a body FormData >-NOTRUN Test content-type header for a body URLSearchParams >+PASS Test content-type header for a body string >+PASS Test content-type header for a body ArrayBufferView >+PASS Test content-type header for a body ArrayBuffer >+PASS Test content-type header for a body Blob >+PASS Test content-type header for a body FormData >+PASS Test content-type header for a body URLSearchParams > >diff --git a/LayoutTests/platform/mac-wk1/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt b/LayoutTests/platform/mac-wk1/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..2b96adf2adbceaa2af61bfb86ccbe1aac06ea723 >--- /dev/null >+++ b/LayoutTests/platform/mac-wk1/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt >@@ -0,0 +1,4 @@ >+CONSOLE MESSAGE: Refused to load http://127.0.0.1:8000/security/contentSecurityPolicy/example_font.woff because it does not appear in the font-src directive of the Content Security Policy. >+CONSOLE MESSAGE: Refused to load http://127.0.0.1:8000/security/contentSecurityPolicy/example_font.woff because it does not appear in the font-src directive of the Content Security Policy. >+The iframe below triggers a violation report creating the initial empty document. It should not crash the web process. >+ >diff --git a/LayoutTests/platform/win/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt b/LayoutTests/platform/win/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..2b96adf2adbceaa2af61bfb86ccbe1aac06ea723 >--- /dev/null >+++ b/LayoutTests/platform/win/http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher-expected.txt >@@ -0,0 +1,4 @@ >+CONSOLE MESSAGE: Refused to load http://127.0.0.1:8000/security/contentSecurityPolicy/example_font.woff because it does not appear in the font-src directive of the Content Security Policy. >+CONSOLE MESSAGE: Refused to load http://127.0.0.1:8000/security/contentSecurityPolicy/example_font.woff because it does not appear in the font-src directive of the Content Security Policy. >+The iframe below triggers a violation report creating the initial empty document. It should not crash the web process. >+ >diff --git a/LayoutTests/platform/wk2/http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-css-in-iframe-report-only-expected.txt b/LayoutTests/platform/wk2/http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-css-in-iframe-report-only-expected.txt >index 8e5f651c05e7a54c4b7df52c22a8aff8e5d2fd0f..060a4bff7bbf16b3b1846c3266b5c7c693caaf7d 100644 >--- a/LayoutTests/platform/wk2/http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-css-in-iframe-report-only-expected.txt >+++ b/LayoutTests/platform/wk2/http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-css-in-iframe-report-only-expected.txt >@@ -8,13 +8,13 @@ frame "<!--frame1-->" - willPerformClientRedirectToURL: https://127.0.0.1:8443/s > frame "<!--frame1-->" - didFinishDocumentLoadForFrame > main frame - didHandleOnloadEventsForFrame > frame "<!--frame1-->" - didFinishLoadForFrame >-main frame - didFinishLoadForFrame > frame "<!--frame1-->" - didStartProvisionalLoadForFrame > frame "<!--frame1-->" - didCancelClientRedirectForFrame > frame "<!--frame1-->" - didCommitLoadForFrame > frame "<!--frame1-->" - didFinishDocumentLoadForFrame > frame "<!--frame1-->" - didHandleOnloadEventsForFrame > frame "<!--frame1-->" - didFinishLoadForFrame >+main frame - didFinishLoadForFrame > This test loads a secure iframe that loads an insecure stylesheet. We should trigger a mixed content block even though the child frame has a report only CSP block-all-mixed-content directive because an active network attacker can use CSS3 to breach the confidentiality of the HTTPS security origin. > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 196807
:
367198
|
367201
|
367255
|
367328
|
367334
|
367339
|
367340
|
367342
|
367352
|
367359
|
368138
| 368329