LayoutTests/fast/xmlhttprequest/xmlhttprequest-nonexistent-file-expected.txt

11CONSOLE MESSAGE: line 64: Not allowed to load local resource: nonexistent.html
2 CONSOLE MESSAGE: line 64: XMLHttpRequest cannot load nonexistent.html due to access control checks.
 2CONSOLE MESSAGE: line 64: XMLHttpRequest cannot load nonexistent.html. Not allowed to request resource
33
44Bug 22475: REGRESSION: Async XMLHttpRequest never finishes on nonexistent files anymore
55

LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt

11CONSOLE MESSAGE: line 30: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/async-xhr-onerror.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
2 CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js due to access control checks.
 2CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js. Resource blocked by content blocker
33CONSOLE MESSAGE: line 30: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/async-xhr-onerror.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
4 CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js due to access control checks.
 4CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js. Resource blocked by content blocker
55Asynchronous onreadystatechange status: 0, readyState:1, responseText:
66Finished runTest. Waiting for callbacks
77Asynchronous onreadystatechange status: 0, readyState:1, responseText:

LayoutTests/http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-xhr-asynchronous-in-iframe-expected.txt

@@frame "<!--framePath //<!--frame0-->-->" - didStartProvisionalLoadForFrame
22main frame - didFinishDocumentLoadForFrame
33frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame
44CONSOLE MESSAGE: Blocked mixed content http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow-star.cgi because 'block-all-mixed-content' appears in the Content Security Policy.
5 CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow-star.cgi due to access control checks.
 5CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow-star.cgi. Not allowed to request resource
66frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
77frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
88main frame - didHandleOnloadEventsForFrame

LayoutTests/http/tests/security/contentSecurityPolicy/block-all-mixed-content/insecure-xhr-asynchronous-in-main-frame-expected.txt

@@main frame - didHandleOnloadEventsForFrame
44main frame - didFinishLoadForFrame
55main frame - didCommitLoadForFrame
66CONSOLE MESSAGE: Blocked mixed content http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow-star.cgi because 'block-all-mixed-content' appears in the Content Security Policy.
7 CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow-star.cgi due to access control checks.
 7CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/xmlhttprequest/resources/access-control-basic-allow-star.cgi. Not allowed to request resource
88main frame - didFinishDocumentLoadForFrame
99main frame - didHandleOnloadEventsForFrame
1010main frame - didFinishLoadForFrame

LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt

11CONSOLE MESSAGE: line 28: [blocked] The page at https://127.0.0.1:8443/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html was not allowed to display insecure content from http://127.0.0.1:8000/.
22
3 CONSOLE MESSAGE: line 28: XMLHttpRequest cannot load http://127.0.0.1:8000/ due to access control checks.
 3CONSOLE MESSAGE: line 28: XMLHttpRequest cannot load http://127.0.0.1:8000/. Not allowed to request resource
44This test opens a HTTPS window that loads insecure data via XHR. We should trigger a mixed content callback because the main frame in the window is HTTPS but now has insecure data.

LayoutTests/http/wpt/beacon/beacon-quota-expected.txt

 1CONSOLE MESSAGE: line 14: Reached maximum amount of queued data of 64Kb for keepalive requests
 2
 3PASS Beacon with a body above the Quota Limit should fail.
 4FAIL Multiple Beacons Quota Limit assert_false: Second beacon should not be sent because we reached the quota expected false got true
 5

LayoutTests/http/wpt/beacon/beacon-quota.html

 1<!DOCTYPE html>
 2<script src="/resources/testharness.js"></script>
 3<script src="/resources/testharnessreport.js"></script>
 4<script>
 5 // We should expect 64KiB of rolling quota for any type of keep-alive request sent.
 6 var expectedQuota = 65536;
 7
 8 function createPayload(payloadSize)
 9 {
 10 return "*".repeat(payloadSize);
 11 }
 12
 13 test(function() {
 14 assert_false(navigator.sendBeacon("/", createPayload(expectedQuota + 1)));
 15 }, "Beacon with a body above the Quota Limit should fail.");
 16
 17 test(function() {
 18 assert_true(navigator.sendBeacon("/", createPayload(expectedQuota)), "Beacon with a body at the Quota Limit should succeed.");
 19 assert_false(navigator.sendBeacon("/", createPayload(1)), "Second beacon should not be sent because we reached the quota");
 20 }, "Multiple Beacons Quota Limit");
 21</script>

LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about.any-expected.txt

@@CONSOLE MESSAGE: line 27: Fetch API cannot load about:invalid.com. Cross origin
55CONSOLE MESSAGE: line 27: Fetch API cannot load about:config. Cross origin requests are only supported for HTTP.
66CONSOLE MESSAGE: line 27: Fetch API cannot load about:unicorn. Cross origin requests are only supported for HTTP.
77
8 FAIL Fetching about:blank (GET) is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
9 FAIL Fetching about:blank (PUT) is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
10 FAIL Fetching about:blank (POST) is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
 8FAIL Fetching about:blank (GET) is OK promise_test: Unhandled rejection with value: object "TypeError: Cross origin requests are only supported for HTTP."
 9FAIL Fetching about:blank (PUT) is OK promise_test: Unhandled rejection with value: object "TypeError: Preflight response is not successful"
 10FAIL Fetching about:blank (POST) is OK promise_test: Unhandled rejection with value: object "TypeError: Cross origin requests are only supported for HTTP."
1111PASS Fetching about:invalid.com is KO
1212PASS Fetching about:config is KO
1313PASS Fetching about:unicorn is KO

LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-about.any.worker-expected.txt

11
2 FAIL Fetching about:blank (GET) is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
3 FAIL Fetching about:blank (PUT) is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
4 FAIL Fetching about:blank (POST) is OK promise_test: Unhandled rejection with value: object "TypeError: Type error"
 2FAIL Fetching about:blank (GET) is OK promise_test: Unhandled rejection with value: object "TypeError: Cross origin requests are only supported for HTTP."
 3FAIL Fetching about:blank (PUT) is OK promise_test: Unhandled rejection with value: object "TypeError: Preflight response is not successful"
 4FAIL Fetching about:blank (POST) is OK promise_test: Unhandled rejection with value: object "TypeError: Cross origin requests are only supported for HTTP."
55PASS Fetching about:invalid.com is KO
66PASS Fetching about:config is KO
77PASS Fetching about:unicorn is KO

LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-multiple-origins-expected.txt

@@CONSOLE MESSAGE: Fetch API cannot load http://localhost:8801/fetch/api/resources
1111CONSOLE MESSAGE: Access-Control-Allow-Origin cannot contain more than one origin.
1212CONSOLE MESSAGE: Fetch API cannot load http://localhost:8801/fetch/api/resources/preflight.py?origin=%2C%20http%3A%2F%2Fexample.com%2C%20https%3A%2F%2Fexample2.com. Access-Control-Allow-Origin cannot contain more than one origin.
1313
14 FAIL 3 origins allowed, match the 3rd (http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Type error"
15 FAIL 3 origins allowed, match the 3rd ("*") promise_test: Unhandled rejection with value: object "TypeError: Type error"
16 FAIL 3 origins allowed, match twice (http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Type error"
17 FAIL 3 origins allowed, match twice ("*") promise_test: Unhandled rejection with value: object "TypeError: Type error"
18 FAIL 3 origins allowed, match twice ("*" and http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Type error"
 14FAIL 3 origins allowed, match the 3rd (http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
 15FAIL 3 origins allowed, match the 3rd ("*") promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
 16FAIL 3 origins allowed, match twice (http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
 17FAIL 3 origins allowed, match twice ("*") promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
 18FAIL 3 origins allowed, match twice ("*" and http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
1919PASS 3 origins allowed, no match
2020

LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-multiple-origins-worker-expected.txt

@@CONSOLE MESSAGE: Access-Control-Allow-Origin cannot contain more than one origin
55CONSOLE MESSAGE: Access-Control-Allow-Origin cannot contain more than one origin.
66CONSOLE MESSAGE: Access-Control-Allow-Origin cannot contain more than one origin.
77
8 FAIL 3 origins allowed, match the 3rd (http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Type error"
9 FAIL 3 origins allowed, match the 3rd ("*") promise_test: Unhandled rejection with value: object "TypeError: Type error"
10 FAIL 3 origins allowed, match twice (http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Type error"
11 FAIL 3 origins allowed, match twice ("*") promise_test: Unhandled rejection with value: object "TypeError: Type error"
12 FAIL 3 origins allowed, match twice ("*" and http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Type error"
 8FAIL 3 origins allowed, match the 3rd (http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
 9FAIL 3 origins allowed, match the 3rd ("*") promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
 10FAIL 3 origins allowed, match twice (http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
 11FAIL 3 origins allowed, match twice ("*") promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
 12FAIL 3 origins allowed, match twice ("*" and http://localhost:8800) promise_test: Unhandled rejection with value: object "TypeError: Access-Control-Allow-Origin cannot contain more than one origin."
1313PASS 3 origins allowed, no match
1414

LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-preflight-star.any-expected.txt

@@CONSOLE MESSAGE: Fetch API cannot load http://127.0.0.1:8800/fetch/api/resources
77CONSOLE MESSAGE: Fetch API cannot load http://127.0.0.1:8800/fetch/api/resources/preflight.py?origin=http://localhost:8800&credentials&allow_methods=*&allow_headers=*&. Request header field X-Test is not allowed by Access-Control-Allow-Headers.
88
99PASS CORS that succeeds with credentials: false; method: GET (allowed: get); header: X-Test,1 (allowed: x-test)
10 FAIL CORS that succeeds with credentials: false; method: SUPER (allowed: *); header: X-Test,1 (allowed: x-test) promise_test: Unhandled rejection with value: object "TypeError: Type error"
11 FAIL CORS that succeeds with credentials: false; method: OK (allowed: *); header: X-Test,1 (allowed: *) promise_test: Unhandled rejection with value: object "TypeError: Type error"
 10FAIL CORS that succeeds with credentials: false; method: SUPER (allowed: *); header: X-Test,1 (allowed: x-test) promise_test: Unhandled rejection with value: object "TypeError: Method SUPER is not allowed by Access-Control-Allow-Methods."
 11FAIL CORS that succeeds with credentials: false; method: OK (allowed: *); header: X-Test,1 (allowed: *) promise_test: Unhandled rejection with value: object "TypeError: Method OK is not allowed by Access-Control-Allow-Methods."
1212PASS CORS that fails with credentials: true; method: OK (allowed: *); header: X-Test,1 (allowed: *)
1313PASS CORS that fails with credentials: true; method: PUT (allowed: *); header: undefined (allowed: )
1414PASS CORS that fails with credentials: true; method: PUT (allowed: put); header: undefined (allowed: *)

LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-preflight-star.any.worker-expected.txt

11
22PASS CORS that succeeds with credentials: false; method: GET (allowed: get); header: X-Test,1 (allowed: x-test)
3 FAIL CORS that succeeds with credentials: false; method: SUPER (allowed: *); header: X-Test,1 (allowed: x-test) promise_test: Unhandled rejection with value: object "TypeError: Type error"
4 FAIL CORS that succeeds with credentials: false; method: OK (allowed: *); header: X-Test,1 (allowed: *) promise_test: Unhandled rejection with value: object "TypeError: Type error"
 3FAIL CORS that succeeds with credentials: false; method: SUPER (allowed: *); header: X-Test,1 (allowed: x-test) promise_test: Unhandled rejection with value: object "TypeError: Method SUPER is not allowed by Access-Control-Allow-Methods."
 4FAIL CORS that succeeds with credentials: false; method: OK (allowed: *); header: X-Test,1 (allowed: *) promise_test: Unhandled rejection with value: object "TypeError: Method OK is not allowed by Access-Control-Allow-Methods."
55PASS CORS that fails with credentials: true; method: OK (allowed: *); header: X-Test,1 (allowed: *)
66PASS CORS that fails with credentials: true; method: PUT (allowed: *); header: undefined (allowed: )
77PASS CORS that fails with credentials: true; method: PUT (allowed: put); header: undefined (allowed: *)

LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-keepalive-quota-expected.txt

 1CONSOLE MESSAGE: line 44: Fetch API cannot load http://localhost:8800/fetch/api/resources/trickle.py?count=1&ms=0. Reached maximum amount of queued data of 64Kb for keepalive requests
 2CONSOLE MESSAGE: line 71: Fetch API cannot load http://localhost:8800/fetch/api/resources/trickle.py?count=1&ms=0. Reached maximum amount of queued data of 64Kb for keepalive requests
 3CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: Reached maximum amount of queued data of 64Kb for keepalive requests
 4CONSOLE MESSAGE: line 88: Fetch API cannot load http://localhost:8800/fetch/api/resources/trickle.py?count=1&ms=0. Reached maximum amount of queued data of 64Kb for keepalive requests
 5
 6Harness Error (FAIL), message = Reached maximum amount of queued data of 64Kb for keepalive requests
17
28PASS A Keep-Alive fetch() with a small body should succeed.
39PASS A Keep-Alive fetch() with a body at the Quota Limit should succeed.
4 FAIL A Keep-Alive fetch() with a body over the Quota Limit should reject. assert_unreached: Should have rejected: undefined Reached unreachable code
 10PASS A Keep-Alive fetch() with a body over the Quota Limit should reject.
511PASS A Keep-Alive fetch() should return it's allocated Quota upon promise resolution.
612PASS A Keep-Alive fetch() should return only it's allocated Quota upon promise resolution.
7 FAIL A Keep-Alive fetch() should not be allowed if the Quota is used up. assert_unreached: Should have rejected: undefined Reached unreachable code
 13PASS A Keep-Alive fetch() should not be allowed if the Quota is used up.
814

LayoutTests/imported/w3c/web-platform-tests/fetch/http-cache/cc-request-expected.txt

@@PASS HTTP cache doesn't reuse fresh response when request contains Cache-Control
1010PASS HTTP cache validates fresh response with Last-Modified when request contains Cache-Control: no-cache.
1111PASS HTTP cache validates fresh response with ETag when request contains Cache-Control: no-cache.
1212FAIL HTTP cache doesn't reuse fresh response when request contains Cache-Control: no-store. assert_equals: Response used expected 2 but got 1
13 FAIL HTTP cache generates 504 status code when nothing is in cache and request contains Cache-Control: only-if-cached. promise_test: Unhandled rejection with value: object "TypeError: Type error"
 13FAIL HTTP cache generates 504 status code when nothing is in cache and request contains Cache-Control: only-if-cached. promise_test: Unhandled rejection with value: object "TypeError: can’t load from network"
1414

Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
20692069 loader/cache/CachedSVGFont.cpp
20702070 loader/cache/CachedScript.cpp
20712071 loader/cache/CachedXSLStyleSheet.cpp
 2072 loader/cache/KeepaliveRequestTracker.cpp
20722073 loader/cache/MemoryCache.cpp
20732074
20742075 loader/icon/IconLoader.cpp

Source/WebCore/Modules/beacon/NavigatorBeacon.cpp

@@ExceptionOr<bool> NavigatorBeacon::sendBeacon(Navigator&, Document& document, co
7373 options.mode = FetchOptions::Mode::NoCors;
7474 }
7575 }
76  document.cachedResourceLoader().requestBeaconResource({ WTFMove(request), options });
 76 ResourceError error;
 77 if (!document.cachedResourceLoader().requestBeaconResource({ WTFMove(request), options }, &error)) {
 78 if (!error.isNull())
 79 document.addConsoleMessage(MessageSource::Network, MessageLevel::Error, error.localizedDescription());
 80 return false;
 81 }
7782 return true;
7883}
7984

Source/WebCore/Modules/fetch/FetchBodyOwner.cpp

3232#include "FetchLoader.h"
3333#include "HTTPParsers.h"
3434#include "JSBlob.h"
 35#include "ResourceError.h"
3536#include "ResourceResponse.h"
3637
3738namespace WebCore {

@@FetchBodyOwner::BlobLoader::BlobLoader(FetchBodyOwner& owner)
277278void FetchBodyOwner::BlobLoader::didReceiveResponse(const ResourceResponse& response)
278279{
279280 if (response.httpStatusCode() != 200)
280  didFail();
 281 didFail({ });
281282}
282283
283 void FetchBodyOwner::BlobLoader::didFail()
 284void FetchBodyOwner::BlobLoader::didFail(const ResourceError&)
284285{
285286 // didFail might be called within FetchLoader::start call.
286287 if (loader->isStarted())

Source/WebCore/Modules/fetch/FetchBodyOwner.h

@@private:
8888 // FetchLoaderClient API
8989 void didReceiveResponse(const ResourceResponse&) final;
9090 void didReceiveData(const char* data, size_t size) final { owner.blobChunk(data, size); }
91  void didFail() final;
 91 void didFail(const ResourceError&) final;
9292 void didSucceed() final { owner.blobLoadingSucceeded(); }
9393
9494 FetchBodyOwner& owner;

Source/WebCore/Modules/fetch/FetchLoader.cpp

3535#include "FetchBody.h"
3636#include "FetchLoaderClient.h"
3737#include "FetchRequest.h"
 38#include "ResourceError.h"
3839#include "ResourceRequest.h"
3940#include "ScriptExecutionContext.h"
4041#include "SecurityOrigin.h"

@@void FetchLoader::start(ScriptExecutionContext& context, const Blob& blob)
4849{
4950 auto urlForReading = BlobURL::createPublicURL(context.securityOrigin());
5051 if (urlForReading.isEmpty()) {
51  m_client.didFail();
 52 m_client.didFail({ errorDomainWebKitInternal, 0, URL(), ASCIILiteral("Could not create URL for Blob") });
5253 return;
5354 }
5455

@@void FetchLoader::start(ScriptExecutionContext& context, const FetchRequest& req
8889 contentSecurityPolicy.upgradeInsecureRequestIfNeeded(fetchRequest, ContentSecurityPolicy::InsecureRequestType::Load);
8990
9091 if (!context.shouldBypassMainWorldContentSecurityPolicy() && !contentSecurityPolicy.allowConnectToSource(fetchRequest.url())) {
91  m_client.didFail();
 92 m_client.didFail({ errorDomainWebKitInternal, 0, URL(), ASCIILiteral("Not allowed by ContentSecurityPolicy"), ResourceError::Type::AccessControl });
9293 return;
9394 }
9495

@@void FetchLoader::didFinishLoading(unsigned long)
144145 m_client.didSucceed();
145146}
146147
147 void FetchLoader::didFail(const ResourceError&)
 148void FetchLoader::didFail(const ResourceError& error)
148149{
149  m_client.didFail();
 150 m_client.didFail(error);
150151}
151152
152153} // namespace WebCore

Source/WebCore/Modules/fetch/FetchLoaderClient.h

3232
3333namespace WebCore {
3434
 35class ResourceError;
3536class ResourceResponse;
3637
3738class FetchLoaderClient {

@@public:
4344 virtual void didReceiveData(const char*, size_t) { }
4445
4546 virtual void didSucceed() = 0;
46  virtual void didFail() = 0;
 47 virtual void didFail(const ResourceError&) = 0;
4748};
4849
4950} // namespace WebCore

Source/WebCore/Modules/fetch/FetchResponse.cpp

3333#include "HTTPParsers.h"
3434#include "JSBlob.h"
3535#include "JSFetchResponse.h"
 36#include "ResourceError.h"
3637#include "ScriptExecutionContext.h"
3738
3839namespace WebCore {

@@void FetchResponse::BodyLoader::didSucceed()
138139 }
139140}
140141
141 void FetchResponse::BodyLoader::didFail()
 142void FetchResponse::BodyLoader::didFail(const ResourceError& error)
142143{
143144 ASSERT(m_response.hasPendingActivity());
144145 if (m_promise)
145  std::exchange(m_promise, std::nullopt)->reject(TypeError);
 146 std::exchange(m_promise, std::nullopt)->reject(Exception { TypeError, String(error.localizedDescription()) });
146147
147148#if ENABLE(STREAMS_API)
148149 if (m_response.m_readableStreamSource) {

Source/WebCore/Modules/fetch/FetchResponse.h

@@private:
118118 private:
119119 // FetchLoaderClient API
120120 void didSucceed() final;
121  void didFail() final;
 121 void didFail(const ResourceError&) final;
122122 void didReceiveResponse(const ResourceResponse&) final;
123123 void didReceiveData(const char*, size_t) final;
124124

Source/WebCore/WebCore.xcodeproj/project.pbxproj

34573457 839AAFED1A0C0C8D00605F99 /* HTMLWBRElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */; };
34583458 83A4A9F91CE7FD8100709B00 /* JSXMLDocumentCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */; };
34593459 83B2D1751B8BCD6A00A02E47 /* NativeNodeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E959E11B8BC22B004D9385 /* NativeNodeFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
 3460 83B74EF51F3E0BF200996BC7 /* KeepaliveRequestTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B74EF21F3E0BD700996BC7 /* KeepaliveRequestTracker.cpp */; };
 3461 83B74EF61F3E0BF200996BC7 /* KeepaliveRequestTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B74EF31F3E0BD700996BC7 /* KeepaliveRequestTracker.h */; };
34603462 83B9687B19F8AB83004EF7AF /* StyleBuilderConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9687919F8AB83004EF7AF /* StyleBuilderConverter.h */; };
34613463 83BB5C881D5D6F45005A71F4 /* AllDescendantsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 83BB5C871D5D6F3A005A71F4 /* AllDescendantsCollection.h */; };
34623464 83C05A5A1A686212007E5DEA /* StylePropertyShorthandFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83C05A581A686212007E5DEA /* StylePropertyShorthandFunctions.cpp */; };

1156111563 839AAFEA1A0C0C8D00605F99 /* HTMLWBRElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLWBRElement.cpp; sourceTree = "<group>"; };
1156211564 839AAFEB1A0C0C8D00605F99 /* HTMLWBRElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLWBRElement.h; sourceTree = "<group>"; };
1156311565 83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocumentCustom.cpp; sourceTree = "<group>"; };
 11566 83B74EF21F3E0BD700996BC7 /* KeepaliveRequestTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeepaliveRequestTracker.cpp; sourceTree = "<group>"; };
 11567 83B74EF31F3E0BD700996BC7 /* KeepaliveRequestTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeepaliveRequestTracker.h; sourceTree = "<group>"; };
1156411568 83B9687919F8AB83004EF7AF /* StyleBuilderConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderConverter.h; sourceTree = "<group>"; };
1156511569 83BB5C871D5D6F3A005A71F4 /* AllDescendantsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllDescendantsCollection.h; sourceTree = "<group>"; };
1156611570 83C05A581A686212007E5DEA /* StylePropertyShorthandFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StylePropertyShorthandFunctions.cpp; sourceTree = "<group>"; };

2233122335 BCB16C0E0979C3BD00467741 /* CachedXSLStyleSheet.cpp */,
2233222336 BCB16C0F0979C3BD00467741 /* CachedXSLStyleSheet.h */,
2233322337 F587864902DE3A9A01EA4122 /* CachePolicy.h */,
 22338 83B74EF21F3E0BD700996BC7 /* KeepaliveRequestTracker.cpp */,
 22339 83B74EF31F3E0BD700996BC7 /* KeepaliveRequestTracker.h */,
2233422340 BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */,
2233522341 BCB16BFF0979C3BD00467741 /* MemoryCache.h */,
2233622342 );

2781827824 77D5101C1ED722BF00DA4C87 /* JSCredentialsContainer.h in Headers */,
2781927825 77D510021ED4F71800DA4C87 /* JSCredentialUserData.h in Headers */,
2782027826 975CA2A21303679D00E99AD9 /* JSCrypto.h in Headers */,
 27827 83B74EF61F3E0BF200996BC7 /* KeepaliveRequestTracker.h in Headers */,
2782127828 E157A8F118185425009F821D /* JSCryptoAlgorithmBuilder.h in Headers */,
2782227829 E1C657131815F9DD00256CDD /* JSCryptoAlgorithmDictionary.h in Headers */,
2782327830 5739E12F1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h in Headers */,

3231332320 B2FA3D900AB75A6F000E5AC4 /* JSSVGFESpotLightElement.cpp in Sources */,
3231432321 B2FA3D920AB75A6F000E5AC4 /* JSSVGFETileElement.cpp in Sources */,
3231532322 B2FA3D940AB75A6F000E5AC4 /* JSSVGFETurbulenceElement.cpp in Sources */,
 32323 83B74EF51F3E0BF200996BC7 /* KeepaliveRequestTracker.cpp in Sources */,
3231632324 B2FA3D960AB75A6F000E5AC4 /* JSSVGFilterElement.cpp in Sources */,
3231732325 B27B28250CEF0C0700D39D54 /* JSSVGFontElement.cpp in Sources */,
3231832326 A83B79040CCAFF15000B0825 /* JSSVGFontFaceElement.cpp in Sources */,

Source/WebCore/loader/DocumentThreadableLoader.cpp

@@void DocumentThreadableLoader::loadRequest(ResourceRequest&& request, SecurityCh
451451
452452 // We create an URL here as the request will be moved in requestRawResource
453453 URL requestUrl = newRequest.resourceRequest().url();
454  m_resource = m_document.cachedResourceLoader().requestRawResource(WTFMove(newRequest));
 454 ResourceError error;
 455 m_resource = m_document.cachedResourceLoader().requestRawResource(WTFMove(newRequest), &error);
455456 if (m_resource)
456457 m_resource->addClient(*this);
457458 else {
458  // FIXME: Since we receive a synchronous error, this is probably due to some AccessControl checks. We should try to retrieve the actual error.
459  logErrorAndFail(ResourceError(String(), 0, requestUrl, String(), ResourceError::Type::AccessControl));
 459 if (error.isNull()) {
 460 // FIXME: Since we receive a synchronous error, this is probably due to some AccessControl checks. We should try to retrieve the actual error.
 461 logErrorAndFail(ResourceError(String(), 0, requestUrl, String(), ResourceError::Type::AccessControl));
 462 } else
 463 logErrorAndFail(error);
460464 }
461465 return;
462466 }

Source/WebCore/loader/cache/CachedResource.cpp

@@void CachedResource::load(CachedResourceLoader& cachedResourceLoader)
266266 auto* document = cachedResourceLoader.document();
267267 auto* contentSecurityPolicy = document && !document->shouldBypassMainWorldContentSecurityPolicy() ? document->contentSecurityPolicy() : nullptr;
268268 platformStrategies()->loaderStrategy()->createPingHandle(frame.loader().networkingContext(), request, *m_origin, contentSecurityPolicy, m_options);
 269 // FIXME: We currently do not get notified when ping loads finish so we treat them as finishing right away.
 270 finishLoading(nullptr);
269271 return;
270272 }
271273

Source/WebCore/loader/cache/CachedResource.h

@@public:
163163
164164 bool isImage() const { return type() == ImageResource; }
165165 // FIXME: CachedRawResource could be a main resource, an audio/video resource, or a raw XHR/icon resource.
166  bool isMainOrMediaOrIconOrRawResource() const { return type() == MainResource || type() == MediaResource || type() == Icon || type() == RawResource; }
 166 bool isMainOrMediaOrIconOrRawResource() const { return type() == MainResource || type() == MediaResource || type() == Icon || type() == RawResource || type() == Beacon; }
167167 bool ignoreForRequestCount() const
168168 {
169169 return m_resourceRequest.ignoreForRequestCount()

Source/WebCore/loader/cache/CachedResourceLoader.cpp

@@static CachedResource* createResource(CachedResource::Type type, CachedResourceR
103103#endif
104104 case CachedResource::FontResource:
105105 return new CachedFont(WTFMove(request), sessionID);
 106 case CachedResource::Beacon:
106107 case CachedResource::MediaResource:
107108 case CachedResource::RawResource:
108109 case CachedResource::Icon:
109110 case CachedResource::MainResource:
110111 return new CachedRawResource(WTFMove(request), type, sessionID);
111  case CachedResource::Beacon:
112  return new CachedResource(WTFMove(request), CachedResource::Beacon, sessionID);
113112#if ENABLE(XSLT)
114113 case CachedResource::XSLStyleSheet:
115114 return new CachedXSLStyleSheet(WTFMove(request), sessionID);

@@SessionID CachedResourceLoader::sessionID() const
182181 return sessionID;
183182}
184183
185 CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResourceRequest&& request)
 184CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResourceRequest&& request, ResourceError* error)
186185{
187186 if (Frame* frame = this->frame()) {
188187 if (frame->loader().pageDismissalEventBeingDispatched() != FrameLoader::PageDismissalType::None) {

@@CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResou
196195 }
197196
198197 auto defer = clientDefersImage(request.resourceRequest().url()) ? DeferOption::DeferredByClient : DeferOption::NoDefer;
199  return downcast<CachedImage>(requestResource(CachedResource::ImageResource, WTFMove(request), ForPreload::No, defer).get());
 198 return downcast<CachedImage>(requestResource(CachedResource::ImageResource, WTFMove(request), error, ForPreload::No, defer).get());
200199}
201200
202 CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourceRequest&& request, bool isSVG)
 201CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourceRequest&& request, bool isSVG, ResourceError* error)
203202{
204203#if ENABLE(SVG_FONTS)
205204 if (isSVG)
206  return downcast<CachedSVGFont>(requestResource(CachedResource::SVGFontResource, WTFMove(request)).get());
 205 return downcast<CachedSVGFont>(requestResource(CachedResource::SVGFontResource, WTFMove(request), error).get());
207206#else
208207 UNUSED_PARAM(isSVG);
209208#endif
210  return downcast<CachedFont>(requestResource(CachedResource::FontResource, WTFMove(request)).get());
 209 return downcast<CachedFont>(requestResource(CachedResource::FontResource, WTFMove(request), error).get());
211210}
212211
213212#if ENABLE(VIDEO_TRACK)
214 CachedResourceHandle<CachedTextTrack> CachedResourceLoader::requestTextTrack(CachedResourceRequest&& request)
 213CachedResourceHandle<CachedTextTrack> CachedResourceLoader::requestTextTrack(CachedResourceRequest&& request, ResourceError* error)
215214{
216  return downcast<CachedTextTrack>(requestResource(CachedResource::TextTrackResource, WTFMove(request)).get());
 215 return downcast<CachedTextTrack>(requestResource(CachedResource::TextTrackResource, WTFMove(request), error).get());
217216}
218217#endif
219218
220 CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestCSSStyleSheet(CachedResourceRequest&& request)
 219CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestCSSStyleSheet(CachedResourceRequest&& request, ResourceError* error)
221220{
222  return downcast<CachedCSSStyleSheet>(requestResource(CachedResource::CSSStyleSheet, WTFMove(request)).get());
 221 return downcast<CachedCSSStyleSheet>(requestResource(CachedResource::CSSStyleSheet, WTFMove(request), error).get());
223222}
224223
225 CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSStyleSheet(CachedResourceRequest&& request)
 224CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSStyleSheet(CachedResourceRequest&& request, ResourceError*)
226225{
227226 ASSERT(document());
228227 request.setDomainForCachePartition(*document());

@@CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSSt
248247 return userSheet;
249248}
250249
251 CachedResourceHandle<CachedScript> CachedResourceLoader::requestScript(CachedResourceRequest&& request)
 250CachedResourceHandle<CachedScript> CachedResourceLoader::requestScript(CachedResourceRequest&& request, ResourceError* error)
252251{
253  return downcast<CachedScript>(requestResource(CachedResource::Script, WTFMove(request)).get());
 252 return downcast<CachedScript>(requestResource(CachedResource::Script, WTFMove(request), error).get());
254253}
255254
256255#if ENABLE(XSLT)
257 CachedResourceHandle<CachedXSLStyleSheet> CachedResourceLoader::requestXSLStyleSheet(CachedResourceRequest&& request)
 256CachedResourceHandle<CachedXSLStyleSheet> CachedResourceLoader::requestXSLStyleSheet(CachedResourceRequest&& request, ResourceError* error)
258257{
259  return downcast<CachedXSLStyleSheet>(requestResource(CachedResource::XSLStyleSheet, WTFMove(request)).get());
 258 return downcast<CachedXSLStyleSheet>(requestResource(CachedResource::XSLStyleSheet, WTFMove(request), error).get());
260259}
261260#endif
262261
263 CachedResourceHandle<CachedSVGDocument> CachedResourceLoader::requestSVGDocument(CachedResourceRequest&& request)
 262CachedResourceHandle<CachedSVGDocument> CachedResourceLoader::requestSVGDocument(CachedResourceRequest&& request, ResourceError* error)
264263{
265  return downcast<CachedSVGDocument>(requestResource(CachedResource::SVGDocumentResource, WTFMove(request)).get());
 264 return downcast<CachedSVGDocument>(requestResource(CachedResource::SVGDocumentResource, WTFMove(request), error).get());
266265}
267266
268267#if ENABLE(LINK_PREFETCH)
269 CachedResourceHandle<CachedResource> CachedResourceLoader::requestLinkResource(CachedResource::Type type, CachedResourceRequest&& request)
 268CachedResourceHandle<CachedResource> CachedResourceLoader::requestLinkResource(CachedResource::Type type, CachedResourceRequest&& request, ResourceError* error)
270269{
271270 ASSERT(frame());
272271 ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkSubresource);
273  return requestResource(type, WTFMove(request));
 272 return requestResource(type, WTFMove(request), error);
274273}
275274#endif
276275
277 CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestMedia(CachedResourceRequest&& request)
 276CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestMedia(CachedResourceRequest&& request, ResourceError* error)
278277{
279  return downcast<CachedRawResource>(requestResource(CachedResource::MediaResource, WTFMove(request)).get());
 278 return downcast<CachedRawResource>(requestResource(CachedResource::MediaResource, WTFMove(request), error).get());
280279}
281280
282 CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestIcon(CachedResourceRequest&& request)
 281CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestIcon(CachedResourceRequest&& request, ResourceError* error)
283282{
284  return downcast<CachedRawResource>(requestResource(CachedResource::Icon, WTFMove(request)).get());
 283 return downcast<CachedRawResource>(requestResource(CachedResource::Icon, WTFMove(request), error).get());
285284}
286285
287 CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestRawResource(CachedResourceRequest&& request)
 286CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestRawResource(CachedResourceRequest&& request, ResourceError* error)
288287{
289  return downcast<CachedRawResource>(requestResource(CachedResource::RawResource, WTFMove(request)).get());
 288 return downcast<CachedRawResource>(requestResource(CachedResource::RawResource, WTFMove(request), error).get());
290289}
291290
292 CachedResourceHandle<CachedResource> CachedResourceLoader::requestBeaconResource(CachedResourceRequest&& request)
 291CachedResourceHandle<CachedResource> CachedResourceLoader::requestBeaconResource(CachedResourceRequest&& request, ResourceError* error)
293292{
294  return requestResource(CachedResource::Beacon, WTFMove(request)).get();
 293 return requestResource(CachedResource::Beacon, WTFMove(request), error).get();
295294}
296295
297 CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestMainResource(CachedResourceRequest&& request)
 296CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestMainResource(CachedResourceRequest&& request, ResourceError* error)
298297{
299  return downcast<CachedRawResource>(requestResource(CachedResource::MainResource, WTFMove(request)).get());
 298 return downcast<CachedRawResource>(requestResource(CachedResource::MainResource, WTFMove(request), error).get());
300299}
301300
302301static MixedContentChecker::ContentType contentTypeFromResourceType(CachedResource::Type type)

@@void CachedResourceLoader::updateHTTPRequestHeaders(CachedResource::Type type, C
689688 request.updateAccordingCacheMode();
690689}
691690
692 CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ForPreload forPreload, DeferOption defer)
 691CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ResourceError* error, ForPreload forPreload, DeferOption defer)
693692{
694693 if (Document* document = this->document())
695694 request.upgradeInsecureRequestIfNeeded(*document);

@@CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
700699
701700 if (!url.isValid()) {
702701 RELEASE_LOG_IF_ALLOWED("requestResource: URL is invalid (frame = %p)", frame());
 702 if (error)
 703 *error = { errorDomainWebKitInternal, 0, url, ASCIILiteral("URL is invalid") };
703704 return nullptr;
704705 }
705706

@@CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
708709 // We are passing url as well as request, as request url may contain a fragment identifier.
709710 if (!canRequest(type, url, request, forPreload)) {
710711 RELEASE_LOG_IF_ALLOWED("requestResource: Not allowed to request resource (frame = %p)", frame());
 712 if (error)
 713 *error = { errorDomainWebKitInternal, 0, url, ASCIILiteral("Not allowed to request resource"), ResourceError::Type::AccessControl };
711714 return nullptr;
712715 }
713716

@@CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
725728 resource->setResourceError(ResourceError(ContentExtensions::WebKitContentBlockerDomain, 0, resourceRequest.url(), WEB_UI_STRING("The URL was blocked by a content blocker", "WebKitErrorBlockedByContentBlocker description")));
726729 return resource;
727730 }
 731 if (error)
 732 *error = { errorDomainWebKitInternal, 0, url, ASCIILiteral("Resource blocked by content blocker"), ResourceError::Type::AccessControl };
728733 return nullptr;
729734 }
730735 if (blockedStatus.madeHTTPS

@@CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache
823828 }
824829
825830 if ((policy != Use || resource->stillNeedsLoad()) && defer == DeferOption::NoDefer) {
 831 if (resource->options().keepAlive && !m_keepaliveRequestTracker.canLoadRequest(*resource)) {
 832 if (error)
 833 *error = { errorDomainWebKitInternal, 0, url, ASCIILiteral("Reached maximum amount of queued data of 64Kb for keepalive requests") };
 834 return nullptr;
 835 }
 836
826837 resource->load(*this);
827838
828839 // We don't support immediate loads, but we do support immediate failure.
829840 if (resource->errorOccurred()) {
830841 if (resource->allowsCaching() && resource->inCache())
831842 memoryCache.remove(*resource);
 843 if (error)
 844 *error = resource->resourceError();
832845 return nullptr;
833846 }
 847
 848 if (resource->options().keepAlive)
 849 m_keepaliveRequestTracker.registerRequest(*resource);
834850 }
835851
836852 if (document() && !document()->loadEventFinished() && !resource->resourceRequest().url().protocolIsData())

@@CachedResourceHandle<CachedResource> CachedResourceLoader::preload(CachedResourc
12451261 if (request.charset().isEmpty() && (type == CachedResource::Script || type == CachedResource::CSSStyleSheet))
12461262 request.setCharset(m_document->charset());
12471263
1248  CachedResourceHandle<CachedResource> resource = requestResource(type, WTFMove(request), ForPreload::Yes);
 1264 CachedResourceHandle<CachedResource> resource = requestResource(type, WTFMove(request), nullptr, ForPreload::Yes);
12491265 if (resource && (!m_preloads || !m_preloads->contains(resource.get()))) {
12501266 // Fonts need special treatment since just creating the resource doesn't trigger a load.
12511267 if (type == CachedResource::FontResource)

Source/WebCore/loader/cache/CachedResourceLoader.h

3030#include "CachedResourceHandle.h"
3131#include "CachedResourceRequest.h"
3232#include "ContentSecurityPolicy.h"
 33#include "KeepaliveRequestTracker.h"
3334#include "ResourceTimingInformation.h"
3435#include "Timer.h"
3536#include <wtf/HashMap.h>

@@public:
7172 static Ref<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(*new CachedResourceLoader(documentLoader)); }
7273 ~CachedResourceLoader();
7374
74  CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&&);
75  CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&&);
76  CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&&);
77  CachedResourceHandle<CachedScript> requestScript(CachedResourceRequest&&);
78  CachedResourceHandle<CachedFont> requestFont(CachedResourceRequest&&, bool isSVG);
79  CachedResourceHandle<CachedRawResource> requestMedia(CachedResourceRequest&&);
80  CachedResourceHandle<CachedRawResource> requestIcon(CachedResourceRequest&&);
81  CachedResourceHandle<CachedResource> requestBeaconResource(CachedResourceRequest&&);
82  CachedResourceHandle<CachedRawResource> requestRawResource(CachedResourceRequest&&);
83  CachedResourceHandle<CachedRawResource> requestMainResource(CachedResourceRequest&&);
84  CachedResourceHandle<CachedSVGDocument> requestSVGDocument(CachedResourceRequest&&);
 75 CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&&, ResourceError* = nullptr);
 76 CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&&, ResourceError* = nullptr);
 77 CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&&, ResourceError* = nullptr);
 78 CachedResourceHandle<CachedScript> requestScript(CachedResourceRequest&&, ResourceError* = nullptr);
 79 CachedResourceHandle<CachedFont> requestFont(CachedResourceRequest&&, bool isSVG, ResourceError* = nullptr);
 80 CachedResourceHandle<CachedRawResource> requestMedia(CachedResourceRequest&&, ResourceError* = nullptr);
 81 CachedResourceHandle<CachedRawResource> requestIcon(CachedResourceRequest&&, ResourceError* = nullptr);
 82 CachedResourceHandle<CachedResource> requestBeaconResource(CachedResourceRequest&&, ResourceError* = nullptr);
 83 CachedResourceHandle<CachedRawResource> requestRawResource(CachedResourceRequest&&, ResourceError* = nullptr);
 84 CachedResourceHandle<CachedRawResource> requestMainResource(CachedResourceRequest&&, ResourceError* = nullptr);
 85 CachedResourceHandle<CachedSVGDocument> requestSVGDocument(CachedResourceRequest&&, ResourceError* = nullptr);
8586#if ENABLE(XSLT)
86  CachedResourceHandle<CachedXSLStyleSheet> requestXSLStyleSheet(CachedResourceRequest&&);
 87 CachedResourceHandle<CachedXSLStyleSheet> requestXSLStyleSheet(CachedResourceRequest&&, ResourceError* = nullptr);
8788#endif
8889#if ENABLE(LINK_PREFETCH)
89  CachedResourceHandle<CachedResource> requestLinkResource(CachedResource::Type, CachedResourceRequest&&);
 90 CachedResourceHandle<CachedResource> requestLinkResource(CachedResource::Type, CachedResourceRequest&&, ResourceError* = nullptr);
9091#endif
9192#if ENABLE(VIDEO_TRACK)
92  CachedResourceHandle<CachedTextTrack> requestTextTrack(CachedResourceRequest&&);
 93 CachedResourceHandle<CachedTextTrack> requestTextTrack(CachedResourceRequest&&, ResourceError* = nullptr);
9394#endif
9495
9596 // Logs an access denied message to the console for the specified URL.

@@private:
152153 enum class ForPreload { Yes, No };
153154 enum class DeferOption { NoDefer, DeferredByClient };
154155
155  CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&&, ForPreload = ForPreload::No, DeferOption = DeferOption::NoDefer);
 156 CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&&, ResourceError* = nullptr, ForPreload = ForPreload::No, DeferOption = DeferOption::NoDefer);
156157 CachedResourceHandle<CachedResource> revalidateResource(CachedResourceRequest&&, CachedResource&);
157158 CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, CachedResourceRequest&&);
158159

@@private:
193194 Timer m_garbageCollectDocumentResourcesTimer;
194195
195196 ResourceTimingInformation m_resourceTimingInfo;
 197 KeepaliveRequestTracker m_keepaliveRequestTracker;
196198
197199 // 29 bits left
198200 bool m_autoLoadImages : 1;

Source/WebCore/loader/cache/KeepaliveRequestTracker.cpp

 1/*
 2 * Copyright (C) 2017 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "KeepaliveRequestTracker.h"
 28
 29namespace WebCore {
 30
 31const uint64_t maxInflightKeepaliveBytes { 65536 }; // 64 kibibytes as per Fetch specification.
 32
 33KeepaliveRequestTracker::~KeepaliveRequestTracker()
 34{
 35 auto inflightRequests = WTFMove(m_inflightKeepaliveRequests);
 36 for (auto& resource : inflightRequests)
 37 resource->removeClient(*this);
 38}
 39
 40bool KeepaliveRequestTracker::canLoadRequest(CachedResource& resource)
 41{
 42 ASSERT(resource.options().keepAlive);
 43 auto* body = resource.resourceRequest().httpBody();
 44 if (!body)
 45 return true;
 46
 47 uint64_t bodySize = body->lengthInBytes();
 48 return m_inflightKeepaliveBytes + bodySize <= maxInflightKeepaliveBytes;
 49}
 50
 51void KeepaliveRequestTracker::registerRequest(CachedResource& resource)
 52{
 53 ASSERT(resource.options().keepAlive);
 54 auto* body = resource.resourceRequest().httpBody();
 55 if (!body)
 56 return;
 57 ASSERT(!m_inflightKeepaliveRequests.contains(&resource));
 58 m_inflightKeepaliveRequests.append(&resource);
 59 m_inflightKeepaliveBytes += body->lengthInBytes();
 60 ASSERT(m_inflightKeepaliveBytes <= maxInflightKeepaliveBytes);
 61
 62 resource.addClient(*this);
 63}
 64
 65void KeepaliveRequestTracker::responseReceived(CachedResource& resource, const ResourceResponse&)
 66{
 67 // Per Fetch specification, allocated quota should be returned before the promise is resolved,
 68 // which is when the response is received.
 69 unregisterRequest(resource);
 70}
 71
 72void KeepaliveRequestTracker::notifyFinished(CachedResource& resource)
 73{
 74 unregisterRequest(resource);
 75}
 76
 77void KeepaliveRequestTracker::unregisterRequest(CachedResource& resource)
 78{
 79 ASSERT(resource.options().keepAlive);
 80 resource.removeClient(*this);
 81 bool wasRemoved = m_inflightKeepaliveRequests.removeFirst(&resource);
 82 ASSERT_UNUSED(wasRemoved, wasRemoved);
 83 m_inflightKeepaliveBytes -= resource.resourceRequest().httpBody()->lengthInBytes();
 84 ASSERT(m_inflightKeepaliveBytes <= maxInflightKeepaliveBytes);
 85}
 86
 87}

Source/WebCore/loader/cache/KeepaliveRequestTracker.h

 1/*
 2 * Copyright (C) 2017 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "CachedRawResourceClient.h"
 29#include "CachedResource.h"
 30#include "CachedResourceHandle.h"
 31#include <wtf/Forward.h>
 32
 33namespace WebCore {
 34
 35class KeepaliveRequestTracker final : public CachedRawResourceClient {
 36public:
 37 ~KeepaliveRequestTracker();
 38 bool canLoadRequest(CachedResource&);
 39 void registerRequest(CachedResource&);
 40
 41 // CachedRawResourceClient.
 42 void responseReceived(CachedResource&, const ResourceResponse&) final;
 43 void notifyFinished(CachedResource&) final;
 44
 45private:
 46 void unregisterRequest(CachedResource&);
 47
 48 Vector<CachedResourceHandle<CachedResource>> m_inflightKeepaliveRequests;
 49 uint64_t m_inflightKeepaliveBytes { 0 };
 50};
 51
 52}

Source/WebCore/platform/network/FormData.cpp

@@Ref<FormData> FormData::isolatedCopy() const
124124 return formData;
125125}
126126
 127size_t FormDataElement::lengthInBytes() const
 128{
 129 switch (m_type) {
 130 case Type::Data:
 131 return m_data.size();
 132 case Type::EncodedFile: {
 133 if (m_fileLength != BlobDataItem::toEndOfFile)
 134 return m_fileLength;
 135 long long fileSize;
 136 if (getFileSize(m_shouldGenerateFile ? m_generatedFilename : m_filename, fileSize))
 137 return fileSize;
 138 return 0;
 139 }
 140 case Type::EncodedBlob: {
 141 if (!blobRegistry().isBlobRegistryImpl())
 142 return 0;
 143 auto* blobData = static_cast<BlobRegistryImpl&>(blobRegistry()).getBlobDataFromURL(m_url);
 144 if (!blobData)
 145 return 0;
 146 size_t length = 0;
 147 for (auto& blobDataItem : blobData->items())
 148 length += (blobDataItem.length() - blobDataItem.offset());
 149 return length;
 150 }
 151 }
 152 ASSERT_NOT_REACHED();
 153 return 0;
 154}
 155
127156FormDataElement FormDataElement::isolatedCopy() const
128157{
129158 switch (m_type) {

@@void FormData::removeGeneratedFilesIfNeeded()
386415 }
387416}
388417
 418size_t FormData::lengthInBytes() const
 419{
 420 size_t length = 0;
 421 for (auto& element : m_elements)
 422 length += element.lengthInBytes();
 423 return length;
 424}
 425
389426} // namespace WebCore

Source/WebCore/platform/network/FormData.h

@@public:
6969 {
7070 }
7171
 72 size_t lengthInBytes() const;
 73
7274 FormDataElement isolatedCopy() const;
7375
7476 template<typename Encoder>

@@public:
254256 return FormURLEncoded;
255257 }
256258
 259 size_t lengthInBytes() const;
 260
257261private:
258262 FormData();
259263 FormData(const FormData&);