From e6b6be8fde42d8b901ad5d8d5d7e2172ce0fb0a6 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 18 Aug 2022 18:44:31 -0700 Subject: [PATCH] browser(webkit): instrument policy check during redirected reload (#16656) It may happen that reload leads to a cross-origin redirect. This PR adds instrumentation to the policy check that triggers new web process creation and allows the client side properly track the navigation progress after reload. Pretty-diff: https://github.com/yury-s/WebKit/commit/753967002c94ed6a3fe5702be530b717c18e1f0d References: #16147 --- browser_patches/webkit/BUILD_NUMBER | 4 +-- browser_patches/webkit/patches/bootstrap.diff | 35 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBER index 9ea3724b2a..8f539152f4 100644 --- a/browser_patches/webkit/BUILD_NUMBER +++ b/browser_patches/webkit/BUILD_NUMBER @@ -1,2 +1,2 @@ -1706 -Changed: max@schmitt.mx Thu Aug 18 23:03:06 UTC 2022 +1707 +Changed: yurys@chromium.org Thu 18 Aug 2022 05:50:58 PM PDT diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diff index 2822f4ea91..64029e2c9d 100644 --- a/browser_patches/webkit/patches/bootstrap.diff +++ b/browser_patches/webkit/patches/bootstrap.diff @@ -2329,7 +2329,7 @@ diff --git a/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm b/So index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d768ace22 100644 --- a/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm +++ b/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm -@@ -198,6 +198,7 @@ NS_ASSUME_NONNULL_BEGIN +@@ -198,6 +198,7 @@ - (void)sendEndIfNeeded - (void)speechRecognizer:(SFSpeechRecognizer *)speechRecognizer availabilityDidChange:(BOOL)available { @@ -2337,7 +2337,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d ASSERT(isMainThread()); if (available || !_task) -@@ -211,6 +212,7 @@ NS_ASSUME_NONNULL_BEGIN +@@ -211,6 +212,7 @@ - (void)speechRecognizer:(SFSpeechRecognizer *)speechRecognizer availabilityDidC - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didHypothesizeTranscription:(SFTranscription *)transcription { @@ -2345,7 +2345,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d ASSERT(isMainThread()); [self sendSpeechStartIfNeeded]; -@@ -219,6 +221,7 @@ NS_ASSUME_NONNULL_BEGIN +@@ -219,6 +221,7 @@ - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didHypothesizeTran - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didFinishRecognition:(SFSpeechRecognitionResult *)recognitionResult { @@ -2353,7 +2353,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d ASSERT(isMainThread()); [self callbackWithTranscriptions:recognitionResult.transcriptions isFinal:YES]; -@@ -230,6 +233,7 @@ NS_ASSUME_NONNULL_BEGIN +@@ -230,6 +233,7 @@ - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didFinishRecogniti - (void)speechRecognitionTaskWasCancelled:(SFSpeechRecognitionTask *)task { @@ -5470,10 +5470,21 @@ index 21e33e46bdb1af8434527747e3c308cbe53f60f0..c17c4de17f439c04d27caa532771934c protected: static SameSiteInfo sameSiteInfo(const Document&, IsForDOMCookieAccess = IsForDOMCookieAccess::No); diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp -index e601aa9c6d3b04df2e9ffb341626013778e4c9d7..13eb5ec5286b6c5ea76b786e6af50ff88e1ea39a 100644 +index e601aa9c6d3b04df2e9ffb341626013778e4c9d7..bb1f35d83d64500eb70e16e9bcd3149094601908 100644 --- a/Source/WebCore/loader/DocumentLoader.cpp +++ b/Source/WebCore/loader/DocumentLoader.cpp -@@ -1510,8 +1510,6 @@ void DocumentLoader::detachFromFrame() +@@ -728,8 +728,10 @@ void DocumentLoader::willSendRequest(ResourceRequest&& newRequest, const Resourc + if (!didReceiveRedirectResponse) + return completionHandler(WTFMove(newRequest)); + ++ InspectorInstrumentation::willCheckNavigationPolicy(*m_frame); + auto navigationPolicyCompletionHandler = [this, protectedThis = Ref { *this }, protectedFrame = Ref { *m_frame }, completionHandler = WTFMove(completionHandler)] (ResourceRequest&& request, WeakPtr&&, NavigationPolicyDecision navigationPolicyDecision) mutable { + m_waitingForNavigationPolicy = false; ++ InspectorInstrumentation::didCheckNavigationPolicy(protectedFrame.get(), navigationPolicyDecision != NavigationPolicyDecision::ContinueLoad); + switch (navigationPolicyDecision) { + case NavigationPolicyDecision::IgnoreLoad: + case NavigationPolicyDecision::StopAllLoads: +@@ -1510,8 +1512,6 @@ void DocumentLoader::detachFromFrame() if (!m_frame) return; @@ -9140,7 +9151,7 @@ diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm b/Source/ index d8eeb6c27a92134728ffada573a1f140e303c727..9ddddb0796cc00d7eea060b11919711446a39586 100644 --- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm +++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm -@@ -720,7 +720,7 @@ void NetworkSessionCocoa::setClientAuditToken(const WebCore::AuthenticationChall +@@ -720,7 +720,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didRece if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { sessionCocoa->setClientAuditToken(challenge); @@ -10557,7 +10568,7 @@ index 67c2480832991ff512fd49b0195cc195e85794e2..619c8a85bd1bdb14a593f15fa02ae90b #import #import #import -@@ -234,6 +235,11 @@ static WallTime toSystemClockTime(NSDate *date) +@@ -234,6 +235,11 @@ - (void)removeDataOfTypes:(NSSet *)dataTypes modifiedSince:(NSDate *)date comple }); } @@ -10736,7 +10747,7 @@ diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm b/ index 2e235bb880c638a0e74256b6d66cb0244ea0a3f1..3471eebb47e860f7c2071d0e7f2691c9f0a6355d 100644 --- a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm +++ b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm -@@ -257,6 +257,16 @@ +@@ -257,6 +257,16 @@ - (BOOL)processSwapsOnNavigation return _processPoolConfiguration->processSwapsOnNavigation(); } @@ -21089,7 +21100,7 @@ diff --git a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm b/Source/WebKitLegac index 78a6e84a1dc04f81b5c266f08ce25f13311d78f2..3136508a043a1b1fd9f7415c551d865710850aa0 100644 --- a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm -@@ -4208,7 +4208,7 @@ static BOOL currentScrollIsBlit(NSView *clipView) +@@ -4208,7 +4208,7 @@ - (void)mouseDown:(WebEvent *)event _private->handlingMouseDownEvent = NO; } @@ -21102,7 +21113,7 @@ diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/ma index 48cc5be9887a698f2bae9261598c08b55705cff8..55904a59760c3a1f987e07db8f5d40d5efa66368 100644 --- a/Source/WebKitLegacy/mac/WebView/WebView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebView.mm -@@ -4035,7 +4035,7 @@ IGNORE_WARNINGS_END +@@ -4035,7 +4035,7 @@ + (void)_doNotStartObservingNetworkReachability } #endif // PLATFORM(IOS_FAMILY) @@ -21111,7 +21122,7 @@ index 48cc5be9887a698f2bae9261598c08b55705cff8..55904a59760c3a1f987e07db8f5d40d5 - (NSArray *)_touchEventRegions { -@@ -4077,7 +4077,7 @@ IGNORE_WARNINGS_END +@@ -4077,7 +4077,7 @@ - (NSArray *)_touchEventRegions }).autorelease(); }