Changeset 220442 in webkit
- Timestamp:
- Aug 8, 2017 10:15:47 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 17 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r220436 r220442 1 2017-08-08 Chris Dumez <cdumez@apple.com> 2 3 [Beacon] Add support for CORS-preflighting for WK2 / NETWORK_SESSION 4 https://bugs.webkit.org/show_bug.cgi?id=175264 5 <rdar://problem/33547793> 6 7 Reviewed by Youenn Fablet. 8 9 Add layout test coverage. 10 11 * http/wpt/beacon/cors/cors-preflight-arraybufferview-failure-expected.txt: Added. 12 * http/wpt/beacon/cors/cors-preflight-arraybufferview-failure.html: Added. 13 * http/wpt/beacon/cors/cors-preflight-arraybufferview-success-expected.txt: Added. 14 * http/wpt/beacon/cors/cors-preflight-arraybufferview-success.html: Added. 15 * http/wpt/beacon/cors/cors-preflight-blob-failure-expected.txt: Added. 16 * http/wpt/beacon/cors/cors-preflight-blob-failure.html: Added. 17 * http/wpt/beacon/cors/cors-preflight-blob-success-expected.txt: Added. 18 * http/wpt/beacon/cors/cors-preflight-blob-success.html: Added. 19 * http/wpt/beacon/cors/cors-preflight-cookie-expected.txt: Added. 20 * http/wpt/beacon/cors/cors-preflight-cookie.html: Added. 21 * http/wpt/beacon/resources/beacon-preflight.py: Added. 22 (respondToCORSPreflight): 23 (main): 24 * http/wpt/beacon/resources/set-cookie.py: Added. 25 (main): 26 * platform/mac-wk1/TestExpectations: 27 * platform/mac-wk2/TestExpectations: 28 * platform/win/TestExpectations: 29 1 30 2017-08-08 Devin Rousso <drousso@apple.com> 2 31 -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r220428 r220442 361 361 webkit.org/b/170877 [ Debug ] webgl/1.0.2/conformance/glsl/misc/shader-with-reserved-words.html [ Pass Timeout ] 362 362 363 # CORS-preflighting for Beacon is not supported on WK1. 364 webkit.org/b/175330 http/wpt/beacon/cors/ [ Skip ] 365 363 366 # This was a WK2-only fix. 364 367 http/tests/css/filters-on-iframes.html [ Skip ] -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r220419 r220442 723 723 webkit.org/b/172834 [ ElCapitan ] imported/w3c/web-platform-tests/IndexedDB/idbobjectstore_getAllKeys.html [ Pass Failure ] 724 724 725 726 # CORS-preflighting for Beacon is not supported on WK2 for non NETWORK_SESSION code path. 727 webkit.org/b/175330 [ ElCapitan ] http/wpt/beacon/cors/ [ Skip ] 728 725 729 webkit.org/b/172201 webaudio/silent-audio-interrupted-in-background.html [ Pass Timeout ] 726 730 -
trunk/LayoutTests/platform/win/TestExpectations
r220436 r220442 4048 4048 webkit.org/b/174079 fast/text/variations/skia-postscript-name.html [ ImageOnlyFailure ] 4049 4049 4050 # CORS-preflighting for Beacon is not supported on WK1. 4051 webkit.org/b/175330 http/wpt/beacon/cors/ [ Skip ] 4052 4050 4053 # Async image tests are currently failing on Windows. 4051 4054 webkit.org/b/174653 fast/images/async-image-background-image-repeated.html [ Timeout ] -
trunk/Source/WebCore/ChangeLog
r220440 r220442 1 2017-08-08 Chris Dumez <cdumez@apple.com> 2 3 [Beacon] Add support for CORS-preflighting for WK2 / NETWORK_SESSION 4 https://bugs.webkit.org/show_bug.cgi?id=175264 5 <rdar://problem/33547793> 6 7 Reviewed by Youenn Fablet. 8 9 Pass additional information when creating a PingHandle so that the PingLoad 10 can deal with CORS-preflighting on Network process side. 11 12 Tests: http/wpt/beacon/cors/cors-preflight-arraybufferview-failure.html 13 http/wpt/beacon/cors/cors-preflight-arraybufferview-success.html 14 http/wpt/beacon/cors/cors-preflight-blob-failure.html 15 http/wpt/beacon/cors/cors-preflight-blob-success.html 16 http/wpt/beacon/cors/cors-preflight-cookie.html 17 18 * WebCore.xcodeproj/project.pbxproj: 19 * loader/CrossOriginAccessControl.cpp: 20 (WebCore::validatePreflightResponse): 21 * loader/CrossOriginAccessControl.h: 22 * loader/CrossOriginPreflightChecker.cpp: 23 (WebCore::CrossOriginPreflightChecker::validatePreflightResponse): 24 * loader/CrossOriginPreflightResultCache.h: 25 * loader/LoaderStrategy.h: 26 * loader/PingLoader.cpp: 27 (WebCore::PingLoader::loadImage): 28 (WebCore::PingLoader::sendPing): 29 (WebCore::PingLoader::sendViolationReport): 30 (WebCore::PingLoader::startPingLoad): 31 * loader/PingLoader.h: 32 * loader/cache/CachedResource.cpp: 33 (WebCore::CachedResource::load): 34 * page/SecurityOrigin.h: 35 1 36 2017-08-08 Sam Weinig <sam@webkit.org> 2 37 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r220433 r220442 6643 6643 E1C415DA0F655D6F0092D2FB /* CrossOriginPreflightResultCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6644 6644 E1C415DE0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */; }; 6645 E1C416120F6562FD0092D2FB /* CrossOriginAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C416110F6562FD0092D2FB /* CrossOriginAccessControl.h */; };6645 E1C416120F6562FD0092D2FB /* CrossOriginAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C416110F6562FD0092D2FB /* CrossOriginAccessControl.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6646 6646 E1C416170F6563180092D2FB /* CrossOriginAccessControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C416160F6563180092D2FB /* CrossOriginAccessControl.cpp */; }; 6647 6647 E1C4DE690EA75C1E0023CCD6 /* ActiveDOMObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; -
trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp
r219595 r220442 28 28 #include "CrossOriginAccessControl.h" 29 29 30 #include "CrossOriginPreflightResultCache.h" 30 31 #include "HTTPHeaderNames.h" 31 32 #include "HTTPParsers.h" … … 157 158 } 158 159 160 bool validatePreflightResponse(const ResourceRequest& request, const ResourceResponse& response, StoredCredentials includeCredentials, SecurityOrigin& securityOrigin, String& errorDescription) 161 { 162 if (!response.isSuccessful()) { 163 errorDescription = ASCIILiteral("Preflight response is not successful"); 164 return false; 165 } 166 167 if (!passesAccessControlCheck(response, includeCredentials, securityOrigin, errorDescription)) 168 return false; 169 170 auto result = std::make_unique<CrossOriginPreflightResultCacheItem>(includeCredentials); 171 if (!result->parse(response, errorDescription) 172 || !result->allowsCrossOriginMethod(request.httpMethod(), errorDescription) 173 || !result->allowsCrossOriginHeaders(request.httpHeaderFields(), errorDescription)) { 174 return false; 175 } 176 177 CrossOriginPreflightResultCache::singleton().appendEntry(securityOrigin.toString(), request.url(), WTFMove(result)); 178 return true; 179 } 180 159 181 } // namespace WebCore -
trunk/Source/WebCore/loader/CrossOriginAccessControl.h
r219595 r220442 42 42 43 43 void updateRequestForAccessControl(ResourceRequest&, SecurityOrigin&, StoredCredentials); 44 ResourceRequest createAccessControlPreflightRequest(const ResourceRequest&, SecurityOrigin&, const String&);44 WEBCORE_EXPORT ResourceRequest createAccessControlPreflightRequest(const ResourceRequest&, SecurityOrigin&, const String&); 45 45 46 46 bool isValidCrossOriginRedirectionURL(const URL&); 47 47 void cleanRedirectedRequestForAccessControl(ResourceRequest&); 48 48 49 bool passesAccessControlCheck(const ResourceResponse&, StoredCredentials, SecurityOrigin&, String& errorDescription); 49 WEBCORE_EXPORT bool passesAccessControlCheck(const ResourceResponse&, StoredCredentials, SecurityOrigin&, String& errorDescription); 50 WEBCORE_EXPORT bool validatePreflightResponse(const ResourceRequest&, const ResourceResponse&, StoredCredentials, SecurityOrigin&, String& errorDescription); 50 51 51 52 } // namespace WebCore -
trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp
r219051 r220442 61 61 void CrossOriginPreflightChecker::validatePreflightResponse(DocumentThreadableLoader& loader, ResourceRequest&& request, unsigned long identifier, const ResourceResponse& response) 62 62 { 63 Frame* frame = loader.document().frame(); 64 ASSERT(frame); 65 66 if (!response.isSuccessful()) { 67 loader.preflightFailure(identifier, ResourceError(errorDomainWebKitInternal, 0, request.url(), ASCIILiteral("Preflight response is not successful"), ResourceError::Type::AccessControl)); 63 String errorDescription; 64 if (!WebCore::validatePreflightResponse(request, response, loader.options().allowCredentials, loader.securityOrigin(), errorDescription)) { 65 loader.preflightFailure(identifier, ResourceError(errorDomainWebKitInternal, 0, request.url(), errorDescription, ResourceError::Type::AccessControl)); 68 66 return; 69 67 } 70 68 71 String description; 72 if (!passesAccessControlCheck(response, loader.options().allowCredentials, loader.securityOrigin(), description)) { 73 loader.preflightFailure(identifier, ResourceError(errorDomainWebKitInternal, 0, request.url(), description, ResourceError::Type::AccessControl)); 74 return; 75 } 76 77 auto result = std::make_unique<CrossOriginPreflightResultCacheItem>(loader.options().allowCredentials); 78 if (!result->parse(response, description) 79 || !result->allowsCrossOriginMethod(request.httpMethod(), description) 80 || !result->allowsCrossOriginHeaders(request.httpHeaderFields(), description)) { 81 loader.preflightFailure(identifier, ResourceError(errorDomainWebKitInternal, 0, request.url(), description, ResourceError::Type::AccessControl)); 82 return; 83 } 69 Frame* frame = loader.document().frame(); 70 ASSERT(frame); 84 71 85 72 // FIXME: <https://webkit.org/b/164889> Web Inspector: Show Preflight Request information in inspector … … 90 77 InspectorInstrumentation::didFinishLoading(frame, frame->loader().documentLoader(), identifier, emptyMetrics, nullptr); 91 78 92 CrossOriginPreflightResultCache::singleton().appendEntry(loader.securityOrigin().toString(), request.url(), WTFMove(result));93 79 loader.preflightSuccess(WTFMove(request)); 94 80 } -
trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h
r208646 r220442 47 47 } 48 48 49 bool parse(const ResourceResponse&, String& errorDescription);50 bool allowsCrossOriginMethod(const String&, String& errorDescription) const;51 bool allowsCrossOriginHeaders(const HTTPHeaderMap&, String& errorDescription) const;49 WEBCORE_EXPORT bool parse(const ResourceResponse&, String& errorDescription); 50 WEBCORE_EXPORT bool allowsCrossOriginMethod(const String&, String& errorDescription) const; 51 WEBCORE_EXPORT bool allowsCrossOriginHeaders(const HTTPHeaderMap&, String& errorDescription) const; 52 52 bool allowsRequest(StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders) const; 53 53 … … 68 68 WEBCORE_EXPORT static CrossOriginPreflightResultCache& singleton(); 69 69 70 void appendEntry(const String& origin, const URL&, std::unique_ptr<CrossOriginPreflightResultCacheItem>);71 bool canSkipPreflight(const String& origin, const URL&, StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders);70 WEBCORE_EXPORT void appendEntry(const String& origin, const URL&, std::unique_ptr<CrossOriginPreflightResultCacheItem>); 71 WEBCORE_EXPORT bool canSkipPreflight(const String& origin, const URL&, StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders); 72 72 73 73 WEBCORE_EXPORT void empty(); -
trunk/Source/WebCore/loader/LoaderStrategy.h
r215065 r220442 43 43 class ResourceRequest; 44 44 class ResourceResponse; 45 class SecurityOrigin; 45 46 class SharedBuffer; 46 47 class SubresourceLoader; 47 48 class URL; 49 50 struct FetchOptions; 48 51 49 52 class WEBCORE_EXPORT LoaderStrategy { … … 60 63 virtual void resumePendingRequests() = 0; 61 64 62 virtual void createPingHandle(NetworkingContext*, ResourceRequest&, bool shouldUseCredentialStorage, bool shouldFollowRedirects) = 0;65 virtual void createPingHandle(NetworkingContext*, ResourceRequest&, Ref<SecurityOrigin>&& sourceOrigin, const FetchOptions&) = 0; 63 66 64 67 virtual void storeDerivedDataToCache(const SHA1::Digest& bodyKey, const String& type, const String& partition, WebCore::SharedBuffer&) = 0; -
trunk/Source/WebCore/loader/PingLoader.cpp
r220303 r220442 104 104 frame.loader().addExtraFieldsToSubresourceRequest(request); 105 105 106 startPingLoad(frame, request, ShouldFollowRedirects::Yes);106 startPingLoad(frame, request, document.securityOrigin(), ShouldFollowRedirects::Yes); 107 107 } 108 108 … … 140 140 } 141 141 142 startPingLoad(frame, request, ShouldFollowRedirects::Yes);142 startPingLoad(frame, request, sourceOrigin, ShouldFollowRedirects::Yes); 143 143 } 144 144 … … 177 177 request.setHTTPReferrer(referrer); 178 178 179 startPingLoad(frame, request, ShouldFollowRedirects::No);180 } 181 182 void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request, S houldFollowRedirects shouldFollowRedirects)179 startPingLoad(frame, request, document.securityOrigin(), ShouldFollowRedirects::No); 180 } 181 182 void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request, SecurityOrigin& sourceOrigin, ShouldFollowRedirects shouldFollowRedirects) 183 183 { 184 184 unsigned long identifier = frame.page()->progress().createUniqueIdentifier(); … … 189 189 // DocumentLoader. 190 190 bool shouldUseCredentialStorage = frame.loader().client().shouldUseCredentialStorage(frame.loader().activeDocumentLoader(), identifier); 191 FetchOptions options; 192 options.credentials = shouldUseCredentialStorage ? FetchOptions::Credentials::Include : FetchOptions::Credentials::Omit; 193 options.redirect = shouldFollowRedirects == ShouldFollowRedirects::Yes ? FetchOptions::Redirect::Follow : FetchOptions::Redirect::Error; 191 194 192 195 InspectorInstrumentation::continueAfterPingLoader(frame, identifier, frame.loader().activeDocumentLoader(), request, ResourceResponse()); 193 196 194 platformStrategies()->loaderStrategy()->createPingHandle(frame.loader().networkingContext(), request, s houldUseCredentialStorage, shouldFollowRedirects == ShouldFollowRedirects::Yes);195 } 196 197 } 197 platformStrategies()->loaderStrategy()->createPingHandle(frame.loader().networkingContext(), request, sourceOrigin, options); 198 } 199 200 } -
trunk/Source/WebCore/loader/PingLoader.h
r220303 r220442 42 42 class URL; 43 43 class ResourceRequest; 44 class SecurityOrigin; 44 45 45 46 enum class ViolationReportType { … … 56 57 private: 57 58 enum class ShouldFollowRedirects { No, Yes }; 58 static void startPingLoad(Frame&, ResourceRequest&, S houldFollowRedirects);59 static void startPingLoad(Frame&, ResourceRequest&, SecurityOrigin& sourceOrigin, ShouldFollowRedirects); 59 60 }; 60 61 -
trunk/Source/WebCore/loader/cache/CachedResource.cpp
r220320 r220442 262 262 // FIXME: We should not special-case Beacon here. 263 263 if (m_options.keepAlive && type() == CachedResource::Beacon) { 264 platformStrategies()->loaderStrategy()->createPingHandle(frame.loader().networkingContext(), request, m_options.credentials == FetchOptions::Credentials::Include, m_options.redirect == FetchOptions::Redirect::Follow); 264 ASSERT(m_origin); 265 platformStrategies()->loaderStrategy()->createPingHandle(frame.loader().networkingContext(), request, *m_origin, m_options); 265 266 return; 266 267 } -
trunk/Source/WebCore/page/SecurityOrigin.h
r218028 r220442 98 98 // the given URL. For example, call this function before issuing 99 99 // XMLHttpRequests. 100 bool canRequest(const URL&) const;100 WEBCORE_EXPORT bool canRequest(const URL&) const; 101 101 102 102 // Returns true if this SecurityOrigin can receive drag content from the -
trunk/Source/WebKit/CMakeLists.txt
r220403 r220442 101 101 NetworkProcess/FileAPI/NetworkBlobRegistry.cpp 102 102 103 NetworkProcess/NetworkCORSPreflightChecker.cpp 103 104 NetworkProcess/NetworkConnectionToWebProcess.cpp 104 105 NetworkProcess/NetworkDataTask.cpp … … 112 113 NetworkProcess/NetworkSession.cpp 113 114 NetworkProcess/NetworkSocketStream.cpp 115 NetworkProcess/PingLoad.cpp 114 116 115 117 NetworkProcess/cache/NetworkCache.cpp -
trunk/Source/WebKit/ChangeLog
r220435 r220442 1 2017-08-08 Chris Dumez <cdumez@apple.com> 2 3 [Beacon] Add support for CORS-preflighting for WK2 / NETWORK_SESSION 4 https://bugs.webkit.org/show_bug.cgi?id=175264 5 <rdar://problem/33547793> 6 7 Reviewed by Youenn Fablet. 8 9 Implement CORS-preflighting for beacons with a payload that has a non 10 safelisted MIME type, as per: 11 - https://w3c.github.io/beacon/#privacy 12 - https://www.w3.org/TR/beacon/#sec-processing-model 13 14 CORS-preflighting is completely handled on Network Process side because 15 a beacon request can outlive its page and therefore its WebContent 16 process. This requires us to pass a little more information to the 17 Network process, in particular the source origin and the corsMode. 18 19 The current implementation does not currently deal with CORS preflights 20 needed upon a redirect. This will be added in a follow-up. 21 22 * CMakeLists.txt: 23 * NetworkProcess/NetworkCORSPreflightChecker.cpp: Added. 24 (WebKit::NetworkCORSPreflightChecker::NetworkCORSPreflightChecker): 25 (WebKit::NetworkCORSPreflightChecker::~NetworkCORSPreflightChecker): 26 (WebKit::NetworkCORSPreflightChecker::startPreflight): 27 (WebKit::NetworkCORSPreflightChecker::willPerformHTTPRedirection): 28 (WebKit::NetworkCORSPreflightChecker::didReceiveChallenge): 29 (WebKit::NetworkCORSPreflightChecker::didReceiveResponseNetworkSession): 30 (WebKit::NetworkCORSPreflightChecker::didReceiveData): 31 (WebKit::NetworkCORSPreflightChecker::didCompleteWithError): 32 (WebKit::NetworkCORSPreflightChecker::didSendData): 33 (WebKit::NetworkCORSPreflightChecker::wasBlocked): 34 (WebKit::NetworkCORSPreflightChecker::cannotShowURL): 35 * NetworkProcess/NetworkCORSPreflightChecker.h: Added. 36 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 37 (WebKit::NetworkConnectionToWebProcess::loadPing): 38 * NetworkProcess/NetworkConnectionToWebProcess.h: 39 * NetworkProcess/NetworkResourceLoadParameters.cpp: 40 (WebKit::NetworkResourceLoadParameters::encode const): 41 (WebKit::NetworkResourceLoadParameters::decode): 42 * NetworkProcess/NetworkResourceLoadParameters.h: 43 * NetworkProcess/PingLoad.cpp: Added. 44 (WebKit::PingLoad::PingLoad): 45 (WebKit::PingLoad::~PingLoad): 46 (WebKit::PingLoad::startNetworkLoad): 47 (WebKit::PingLoad::willPerformHTTPRedirection): 48 (WebKit::PingLoad::didReceiveChallenge): 49 (WebKit::PingLoad::didReceiveResponseNetworkSession): 50 (WebKit::PingLoad::didReceiveData): 51 (WebKit::PingLoad::didCompleteWithError): 52 (WebKit::PingLoad::didSendData): 53 (WebKit::PingLoad::wasBlocked): 54 (WebKit::PingLoad::cannotShowURL): 55 (WebKit::PingLoad::timeoutTimerFired): 56 (WebKit::PingLoad::needsCORSPreflight const): 57 (WebKit::PingLoad::doCORSPreflight): 58 * NetworkProcess/PingLoad.h: 59 * WebKit.xcodeproj/project.pbxproj: 60 * WebProcess/Network/WebLoaderStrategy.cpp: 61 (WebKit::WebLoaderStrategy::createPingHandle): 62 * WebProcess/Network/WebLoaderStrategy.h: 63 1 64 2017-08-08 Megan Gardner <megan_gardner@apple.com> 2 65 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r220267 r220442 223 223 } 224 224 225 void NetworkConnectionToWebProcess::loadPing( const NetworkResourceLoadParameters& loadParameters)225 void NetworkConnectionToWebProcess::loadPing(NetworkResourceLoadParameters&& loadParameters) 226 226 { 227 227 #if USE(NETWORK_SESSION) 228 228 // PingLoad manages its own lifetime, deleting itself when its purpose has been fulfilled. 229 new PingLoad( loadParameters);229 new PingLoad(WTFMove(loadParameters)); 230 230 #else 231 231 RefPtr<NetworkingContext> context = RemoteNetworkingContext::create(loadParameters.sessionID, loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect); -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
r219328 r220442 83 83 void scheduleResourceLoad(const NetworkResourceLoadParameters&); 84 84 void performSynchronousLoad(const NetworkResourceLoadParameters&, Ref<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>&&); 85 void loadPing( const NetworkResourceLoadParameters&);85 void loadPing(NetworkResourceLoadParameters&&); 86 86 void prefetchDNS(const String&); 87 87 -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
r210835 r220442 30 30 #include "DataReference.h" 31 31 #include "WebCoreArgumentCoders.h" 32 #include <WebCore/SecurityOriginData.h> 32 33 33 34 using namespace WebCore; … … 82 83 encoder << maximumBufferingTime; 83 84 encoder << derivedCachedDataTypesToRetrieve; 85 86 encoder << static_cast<bool>(sourceOrigin); 87 if (sourceOrigin) 88 encoder << SecurityOriginData::fromSecurityOrigin(*sourceOrigin); 89 encoder.encodeEnum(mode); 84 90 } 85 91 … … 146 152 return false; 147 153 154 bool hasSourceOrigin; 155 if (!decoder.decode(hasSourceOrigin)) 156 return false; 157 if (hasSourceOrigin) { 158 SecurityOriginData sourceOriginData; 159 if (!decoder.decode(sourceOriginData)) 160 return false; 161 ASSERT(!sourceOriginData.isEmpty()); 162 result.sourceOrigin = sourceOriginData.securityOrigin(); 163 } 164 if (!decoder.decodeEnum(result.mode)) 165 return false; 166 148 167 return true; 149 168 } -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h
r215152 r220442 29 29 #include "NetworkLoadParameters.h" 30 30 #include "SandboxExtension.h" 31 #include <WebCore/FetchOptions.h> 31 32 #include <WebCore/ResourceHandle.h> 32 33 #include <WebCore/ResourceLoaderOptions.h> 33 34 #include <WebCore/ResourceRequest.h> 35 #include <WebCore/SecurityOrigin.h> 34 36 #include <WebCore/SessionID.h> 35 37 #include <wtf/Seconds.h> … … 54 56 Seconds maximumBufferingTime; 55 57 Vector<String> derivedCachedDataTypesToRetrieve; 58 RefPtr<WebCore::SecurityOrigin> sourceOrigin; 59 WebCore::FetchOptions::Mode mode; 56 60 }; 57 61 -
trunk/Source/WebKit/NetworkProcess/PingLoad.h
r215173 r220442 24 24 */ 25 25 26 #ifndef PingLoad_h 27 #define PingLoad_h 26 #pragma once 28 27 29 #include "AuthenticationManager.h" 28 #if USE(NETWORK_SESSION) 29 30 30 #include "NetworkDataTask.h" 31 #include " SessionTracker.h"31 #include "NetworkResourceLoadParameters.h" 32 32 33 33 namespace WebKit { 34 34 35 class NetworkCORSPreflightChecker; 36 35 37 class PingLoad final : private NetworkDataTaskClient { 36 38 public: 37 PingLoad(const NetworkResourceLoadParameters& parameters) 38 : m_timeoutTimer(*this, &PingLoad::timeoutTimerFired) 39 , m_shouldFollowRedirects(parameters.shouldFollowRedirects) 40 { 41 if (auto* networkSession = SessionTracker::networkSession(parameters.sessionID)) { 42 m_task = NetworkDataTask::create(*networkSession, *this, parameters); 43 m_task->resume(); 44 } else 45 ASSERT_NOT_REACHED(); 46 47 // If the server never responds, this object will hang around forever. 48 // Set a very generous timeout, just in case. 49 m_timeoutTimer.startOneShot(60000_s); 50 } 39 explicit PingLoad(NetworkResourceLoadParameters&&); 51 40 52 41 private: 53 void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&& request, RedirectCompletionHandler&& completionHandler) final 54 { 55 completionHandler(m_shouldFollowRedirects ? request : WebCore::ResourceRequest()); 56 } 57 void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&& completionHandler) final 58 { 59 completionHandler(AuthenticationChallengeDisposition::Cancel, { }); 60 delete this; 61 } 62 void didReceiveResponseNetworkSession(WebCore::ResourceResponse&&, ResponseCompletionHandler&& completionHandler) final 63 { 64 completionHandler(WebCore::PolicyAction::PolicyIgnore); 65 delete this; 66 } 67 void didReceiveData(Ref<WebCore::SharedBuffer>&&) final { ASSERT_NOT_REACHED(); } 68 void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&) final { delete this; } 69 void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) final { } 70 void wasBlocked() final { delete this; } 71 void cannotShowURL() final { delete this; } 42 ~PingLoad(); 72 43 73 void timeoutTimerFired() { delete this; } 44 void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&) final; 45 void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&) final; 46 void didReceiveResponseNetworkSession(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) final; 47 void didReceiveData(Ref<WebCore::SharedBuffer>&&) final; 48 void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&) final; 49 void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) final; 50 void wasBlocked() final; 51 void cannotShowURL() final; 52 void timeoutTimerFired(); 53 54 void startNetworkLoad(); 55 bool needsCORSPreflight(const WebCore::ResourceRequest&) const; 56 void doCORSPreflight(const WebCore::ResourceRequest&); 74 57 75 virtual ~PingLoad() 76 { 77 if (m_task) { 78 ASSERT(m_task->client() == this); 79 m_task->clearClient(); 80 m_task->cancel(); 81 } 82 } 83 58 NetworkResourceLoadParameters m_parameters; 84 59 RefPtr<NetworkDataTask> m_task; 85 60 WebCore::Timer m_timeoutTimer; 86 bool m_shouldFollowRedirects;61 std::unique_ptr<NetworkCORSPreflightChecker> m_corsPreflightChecker; 87 62 }; 88 63 89 64 } 90 65 91 #endif 66 #endif // USE(NETWORK_SESSION) -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r220275 r220442 903 903 41FAF5F91E3C1025001AE678 /* LibWebRTCResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */; }; 904 904 4450AEC01DC3FAE5009943F2 /* SharedMemoryCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */; }; 905 462107D81F38DBDB00DD7810 /* PingLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 462107D71F38DBD300DD7810 /* PingLoad.cpp */; }; 905 906 463FD4801EB9459600A2982C /* WKProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */; settings = {ATTRIBUTES = (Private, ); }; }; 906 907 463FD4821EB94EC000A2982C /* ProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */; }; … … 908 909 46A2B6081E5676A600C3DEDA /* BackgroundProcessResponsivenessTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A2B6061E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.cpp */; }; 909 910 46A2B6091E5676A600C3DEDA /* BackgroundProcessResponsivenessTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */; }; 911 46DF063B1F3905F8001980BB /* NetworkCORSPreflightChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46DF06391F3905E5001980BB /* NetworkCORSPreflightChecker.cpp */; }; 912 46DF063C1F3905F8001980BB /* NetworkCORSPreflightChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */; }; 910 913 4A3CC18A19B063E700D14AEF /* UserMediaPermissionRequestManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F3919AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.cpp */; }; 911 914 4A3CC18B19B0640F00D14AEF /* UserMediaPermissionRequestManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3A19AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.h */; }; … … 3150 3153 41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCResolver.cpp; path = Network/webrtc/LibWebRTCResolver.cpp; sourceTree = "<group>"; }; 3151 3154 4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SharedMemoryCocoa.cpp; path = cocoa/SharedMemoryCocoa.cpp; sourceTree = "<group>"; }; 3155 462107D71F38DBD300DD7810 /* PingLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PingLoad.cpp; path = NetworkProcess/PingLoad.cpp; sourceTree = "<group>"; }; 3152 3156 463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKProcessTerminationReason.h; sourceTree = "<group>"; }; 3153 3157 463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessTerminationReason.h; sourceTree = "<group>"; }; … … 3155 3159 46A2B6061E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundProcessResponsivenessTimer.cpp; sourceTree = "<group>"; }; 3156 3160 46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackgroundProcessResponsivenessTimer.h; sourceTree = "<group>"; }; 3161 46DF06391F3905E5001980BB /* NetworkCORSPreflightChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkCORSPreflightChecker.cpp; path = NetworkProcess/NetworkCORSPreflightChecker.cpp; sourceTree = "<group>"; }; 3162 46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkCORSPreflightChecker.h; path = NetworkProcess/NetworkCORSPreflightChecker.h; sourceTree = "<group>"; }; 3157 3163 4A410F3519AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserMediaPermissionRequest.cpp; sourceTree = "<group>"; }; 3158 3164 4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserMediaPermissionRequest.h; sourceTree = "<group>"; }; … … 5956 5962 510CC7DC16138E2900D03ED3 /* mac */, 5957 5963 413075971DE84ED70039EC69 /* webrtc */, 5964 46DF06391F3905E5001980BB /* NetworkCORSPreflightChecker.cpp */, 5965 46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */, 5958 5966 513A16491630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp */, 5959 5967 513A164A1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h */, … … 5985 5993 5C0B177E1E7C886700E9123C /* NetworkSocketStream.h */, 5986 5994 5C0B177F1E7C886700E9123C /* NetworkSocketStream.messages.in */, 5995 462107D71F38DBD300DD7810 /* PingLoad.cpp */, 5987 5996 5CE85B1F1C88E6430070BFCE /* PingLoad.h */, 5988 5997 E1B78470163F24690007B692 /* RemoteNetworkingContext.h */, … … 8579 8588 E1B78471163F24690007B692 /* RemoteNetworkingContext.h in Headers */, 8580 8589 1A5704FC1BE1751100874AF1 /* RemoteObjectInvocation.h in Headers */, 8590 46DF063C1F3905F8001980BB /* NetworkCORSPreflightChecker.h in Headers */, 8581 8591 1AC1338018590AE400F3EC05 /* RemoteObjectRegistry.h in Headers */, 8582 8592 1AC1338618590C4600F3EC05 /* RemoteObjectRegistryMessages.h in Headers */, … … 9861 9871 E1A31735134CEA80007C9A4F /* AttributedString.mm in Sources */, 9862 9872 512F589612A8838800629530 /* AuthenticationChallengeProxy.cpp in Sources */, 9873 46DF063B1F3905F8001980BB /* NetworkCORSPreflightChecker.cpp in Sources */, 9863 9874 512F589812A8838800629530 /* AuthenticationDecisionListener.cpp in Sources */, 9864 9875 518E8EF816B2091C00E91429 /* AuthenticationManager.cpp in Sources */, … … 10201 10212 51E35200180F5D0F00E53BE9 /* StorageToWebProcessConnection.cpp in Sources */, 10202 10213 5118E9AC1F295977003EF9F5 /* StorageToWebProcessConnectionMessageReceiver.cpp in Sources */, 10214 462107D81F38DBDB00DD7810 /* PingLoad.cpp in Sources */, 10203 10215 1AE00D6B18327C1200087DD7 /* StringReference.cpp in Sources */, 10204 10216 296BD85E15019BC30071F424 /* StringUtilities.mm in Sources */, -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
r220303 r220442 51 51 #include <WebCore/Document.h> 52 52 #include <WebCore/DocumentLoader.h> 53 #include <WebCore/FetchOptions.h> 53 54 #include <WebCore/Frame.h> 54 55 #include <WebCore/FrameLoader.h> … … 57 58 #include <WebCore/ReferrerPolicy.h> 58 59 #include <WebCore/ResourceLoader.h> 60 #include <WebCore/SecurityOrigin.h> 59 61 #include <WebCore/SessionID.h> 60 62 #include <WebCore/Settings.h> … … 384 386 } 385 387 386 void WebLoaderStrategy::createPingHandle(NetworkingContext* networkingContext, ResourceRequest& request, bool shouldUseCredentialStorage, bool shouldFollowRedirects)388 void WebLoaderStrategy::createPingHandle(NetworkingContext* networkingContext, ResourceRequest& request, Ref<SecurityOrigin>&& sourceOrigin, const FetchOptions& options) 387 389 { 388 390 // It's possible that call to createPingHandle might be made during initial empty Document creation before a NetworkingContext exists. … … 398 400 NetworkResourceLoadParameters loadParameters; 399 401 loadParameters.request = request; 402 loadParameters.sourceOrigin = WTFMove(sourceOrigin); 400 403 loadParameters.sessionID = webPage ? webPage->sessionID() : SessionID::defaultSessionID(); 401 loadParameters.allowStoredCredentials = shouldUseCredentialStorage ? AllowStoredCredentials : DoNotAllowStoredCredentials; 402 loadParameters.shouldFollowRedirects = shouldFollowRedirects; 404 loadParameters.allowStoredCredentials = options.credentials == FetchOptions::Credentials::Omit ? DoNotAllowStoredCredentials : AllowStoredCredentials; 405 loadParameters.mode = options.mode; 406 loadParameters.shouldFollowRedirects = options.redirect == FetchOptions::Redirect::Follow; 403 407 loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = networkingContext->shouldClearReferrerOnHTTPSToHTTPRedirect(); 404 408 -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
r216037 r220442 32 32 #include <wtf/RunLoop.h> 33 33 34 namespace WebCore { 35 struct FetchOptions; 36 } 37 34 38 namespace WebKit { 35 39 … … 56 60 void resumePendingRequests() override; 57 61 58 void createPingHandle(WebCore::NetworkingContext*, WebCore::ResourceRequest&, bool shouldUseCredentialStorage, bool shouldFollowRedirects) override;62 void createPingHandle(WebCore::NetworkingContext*, WebCore::ResourceRequest&, Ref<WebCore::SecurityOrigin>&& sourceOrigin, const WebCore::FetchOptions&) override; 59 63 60 64 void storeDerivedDataToCache(const SHA1::Digest& bodyHash, const String& type, const String& partition, WebCore::SharedBuffer&) override; -
trunk/Source/WebKitLegacy/ChangeLog
r220205 r220442 1 2017-08-08 Chris Dumez <cdumez@apple.com> 2 3 [Beacon] Add support for CORS-preflighting for WK2 / NETWORK_SESSION 4 https://bugs.webkit.org/show_bug.cgi?id=175264 5 <rdar://problem/33547793> 6 7 Reviewed by Youenn Fablet. 8 9 createPingHandle() now takes new parameters but there is currently no behavior 10 change on WebKit1. 11 12 * WebCoreSupport/WebResourceLoadScheduler.cpp: 13 (WebResourceLoadScheduler::createPingHandle): 14 * WebCoreSupport/WebResourceLoadScheduler.h: 15 1 16 2017-08-03 Per Arne Vollan <pvollan@apple.com> 2 17 -
trunk/Source/WebKitLegacy/WebCoreSupport/WebResourceLoadScheduler.cpp
r215160 r220442 27 27 #include <WebCore/Document.h> 28 28 #include <WebCore/DocumentLoader.h> 29 #include <WebCore/FetchOptions.h> 29 30 #include <WebCore/Frame.h> 30 31 #include <WebCore/FrameLoader.h> … … 363 364 } 364 365 365 void WebResourceLoadScheduler::createPingHandle(NetworkingContext* networkingContext, ResourceRequest& request, bool shouldUseCredentialStorage, bool shouldFollowRedirects)366 void WebResourceLoadScheduler::createPingHandle(NetworkingContext* networkingContext, ResourceRequest& request, Ref<SecurityOrigin>&&, const FetchOptions& options) 366 367 { 367 368 // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled. 368 new PingHandle(networkingContext, request, shouldUseCredentialStorage, PingHandle::UsesAsyncCallbacks::No, shouldFollowRedirects);369 } 370 369 new PingHandle(networkingContext, request, options.credentials != FetchOptions::Credentials::Omit, PingHandle::UsesAsyncCallbacks::No, options.redirect == FetchOptions::Redirect::Follow); 370 } 371 -
trunk/Source/WebKitLegacy/WebCoreSupport/WebResourceLoadScheduler.h
r215065 r220442 38 38 class WebResourceLoadScheduler; 39 39 40 namespace WebCore { 41 struct FetchOptions; 42 class SecurityOrigin; 43 } 44 40 45 WebResourceLoadScheduler& webResourceLoadScheduler(); 41 46 … … 55 60 void resumePendingRequests() override; 56 61 57 void createPingHandle(WebCore::NetworkingContext*, WebCore::ResourceRequest&, bool shouldUseCredentialStorage, bool shouldFollowRedirects) override;62 void createPingHandle(WebCore::NetworkingContext*, WebCore::ResourceRequest&, Ref<WebCore::SecurityOrigin>&& sourceOrigin, const WebCore::FetchOptions&) override; 58 63 59 64 void storeDerivedDataToCache(const SHA1::Digest&, const String&, const String&, WebCore::SharedBuffer&) override { }
Note: See TracChangeset
for help on using the changeset viewer.