[Beacon] Update sendBeacon to use the CachedResourceLoader
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Aug 2017 23:09:24 +0000 (23:09 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Aug 2017 23:09:24 +0000 (23:09 +0000)
commit2e45e4cf81a76b76b18036823da677253241f162
tree6b78ae837554403c70d681903789693cae9c53ea
parent96b1861a5ddfdc145d801135428130b838fd375f
[Beacon] Update sendBeacon to use the CachedResourceLoader
https://bugs.webkit.org/show_bug.cgi?id=175192
<rdar://problem/33725923>

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline test as our Content-Type header has changed for ArrayBuffer / ArrayBufferView
payloads.

* web-platform-tests/beacon/headers/header-content-type-expected.txt:

Source/WebCore:

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:

Source/WebKit:

Deal with new Beacon CachedResource type.

* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::maximumBufferingTime):

LayoutTests:

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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/blink/sendbeacon/beacon-cookie-expected.txt
LayoutTests/http/tests/blink/sendbeacon/beacon-cross-origin-expected.txt
LayoutTests/http/tests/blink/sendbeacon/beacon-same-origin-expected.txt
LayoutTests/http/wpt/beacon/headers/header-content-type-same-origin.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/beacon/NavigatorBeacon.cpp
Source/WebCore/Modules/beacon/NavigatorBeacon.h
Source/WebCore/loader/LinkLoader.cpp
Source/WebCore/loader/PingLoader.cpp
Source/WebCore/loader/PingLoader.h
Source/WebCore/loader/ResourceLoadInfo.cpp
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp