Diff
Modified: trunk/LayoutTests/ChangeLog (220302 => 220303)
--- trunk/LayoutTests/ChangeLog 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/LayoutTests/ChangeLog 2017-08-04 23:09:24 UTC (rev 220303)
@@ -1,3 +1,23 @@
+2017-08-04 Chris Dumez <[email protected]>
+
+ [Beacon] Update sendBeacon to use the CachedResourceLoader
+ https://bugs.webkit.org/show_bug.cgi?id=175192
+ <rdar://problem/33725923>
+
+ Reviewed by Youenn Fablet.
+
+ 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.
+
+ Our Content-Type header for ArrayBuffer / ArrayBufferView payloads has also
+ changed. It is unclear which one is best but at least we are now consistent
+ with Fetch.
+
+ * 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:
+ * http/wpt/beacon/headers/header-content-type-same-origin.html:
+
2017-08-04 John Wilander <[email protected]>
Resource Load Statistics: Report user interaction immediately, but only when needed
Modified: trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-cookie-expected.txt (220302 => 220303)
--- trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-cookie-expected.txt 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-cookie-expected.txt 2017-08-04 23:09:24 UTC (rev 220303)
@@ -7,7 +7,7 @@
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
Modified: trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt (220302 => 220303)
--- trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt 2017-08-04 23:09:24 UTC (rev 220303)
@@ -6,7 +6,7 @@
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
Modified: trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-same-origin-expected.txt (220302 => 220303)
--- trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-same-origin-expected.txt 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/LayoutTests/http/tests/blink/sendbeacon/beacon-same-origin-expected.txt 2017-08-04 23:09:24 UTC (rev 220303)
@@ -7,7 +7,7 @@
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
@@ -16,8 +16,8 @@
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 Content-Type: application/x-www-form-urlencoded
+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 @@
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 @@
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 @@
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
Modified: trunk/LayoutTests/http/wpt/beacon/headers/header-content-type-same-origin.html (220302 => 220303)
--- trunk/LayoutTests/http/wpt/beacon/headers/header-content-type-same-origin.html 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/LayoutTests/http/wpt/beacon/headers/header-content-type-same-origin.html 2017-08-04 23:09:24 UTC (rev 220303)
@@ -77,8 +77,8 @@
}
testContentTypeHeader("hi!", "text/plain;charset=UTF-8", "string");
-testContentTypeHeader(stringToArrayBufferView("123"), "application/octet-stream", "ArrayBufferView"); // Specification says no content-type but browsers seem to use "application/octet-stream".
-testContentTypeHeader(stringToArrayBuffer("123"), "application/octet-stream", "ArrayBuffer"); // Specification says no content-type but browsers seem to use "application/octet-stream".
+testContentTypeHeader(stringToArrayBufferView("123"), "application/x-www-form-urlencoded", "ArrayBufferView"); // FIXME: It is unclear what the Content-Type should be here or if it should be present at all.
+testContentTypeHeader(stringToArrayBuffer("123"), "application/x-www-form-urlencoded", "ArrayBuffer"); // FIXME: It is unclear what the Content-Type should be here or if it should be present at all.
testContentTypeHeader(stringToBlob("123"), "text/plain", "Blob");
testContentTypeHeader(stringToFormData("qwerty"), "multipart/form-data", "FormData");
testContentTypeHeader(stringToURLSearchParams("key1=value1&key2=value2"), "application/x-www-form-urlencoded;charset=UTF-8", "URLSearchParams");
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (220302 => 220303)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-08-04 23:09:24 UTC (rev 220303)
@@ -1,5 +1,18 @@
2017-08-04 Chris Dumez <[email protected]>
+ [Beacon] Update sendBeacon to use the CachedResourceLoader
+ https://bugs.webkit.org/show_bug.cgi?id=175192
+ <rdar://problem/33725923>
+
+ Reviewed by Youenn Fablet.
+
+ Rebaseline test as our Content-Type header has changed for ArrayBuffer / ArrayBufferView
+ payloads.
+
+ * web-platform-tests/beacon/headers/header-content-type-expected.txt:
+
+2017-08-04 Chris Dumez <[email protected]>
+
Match newly-clarified spec on textarea defaultValue/value/child text content
https://bugs.webkit.org/show_bug.cgi?id=173878
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt (220302 => 220303)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt 2017-08-04 23:09:24 UTC (rev 220303)
@@ -1,6 +1,5 @@
-CONSOLE MESSAGE: line 35: This requests requires a CORS preflight but this is not supported yet.
PASS Test content-type header for a body string
-FAIL Test content-type header for a body ArrayBuffer assert_true: SendBeacon Succeeded expected true got false
+PASS Test content-type header for a body ArrayBuffer
PASS Test content-type header for a body FormData
Modified: trunk/Source/WebCore/ChangeLog (220302 => 220303)
--- trunk/Source/WebCore/ChangeLog 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/ChangeLog 2017-08-04 23:09:24 UTC (rev 220303)
@@ -1,3 +1,43 @@
+2017-08-04 Chris Dumez <[email protected]>
+
+ [Beacon] Update sendBeacon to use the CachedResourceLoader
+ https://bugs.webkit.org/show_bug.cgi?id=175192
+ <rdar://problem/33725923>
+
+ Reviewed by Youenn Fablet.
+
+ Update sendBeacon to use the FetchRequest / 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):
+ * Modules/beacon/NavigatorBeacon.h:
+ * 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 John Wilander <[email protected]>
Resource Load Statistics: Report user interaction immediately, but only when needed
Modified: trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp (220302 => 220303)
--- trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2017-08-04 23:09:24 UTC (rev 220303)
@@ -26,13 +26,16 @@
#include "config.h"
#include "NavigatorBeacon.h"
+#include "CachedResourceLoader.h"
#include "Document.h"
+#include "FetchRequest.h"
#include "Navigator.h"
#include "URL.h"
+#include <runtime/JSCJSValue.h>
namespace WebCore {
-ExceptionOr<bool> NavigatorBeacon::sendBeacon(Navigator&, Document& document, const String& url, std::optional<BodyInit>&& data)
+ExceptionOr<bool> NavigatorBeacon::sendBeacon(Navigator&, Document& document, const String& url, std::optional<FetchBody::Init>&& body)
{
URL parsedUrl = document.completeURL(url);
@@ -43,11 +46,31 @@
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;
+ }
+
+ FetchRequestInit init;
+ init.method = ASCIILiteral("POST");
+ init.body = WTFMove(body);
+ init.credentials = FetchOptions::Credentials::Include;
+ init.cache = FetchOptions::Cache::NoCache;
+ init.redirect = FetchOptions::Redirect::Follow;
+ init.keepalive = true;
+ init.window = JSC::jsNull();
+
+ auto fetchRequestResult = FetchRequest::create(document, parsedUrl.string(), WTFMove(init));
+ if (fetchRequestResult.hasException())
+ return fetchRequestResult.releaseException();
+
+ auto fetchRequest = fetchRequestResult.releaseReturnValue();
+ document.cachedResourceLoader().requestBeaconResource({ fetchRequest->internalRequest(), fetchRequest->fetchOptions() });
+ return true;
}
}
Modified: trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.h (220302 => 220303)
--- trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.h 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.h 2017-08-04 23:09:24 UTC (rev 220303)
@@ -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 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>&&);
};
}
Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (220302 => 220303)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2017-08-04 23:09:24 UTC (rev 220303)
@@ -162,6 +162,7 @@
#if ENABLE(XSLT)
case CachedResource::XSLStyleSheet:
#endif
+ case CachedResource::Beacon:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkSubresource:
case CachedResource::LinkPrefetch:
Modified: trunk/Source/WebCore/loader/PingLoader.cpp (220302 => 220303)
--- trunk/Source/WebCore/loader/PingLoader.cpp 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/PingLoader.cpp 2017-08-04 23:09:24 UTC (rev 220303)
@@ -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 @@
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();
Modified: trunk/Source/WebCore/loader/PingLoader.h (220302 => 220303)
--- trunk/Source/WebCore/loader/PingLoader.h 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/PingLoader.h 2017-08-04 23:09:24 UTC (rev 220303)
@@ -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 @@
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);
Modified: trunk/Source/WebCore/loader/ResourceLoadInfo.cpp (220302 => 220303)
--- trunk/Source/WebCore/loader/ResourceLoadInfo.cpp 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/ResourceLoadInfo.cpp 2017-08-04 23:09:24 UTC (rev 220303)
@@ -55,6 +55,7 @@
#endif
return ResourceType::Font;
+ case CachedResource::Beacon:
case CachedResource::MediaResource:
case CachedResource::Icon:
case CachedResource::RawResource:
@@ -70,6 +71,7 @@
ASSERT_NOT_REACHED();
#endif
};
+ return ResourceType::Raw;
}
uint16_t readResourceType(const String& name)
Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (220302 => 220303)
--- trunk/Source/WebCore/loader/SubresourceLoader.cpp 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp 2017-08-04 23:09:24 UTC (rev 220303)
@@ -447,6 +447,9 @@
#endif
resourceType = DiagnosticLoggingKeys::fontKey();
break;
+ case CachedResource::Beacon:
+ ASSERT_NOT_REACHED();
+ break;
case CachedResource::MediaResource:
case CachedResource::Icon:
case CachedResource::RawResource:
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (220302 => 220303)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2017-08-04 23:09:24 UTC (rev 220303)
@@ -88,6 +88,8 @@
#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 @@
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);
Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (220302 => 220303)
--- trunk/Source/WebCore/loader/cache/CachedResource.h 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h 2017-08-04 23:09:24 UTC (rev 220303)
@@ -72,6 +72,7 @@
MediaResource,
RawResource,
Icon,
+ Beacon,
SVGDocumentResource
#if ENABLE(XSLT)
, XSLStyleSheet
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (220302 => 220303)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2017-08-04 23:09:24 UTC (rev 220303)
@@ -108,6 +108,8 @@
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 @@
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 @@
return MixedContentChecker::ContentType::Active;
#endif
+ case CachedResource::Beacon:
case CachedResource::RawResource:
case CachedResource::Icon:
case CachedResource::SVGDocumentResource:
@@ -381,6 +389,7 @@
break;
}
case CachedResource::MainResource:
+ case CachedResource::Beacon:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkSubresource:
@@ -431,6 +440,7 @@
if (!m_document->contentSecurityPolicy()->allowMediaFromSource(url, redirectResponseReceived))
return false;
break;
+ case CachedResource::Beacon:
case CachedResource::RawResource:
return true;
default:
@@ -626,6 +636,9 @@
if (resource.type() == CachedResource::Type::RawResource || resource.type() == CachedResource::Type::MediaResource)
return false;
+ if (resource.type() == CachedResource::Beacon)
+ return false;
+
return true;
}
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (220302 => 220303)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2017-08-04 23:09:24 UTC (rev 220303)
@@ -78,6 +78,7 @@
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&&);
Modified: trunk/Source/WebKit/ChangeLog (220302 => 220303)
--- trunk/Source/WebKit/ChangeLog 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebKit/ChangeLog 2017-08-04 23:09:24 UTC (rev 220303)
@@ -1,3 +1,16 @@
+2017-08-04 Chris Dumez <[email protected]>
+
+ [Beacon] Update sendBeacon to use the CachedResourceLoader
+ https://bugs.webkit.org/show_bug.cgi?id=175192
+ <rdar://problem/33725923>
+
+ Reviewed by Youenn Fablet.
+
+ Deal with new Beacon CachedResource type.
+
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::maximumBufferingTime):
+
2017-08-04 John Wilander <[email protected]>
Resource Load Statistics: Report user interaction immediately, but only when needed
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (220302 => 220303)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2017-08-04 22:34:57 UTC (rev 220302)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2017-08-04 23:09:24 UTC (rev 220303)
@@ -105,6 +105,7 @@
return 0_s;
switch (resource->type()) {
+ case CachedResource::Beacon:
case CachedResource::CSSStyleSheet:
case CachedResource::Script:
#if ENABLE(SVG_FONTS)