WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-175192-20170804123431.patch (text/plain), 28.41 KB, created by
Chris Dumez
on 2017-08-04 12:34:31 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2017-08-04 12:34:31 PDT
Size:
28.41 KB
patch
obsolete
>Subversion Revision: 220272 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 959d2ef32e03a5b3b4a5ae0261a1e86c9aa4b53b..843a6fff82f08a2b1188fc6c9ac4144b58a1f901 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,42 @@ >+2017-08-04 Chris Dumez <cdumez@apple.com> >+ >+ [Beacon] Update sendBeacon to use the CachedResourceLoader >+ https://bugs.webkit.org/show_bug.cgi?id=175192 >+ <rdar://problem/33725923> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update sendBeacon to use the CachedResourceLoader instead of the PingLoader. >+ This gets us closer to the specification which is based on Fetch and reduces >+ code duplication. This also fixes an issue where our Origin header was not >+ properly set on Beacon resquests. >+ >+ In a follow-up, we will implement in CachedResourceLoader Fetch's quota for >+ inflight keepalive requests which is needed to fully support sendBeacon(). >+ >+ * Modules/beacon/NavigatorBeacon.cpp: >+ (WebCore::NavigatorBeacon::sendBeacon): >+ * loader/LinkLoader.cpp: >+ (WebCore::createLinkPreloadResourceClient): >+ * loader/PingLoader.cpp: >+ * loader/PingLoader.h: >+ * loader/ResourceLoadInfo.cpp: >+ (WebCore::toResourceType): >+ * loader/SubresourceLoader.cpp: >+ (WebCore::logResourceLoaded): >+ * loader/cache/CachedResource.cpp: >+ (WebCore::CachedResource::defaultPriorityForResourceType): >+ (WebCore::CachedResource::load): >+ * loader/cache/CachedResource.h: >+ * loader/cache/CachedResourceLoader.cpp: >+ (WebCore::createResource): >+ (WebCore::CachedResourceLoader::requestBeaconResource): >+ (WebCore::contentTypeFromResourceType): >+ (WebCore::CachedResourceLoader::checkInsecureContent const): >+ (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const): >+ (WebCore::isResourceSuitableForDirectReuse): >+ * loader/cache/CachedResourceLoader.h: >+ > 2017-08-04 Youenn Fablet <youenn@apple.com> > > Remove STREAMS_API compilation guard >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 5ad4b32d178bab3997a4af93c8f58fd66b54bb6e..eb7cbc9040a9a92ea9fcd6bc067f28563e65e2da 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,16 @@ >+2017-08-04 Chris Dumez <cdumez@apple.com> >+ >+ [Beacon] Update sendBeacon to use the CachedResourceLoader >+ https://bugs.webkit.org/show_bug.cgi?id=175192 >+ <rdar://problem/33725923> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Deal with new Beacon CachedResource type. >+ >+ * WebProcess/Network/WebLoaderStrategy.cpp: >+ (WebKit::maximumBufferingTime): >+ > 2017-08-04 Youenn Fablet <youenn@apple.com> > > Remove STREAMS_API compilation guard >diff --git a/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp b/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >index 29f7b7ce555ad1a281a73d4704b3589593d0d167..6aa661def25bfbf1c531d2c0b8128a0de3202018 100644 >--- a/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >+++ b/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp >@@ -26,13 +26,65 @@ > #include "config.h" > #include "NavigatorBeacon.h" > >+#include "Blob.h" >+#include "CachedResourceLoader.h" >+#include "DOMFormData.h" > #include "Document.h" >+#include "FormData.h" >+#include "HTTPHeaderNames.h" >+#include "HTTPHeaderValues.h" >+#include "HTTPParsers.h" > #include "Navigator.h" >+#include "ParsedContentType.h" > #include "URL.h" >+#include "URLSearchParams.h" >+#include <runtime/ArrayBuffer.h> >+#include <runtime/ArrayBufferView.h> >+#include <runtime/JSCInlines.h> >+ > > namespace WebCore { > >-ExceptionOr<bool> NavigatorBeacon::sendBeacon(Navigator&, Document& document, const String& url, std::optional<BodyInit>&& data) >+// https://fetch.spec.whatwg.org/#concept-bodyinit-extract >+static Ref<FormData> extractBody(FetchBody::Init& bodyInit, Document& document, String& mimeType) >+{ >+ return WTF::switchOn(bodyInit, >+ [&] (RefPtr<Blob>& blob) { >+ auto& blobType = blob->type(); >+ if (!blobType.isEmpty() && isValidContentType(blobType)) >+ mimeType = blobType; >+ else >+ mimeType = ASCIILiteral("application/octet-stream"); >+ auto formData = FormData::create(); >+ formData->appendBlob(blob->url()); >+ return formData; >+ }, >+ [&] (RefPtr<JSC::ArrayBuffer>& buffer) { >+ mimeType = ASCIILiteral("application/octet-stream"); >+ return FormData::create(buffer->data(), buffer->byteLength()); >+ }, >+ [&] (RefPtr<JSC::ArrayBufferView>& buffer) { >+ mimeType = ASCIILiteral("application/octet-stream"); >+ return FormData::create(buffer->baseAddress(), buffer->byteLength()); >+ }, >+ [&] (RefPtr<DOMFormData>& domFormData) { >+ auto formData = FormData::createMultiPart(*domFormData, domFormData->encoding(), &document); >+ formData->generateFiles(&document); >+ mimeType = makeString("multipart/form-data; boundary=", formData->boundary().data()); >+ return formData; >+ }, >+ [&] (RefPtr<URLSearchParams>& searchParams) { >+ mimeType = HTTPHeaderValues::formURLEncodedContentType(); >+ return FormData::create(searchParams->toString().utf8()); >+ }, >+ [&] (String& string) { >+ mimeType = HTTPHeaderValues::textPlainContentType(); >+ return FormData::create(string.utf8()); >+ } >+ ); >+} >+ >+ExceptionOr<bool> NavigatorBeacon::sendBeacon(Navigator&, Document& document, const String& url, std::optional<FetchBody::Init>&& data) > { > URL parsedUrl = document.completeURL(url); > >@@ -43,11 +95,49 @@ ExceptionOr<bool> NavigatorBeacon::sendBeacon(Navigator&, Document& document, co > if (!parsedUrl.protocolIsInHTTPFamily()) > return Exception { TypeError, ASCIILiteral("Beacons can only be sent over HTTP(S)") }; > >- auto* frame = document.frame(); >- if (!frame) >+ if (!document.frame()) > return false; > >- return PingLoader::sendBeacon(*frame, document, parsedUrl, WTFMove(data)); >+ auto& contentSecurityPolicy = *document.contentSecurityPolicy(); >+ if (!document.shouldBypassMainWorldContentSecurityPolicy() && !contentSecurityPolicy.allowConnectToSource(parsedUrl)) { >+ // We simulate a network error so we return true here. This is consistent with Blink. >+ return true; >+ } >+ >+ ResourceRequest request(parsedUrl); >+ >+ bool noCors = true; >+ request.setHTTPMethod(ASCIILiteral("POST")); >+ if (data) { >+ String mimeType; >+ request.setHTTPBody(extractBody(data.value(), document, mimeType)); >+ noCors = false; >+ if (!mimeType.isEmpty()) { >+ // If mimeType value is a CORS-safelisted request-header value for the Content-Type header, set corsMode to "no-cors". >+ if (isCrossOriginSafeRequestHeader(HTTPHeaderName::ContentType, mimeType)) >+ noCors = true; >+ request.setHTTPContentType(mimeType); >+ } >+ } >+ >+ // FIXME: We are supposed to do a preflight in this case but this is not supported yet. >+ bool isCrossOriginRequest = !document.securityOrigin().canRequest(parsedUrl); >+ if (isCrossOriginRequest && !noCors) { >+ document.addConsoleMessage(MessageSource::Security, MessageLevel::Error, ASCIILiteral("This requests requires a CORS preflight but this is not supported yet.")); >+ return false; >+ } >+ >+ ResourceLoaderOptions options; >+ options.keepAlive = true; >+ options.mode = noCors ? FetchOptions::Mode::NoCors : FetchOptions::Mode::Cors; >+ options.credentials = FetchOptions::Credentials::Include; >+ options.cache = FetchOptions::Cache::NoCache; >+ options.redirect = FetchOptions::Redirect::Follow; >+ options.allowCredentials = AllowStoredCredentials; >+ >+ document.cachedResourceLoader().requestBeaconResource({ WTFMove(request), options }); >+ >+ return true; > } > > } >diff --git a/Source/WebCore/Modules/beacon/NavigatorBeacon.h b/Source/WebCore/Modules/beacon/NavigatorBeacon.h >index d9cb3e5097893997df984634edada6ae83744fa1..6fdf89dd5aefe36cfa2ab0751e9838a4a84a668d 100644 >--- a/Source/WebCore/Modules/beacon/NavigatorBeacon.h >+++ b/Source/WebCore/Modules/beacon/NavigatorBeacon.h >@@ -26,7 +26,7 @@ > #pragma once > > #include "ExceptionOr.h" >-#include "PingLoader.h" >+#include "FetchBody.h" > #include <wtf/Forward.h> > > namespace WebCore { >@@ -36,7 +36,7 @@ class Navigator; > > class NavigatorBeacon { > public: >- static ExceptionOr<bool> sendBeacon(Navigator&, Document&, const String& url, std::optional<BodyInit>&&); >+ static ExceptionOr<bool> sendBeacon(Navigator&, Document&, const String& url, std::optional<FetchBody::Init>&&); > }; > > } >diff --git a/Source/WebCore/loader/LinkLoader.cpp b/Source/WebCore/loader/LinkLoader.cpp >index 7542bb72b308d91360bc009f762701b846956ef3..6e2d4aedc8c8d4f7eeb82482d44ee6614dfc2335 100644 >--- a/Source/WebCore/loader/LinkLoader.cpp >+++ b/Source/WebCore/loader/LinkLoader.cpp >@@ -162,6 +162,7 @@ static std::unique_ptr<LinkPreloadResourceClient> createLinkPreloadResourceClien > #if ENABLE(XSLT) > case CachedResource::XSLStyleSheet: > #endif >+ case CachedResource::Beacon: > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkSubresource: > case CachedResource::LinkPrefetch: >diff --git a/Source/WebCore/loader/PingLoader.cpp b/Source/WebCore/loader/PingLoader.cpp >index 104c3aa8a92bc08abb62d5cefb81d56a35682b74..865eb1cdb8052d1638634575315b8cc3bba92772 100644 >--- a/Source/WebCore/loader/PingLoader.cpp >+++ b/Source/WebCore/loader/PingLoader.cpp >@@ -34,21 +34,14 @@ > #include "config.h" > #include "PingLoader.h" > >-#include "Blob.h" > #include "ContentSecurityPolicy.h" >-#include "DOMFormData.h" > #include "Document.h" >-#include "FormData.h" > #include "Frame.h" > #include "FrameLoader.h" > #include "FrameLoaderClient.h" >-#include "HTTPHeaderNames.h" >-#include "HTTPHeaderValues.h" >-#include "HTTPParsers.h" > #include "InspectorInstrumentation.h" > #include "LoaderStrategy.h" > #include "Page.h" >-#include "ParsedContentType.h" > #include "PlatformStrategies.h" > #include "ProgressTracker.h" > #include "ResourceHandle.h" >@@ -57,11 +50,7 @@ > #include "ResourceResponse.h" > #include "SecurityOrigin.h" > #include "SecurityPolicy.h" >-#include "URLSearchParams.h" > #include "UserContentController.h" >-#include <runtime/ArrayBuffer.h> >-#include <runtime/ArrayBufferView.h> >-#include <runtime/JSCInlines.h> > #include <wtf/text/CString.h> > > namespace WebCore { >@@ -190,87 +179,6 @@ void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, Ref<For > startPingLoad(frame, request, ShouldFollowRedirects::No); > } > >-bool PingLoader::sendBeacon(Frame& frame, Document& document, const URL& url, std::optional<BodyInit>&& data) >-{ >- ResourceRequest request(url); >- if (processContentExtensionRulesForLoad(frame, request, ResourceType::Raw)) >- return false; >- >- auto& contentSecurityPolicy = *document.contentSecurityPolicy(); >- if (!document.shouldBypassMainWorldContentSecurityPolicy() && !contentSecurityPolicy.allowConnectToSource(url)) { >- // We simulate a network error so we return true here. This is consistent with Blink. >- return true; >- } >- >- bool noCors = true; >- request.setHTTPMethod(ASCIILiteral("POST")); >- // FIXME: We should restrict the size of payloads. >- if (data) { >- String mimeType; >- WTF::switchOn(data.value(), >- [&] (RefPtr<Blob>& blob) { >- auto& blobType = blob->type(); >- if (!blobType.isEmpty() && isValidContentType(blobType)) >- mimeType = blobType; >- else >- mimeType = ASCIILiteral("application/octet-stream"); >- auto formData = FormData::create(); >- formData->appendBlob(blob->url()); >- request.setHTTPBody(WTFMove(formData)); >- }, >- [&] (RefPtr<JSC::ArrayBuffer>& buffer) { >- mimeType = ASCIILiteral("application/octet-stream"); >- request.setHTTPBody(FormData::create(buffer->data(), buffer->byteLength())); >- }, >- [&] (RefPtr<JSC::ArrayBufferView>& buffer) { >- mimeType = ASCIILiteral("application/octet-stream"); >- request.setHTTPBody(FormData::create(buffer->baseAddress(), buffer->byteLength())); >- }, >- [&] (RefPtr<DOMFormData>& domFormData) { >- auto formData = FormData::createMultiPart(*domFormData, domFormData->encoding(), &document); >- formData->generateFiles(&document); >- mimeType = makeString("multipart/form-data; boundary=", formData->boundary().data()); >- request.setHTTPBody(WTFMove(formData)); >- }, >- [&] (RefPtr<URLSearchParams>& searchParams) { >- mimeType = HTTPHeaderValues::formURLEncodedContentType(); >- request.setHTTPBody(FormData::create(searchParams->toString().utf8())); >- }, >- [&] (String& string) { >- mimeType = HTTPHeaderValues::textPlainContentType(); >- request.setHTTPBody(FormData::create(string.utf8())); >- } >- ); >- noCors = false; >- if (!mimeType.isEmpty()) { >- // If mimeType value is a CORS-safelisted request-header value for the Content-Type header, set corsMode to "no-cors". >- if (isCrossOriginSafeRequestHeader(HTTPHeaderName::ContentType, mimeType)) >- noCors = true; >- request.setHTTPContentType(mimeType); >- } >- } >- request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0"); >- frame.loader().addExtraFieldsToSubresourceRequest(request); >- >- auto& sourceOrigin = document.securityOrigin(); >- bool isCrossOriginRequest = !sourceOrigin.canRequest(url); >- >- // FIXME: We are supposed to do a preflight in this case but this is not supported yet. >- if (isCrossOriginRequest && !noCors) { >- document.addConsoleMessage(MessageSource::Security, MessageLevel::Error, ASCIILiteral("This requests requires a CORS preflight but this is not supported yet.")); >- return false; >- } >- >- FrameLoader::addHTTPOriginIfNeeded(request, sourceOrigin.toString()); >- String referrer = SecurityPolicy::generateReferrerHeader(document.referrerPolicy(), url, frame.loader().outgoingReferrer()); >- if (!referrer.isEmpty()) >- request.setHTTPReferrer(referrer); >- >- request.setAllowCookies(true); // Credentials mode: include. >- startPingLoad(frame, request, ShouldFollowRedirects::Yes); >- return true; >-} >- > void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request, ShouldFollowRedirects shouldFollowRedirects) > { > unsigned long identifier = frame.page()->progress().createUniqueIdentifier(); >diff --git a/Source/WebCore/loader/PingLoader.h b/Source/WebCore/loader/PingLoader.h >index 6ab5ca37f277e12baa689e0269d43b01e6ac22d8..b7937de209bb24d82e227cb33eb48f711c29b2af 100644 >--- a/Source/WebCore/loader/PingLoader.h >+++ b/Source/WebCore/loader/PingLoader.h >@@ -34,24 +34,12 @@ > > #include <wtf/Forward.h> > #include <wtf/Ref.h> >-#include <wtf/Variant.h> >- >-namespace JSC { >- >-class ArrayBuffer; >-class ArrayBufferView; >- >-} > > namespace WebCore { > >-class Blob; >-class DOMFormData; >-class Document; > class FormData; > class Frame; > class URL; >-class URLSearchParams; > class ResourceRequest; > > enum class ViolationReportType { >@@ -59,12 +47,9 @@ enum class ViolationReportType { > XSSAuditor, > }; > >-using BodyInit = Variant<RefPtr<Blob>, RefPtr<JSC::ArrayBufferView>, RefPtr<JSC::ArrayBuffer>, RefPtr<DOMFormData>, RefPtr<URLSearchParams>, String>; >- > class PingLoader { > public: > static void loadImage(Frame&, const URL&); >- static bool sendBeacon(Frame&, Document&, const URL&, std::optional<BodyInit>&&); > static void sendPing(Frame&, const URL& pingURL, const URL& destinationURL); > static void sendViolationReport(Frame&, const URL& reportURL, Ref<FormData>&& report, ViolationReportType); > >diff --git a/Source/WebCore/loader/ResourceLoadInfo.cpp b/Source/WebCore/loader/ResourceLoadInfo.cpp >index 027b3f7dc665db3f9a612efecab7626313b73428..13b2ae100f48ebf274b88901d184822e7d1893e2 100644 >--- a/Source/WebCore/loader/ResourceLoadInfo.cpp >+++ b/Source/WebCore/loader/ResourceLoadInfo.cpp >@@ -55,6 +55,7 @@ ResourceType toResourceType(CachedResource::Type type) > #endif > return ResourceType::Font; > >+ case CachedResource::Beacon: > case CachedResource::MediaResource: > case CachedResource::Icon: > case CachedResource::RawResource: >@@ -70,6 +71,7 @@ ResourceType toResourceType(CachedResource::Type type) > ASSERT_NOT_REACHED(); > #endif > }; >+ return ResourceType::Raw; > } > > uint16_t readResourceType(const String& name) >diff --git a/Source/WebCore/loader/SubresourceLoader.cpp b/Source/WebCore/loader/SubresourceLoader.cpp >index 07fb52ea3f8ba72708952e157cffb05651f3c70f..e29bdfb7ecd5a8fdf039553243f7e576221f94a9 100644 >--- a/Source/WebCore/loader/SubresourceLoader.cpp >+++ b/Source/WebCore/loader/SubresourceLoader.cpp >@@ -447,6 +447,7 @@ static void logResourceLoaded(Frame* frame, CachedResource::Type type) > #endif > resourceType = DiagnosticLoggingKeys::fontKey(); > break; >+ case CachedResource::Beacon: > case CachedResource::MediaResource: > case CachedResource::Icon: > case CachedResource::RawResource: >diff --git a/Source/WebCore/loader/cache/CachedResource.cpp b/Source/WebCore/loader/cache/CachedResource.cpp >index d8d68fa6b5ec36353887f6006df867801be12ac7..4b442f658bda966976e8ea7ec8878ff0aedfd7dc 100644 >--- a/Source/WebCore/loader/cache/CachedResource.cpp >+++ b/Source/WebCore/loader/cache/CachedResource.cpp >@@ -88,6 +88,8 @@ ResourceLoadPriority CachedResource::defaultPriorityForResourceType(Type type) > #endif > case CachedResource::SVGDocumentResource: > return ResourceLoadPriority::Low; >+ case CachedResource::Beacon: >+ return ResourceLoadPriority::VeryLow; > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkPrefetch: > return ResourceLoadPriority::VeryLow; >@@ -257,6 +259,12 @@ void CachedResource::load(CachedResourceLoader& cachedResourceLoader) > m_fragmentIdentifierForRequest = String(); > } > >+ // FIXME: We should not special-case Beacon here. >+ if (m_options.keepAlive && type() == CachedResource::Beacon) { >+ platformStrategies()->loaderStrategy()->createPingHandle(frame.loader().networkingContext(), request, m_options.credentials == FetchOptions::Credentials::Include, m_options.redirect == FetchOptions::Redirect::Follow); >+ return; >+ } >+ > m_loader = platformStrategies()->loaderStrategy()->loadResource(frame, *this, request, m_options); > if (!m_loader) { > RELEASE_LOG_IF_ALLOWED("load: Unable to create SubresourceLoader (frame = %p)", &frame); >diff --git a/Source/WebCore/loader/cache/CachedResource.h b/Source/WebCore/loader/cache/CachedResource.h >index 242ffaca27dbb52192ffa701ce23c39a9e2cd74b..8ba98e596825b1798c8c32f352ac76e7f4d4889d 100644 >--- a/Source/WebCore/loader/cache/CachedResource.h >+++ b/Source/WebCore/loader/cache/CachedResource.h >@@ -72,6 +72,7 @@ public: > MediaResource, > RawResource, > Icon, >+ Beacon, > SVGDocumentResource > #if ENABLE(XSLT) > , XSLStyleSheet >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >index fb3489b0fc034abd0b1b7d1a822fffcea0a79678..830ce51cb4731f877b60474e6e329076248744e3 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >@@ -108,6 +108,8 @@ static CachedResource* createResource(CachedResource::Type type, CachedResourceR > case CachedResource::Icon: > case CachedResource::MainResource: > return new CachedRawResource(WTFMove(request), type, sessionID); >+ case CachedResource::Beacon: >+ return new CachedResource(WTFMove(request), CachedResource::Beacon, sessionID); > #if ENABLE(XSLT) > case CachedResource::XSLStyleSheet: > return new CachedXSLStyleSheet(WTFMove(request), sessionID); >@@ -287,6 +289,11 @@ CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestRawResource > return downcast<CachedRawResource>(requestResource(CachedResource::RawResource, WTFMove(request)).get()); > } > >+CachedResourceHandle<CachedResource> CachedResourceLoader::requestBeaconResource(CachedResourceRequest&& request) >+{ >+ return requestResource(CachedResource::Beacon, WTFMove(request)).get(); >+} >+ > CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestMainResource(CachedResourceRequest&& request) > { > return downcast<CachedRawResource>(requestResource(CachedResource::MainResource, WTFMove(request)).get()); >@@ -312,6 +319,7 @@ static MixedContentChecker::ContentType contentTypeFromResourceType(CachedResour > return MixedContentChecker::ContentType::Active; > #endif > >+ case CachedResource::Beacon: > case CachedResource::RawResource: > case CachedResource::Icon: > case CachedResource::SVGDocumentResource: >@@ -381,6 +389,7 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const > break; > } > case CachedResource::MainResource: >+ case CachedResource::Beacon: > #if ENABLE(LINK_PREFETCH) > case CachedResource::LinkPrefetch: > case CachedResource::LinkSubresource: >@@ -431,6 +440,7 @@ bool CachedResourceLoader::allowedByContentSecurityPolicy(CachedResource::Type t > if (!m_document->contentSecurityPolicy()->allowMediaFromSource(url, redirectResponseReceived)) > return false; > break; >+ case CachedResource::Beacon: > case CachedResource::RawResource: > return true; > default: >@@ -626,6 +636,9 @@ static inline bool isResourceSuitableForDirectReuse(const CachedResource& resour > if (resource.type() == CachedResource::Type::RawResource || resource.type() == CachedResource::Type::MediaResource) > return false; > >+ if (resource.type() == CachedResource::Beacon) >+ return false; >+ > return true; > } > >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.h b/Source/WebCore/loader/cache/CachedResourceLoader.h >index 9e2ccf53dda794cc2d548abb73c6405567d047f9..71a5b88b7e0037a545e50ccce94e8cde7af7342f 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.h >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.h >@@ -78,6 +78,7 @@ public: > CachedResourceHandle<CachedFont> requestFont(CachedResourceRequest&&, bool isSVG); > CachedResourceHandle<CachedRawResource> requestMedia(CachedResourceRequest&&); > CachedResourceHandle<CachedRawResource> requestIcon(CachedResourceRequest&&); >+ CachedResourceHandle<CachedResource> requestBeaconResource(CachedResourceRequest&&); > CachedResourceHandle<CachedRawResource> requestRawResource(CachedResourceRequest&&); > CachedResourceHandle<CachedRawResource> requestMainResource(CachedResourceRequest&&); > CachedResourceHandle<CachedSVGDocument> requestSVGDocument(CachedResourceRequest&&); >diff --git a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >index 63fe8b5046e4644aa64839777179d4ee1e729e0e..2f258cd758321388bd8bfe625ffcef7ec316fd1d 100644 >--- a/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >+++ b/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp >@@ -118,6 +118,7 @@ static Seconds maximumBufferingTime(CachedResource* resource) > return 50_ms; > case CachedResource::MainResource: > case CachedResource::Icon: >+ case CachedResource::Beacon: > case CachedResource::RawResource: > case CachedResource::SVGDocumentResource: > #if ENABLE(LINK_PREFETCH) >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index da0fb59ccf2044b9799b10a13a57938a47463bad..7a38d280374baf6270dfeb5b710d2bbdb94b1ae4 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,5 +1,20 @@ > 2017-08-04 Chris Dumez <cdumez@apple.com> > >+ [Beacon] Update sendBeacon to use the CachedResourceLoader >+ https://bugs.webkit.org/show_bug.cgi?id=175192 >+ <rdar://problem/33725923> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Rebaseline a few tests now that the Origin header is properly set of our Beacon >+ requests. This is a progression and matches the results from Blink. >+ >+ * http/tests/blink/sendbeacon/beacon-cookie-expected.txt: >+ * http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt: >+ * http/tests/blink/sendbeacon/beacon-same-origin-expected.txt: >+ >+2017-08-04 Chris Dumez <cdumez@apple.com> >+ > Mark beacon-basic-string.html as slow. > > * TestExpectations: >diff --git a/LayoutTests/http/tests/blink/sendbeacon/beacon-cookie-expected.txt b/LayoutTests/http/tests/blink/sendbeacon/beacon-cookie-expected.txt >index b35b4571f0f6c711d6f1dac81e41211c2b0271fa..f1afd7ff1e3f49c9fece1aa79883fdc286f8e876 100644 >--- a/LayoutTests/http/tests/blink/sendbeacon/beacon-cookie-expected.txt >+++ b/LayoutTests/http/tests/blink/sendbeacon/beacon-cookie-expected.txt >@@ -7,7 +7,7 @@ PASS navigator.sendBeacon("resources/save-beacon.php?name=cookie", "Blip"); is t > PASS Beacon sent successfully > PASS Content-Type: text/plain;charset=UTF-8 > PASS Cookie: hello=world >-PASS Origin: null >+PASS Origin: http://127.0.0.1:8000 > PASS Referer: http://127.0.0.1:8000/blink/sendbeacon/beacon-cookie.html > PASS Request-Method: POST > PASS Length: 4 >diff --git a/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt b/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt >index 774e1a61661a27ae48f779c2fc94cca92e299a84..76c01a5e9bca57e12e170d3c9dbfe22c104cf2c3 100644 >--- a/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt >+++ b/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt >@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE > PASS navigator.sendBeacon("http://localhost:8000/blink/sendbeacon/resources/save-beacon.php?name=cross-origin", "CrossOrigin"); is true > PASS Beacon sent successfully > PASS Content-Type: text/plain;charset=UTF-8 >-PASS Origin: null >+PASS Origin: http://127.0.0.1:8000 > PASS Referer: http://127.0.0.1:8000/blink/sendbeacon/beacon-cross-origin.html > PASS Request-Method: POST > PASS Length: 11 >diff --git a/LayoutTests/http/tests/blink/sendbeacon/beacon-same-origin-expected.txt b/LayoutTests/http/tests/blink/sendbeacon/beacon-same-origin-expected.txt >index b2e1e803f29c2a082a1543a71c418d40a98a855d..f07787fa39f5613a18f5cba541c777f4d49d9357 100644 >--- a/LayoutTests/http/tests/blink/sendbeacon/beacon-same-origin-expected.txt >+++ b/LayoutTests/http/tests/blink/sendbeacon/beacon-same-origin-expected.txt >@@ -7,7 +7,7 @@ Sending beacon with type: [object String] > PASS navigator.sendBeacon("resources/save-beacon.php?name=same-origin", payload); is true > PASS Beacon sent successfully > PASS Content-Type: text/plain;charset=UTF-8 >-PASS Origin: null >+PASS Origin: http://127.0.0.1:8000 > PASS Referer: http://127.0.0.1:8000/blink/sendbeacon/beacon-same-origin.html > PASS Request-Method: POST > PASS Length: 10 >@@ -17,7 +17,7 @@ Sending beacon with type: [object Uint32Array] > PASS navigator.sendBeacon("resources/save-beacon.php?name=same-origin", payload); is true > PASS Beacon sent successfully > PASS Content-Type: application/octet-stream >-PASS Origin: null >+PASS Origin: http://127.0.0.1:8000 > PASS Referer: http://127.0.0.1:8000/blink/sendbeacon/beacon-same-origin.html > PASS Request-Method: POST > PASS Length: 40 >@@ -27,7 +27,7 @@ Sending beacon with type: [object Blob] > PASS navigator.sendBeacon("resources/save-beacon.php?name=same-origin", payload); is true > PASS Beacon sent successfully > PASS Content-Type: text/plain;from-beacon=true >-PASS Origin: null >+PASS Origin: http://127.0.0.1:8000 > PASS Referer: http://127.0.0.1:8000/blink/sendbeacon/beacon-same-origin.html > PASS Request-Method: POST > PASS Length: 11 >@@ -37,7 +37,7 @@ Sending beacon with type: [object FormData] > PASS navigator.sendBeacon("resources/save-beacon.php?name=same-origin", payload); is true > PASS Beacon sent successfully > PASS Content-Type: multipart/form-data; >-PASS Origin: null >+PASS Origin: http://127.0.0.1:8000 > PASS Referer: http://127.0.0.1:8000/blink/sendbeacon/beacon-same-origin.html > PASS Request-Method: POST > PASS Length: 9 >@@ -47,7 +47,7 @@ Sending beacon with type: [object URLSearchParams] > PASS navigator.sendBeacon("resources/save-beacon.php?name=same-origin", payload); is true > PASS Beacon sent successfully > PASS Content-Type: application/x-www-form-urlencoded;charset=UTF-8 >-PASS Origin: null >+PASS Origin: http://127.0.0.1:8000 > PASS Referer: http://127.0.0.1:8000/blink/sendbeacon/beacon-same-origin.html > PASS Request-Method: POST > PASS Length: 7
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 175192
:
317251
|
317256
|
317258
|
317259
|
317268
|
317275
|
317283
|
317302