WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
v3
0001-WKNavigationDelegatePrivate-client-redirect-SPI-need.patch (text/plain), 31.79 KB, created by
David Quesada
on 2017-08-31 12:03:38 PDT
(
hide
)
Description:
v3
Filename:
MIME Type:
Creator:
David Quesada
Created:
2017-08-31 12:03:38 PDT
Size:
31.79 KB
patch
obsolete
>From 6a51c1182e3c84eea43ea8a41fd657f4b090690e Mon Sep 17 00:00:00 2001 >From: David Quesada <david_quesada@apple.com> >Date: Thu, 31 Aug 2017 11:39:16 -0700 >Subject: [PATCH] WKNavigationDelegatePrivate client redirect SPI needs to be > able to detect redirects scheduled before the document finishes loading > https://bugs.webkit.org/show_bug.cgi?id=176128 rdar://problem/34068476 > >Reviewed by NOBODY (OOPS!). > >Source/WebCore: > >Removed FrameLoaderClient::dispatchDidPerformClientRedirect() since no client cares about this event anymore. >Also removed FrameLoader::performClientRedirect() since it wouldn't do anything but call changeLocation(). > >No new tests - no change in functionality. > >* loader/FrameLoader.cpp: >* loader/FrameLoader.h: >* loader/FrameLoaderClient.h: >* loader/NavigationScheduler.cpp: > >Source/WebKit: > >_webView:didPerformClientRedirect: isn't useful for delegates that want to know about client redirects >started before the document is finished loading. This is because the method would be called after the >navigation scheduler's timer fires and the navigation for the redirect has begun. Since this happens in >a later iteration of the run loop, the document has already finished loading. Address this by replacing >the method with two that give the navigation delegate more information about when client redirects are >scheduled and canceled. > >* UIProcess/API/APINavigationClient.h: >(API::NavigationClient::willPerformClientRedirect): >(API::NavigationClient::didCancelClientRedirect): >* UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: >* UIProcess/Cocoa/NavigationState.h: >* UIProcess/Cocoa/NavigationState.mm: >(WebKit::NavigationState::setNavigationDelegate): >(WebKit::NavigationState::NavigationClient::willPerformClientRedirect): >(WebKit::NavigationState::NavigationClient::didCancelClientRedirect): >* UIProcess/WebPageProxy.cpp: >(WebKit::WebPageProxy::willPerformClientRedirectForFrame): >(WebKit::WebPageProxy::didCancelClientRedirectForFrame): >* UIProcess/WebPageProxy.h: >* UIProcess/WebPageProxy.messages.in: >* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: >(WebKit::WebFrameLoaderClient::dispatchDidCancelClientRedirect): >(WebKit::WebFrameLoaderClient::dispatchWillPerformClientRedirect): >* WebProcess/WebCoreSupport/WebFrameLoaderClient.h: > >Tools: > >Removed API test for the deleted WKNavigationDelegatePrivate method, >and added two new tests for the two new methods. > >* TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm: >(-[ClientRedirectNavigationDelegate _webView:willPerformClientRedirectToURL:delay:]): >(-[ClientRedirectNavigationDelegate _webViewDidCancelClientRedirect:]): >(-[ClientRedirectNavigationDelegate webView:didFinishNavigation:]): >(TEST): >--- > Source/WebCore/ChangeLog | 18 +++++ > Source/WebCore/loader/FrameLoader.cpp | 6 -- > Source/WebCore/loader/FrameLoader.h | 1 - > Source/WebCore/loader/FrameLoaderClient.h | 1 - > Source/WebCore/loader/NavigationScheduler.cpp | 4 +- > Source/WebKit/ChangeLog | 34 +++++++++ > Source/WebKit/UIProcess/API/APINavigationClient.h | 3 +- > .../API/Cocoa/WKNavigationDelegatePrivate.h | 3 +- > Source/WebKit/UIProcess/Cocoa/NavigationState.h | 6 +- > Source/WebKit/UIProcess/Cocoa/NavigationState.mm | 26 ++++--- > Source/WebKit/UIProcess/WebPageProxy.cpp | 20 ++++-- > Source/WebKit/UIProcess/WebPageProxy.h | 3 +- > Source/WebKit/UIProcess/WebPageProxy.messages.in | 3 +- > .../WebCoreSupport/WebFrameLoaderClient.cpp | 18 ++--- > .../WebCoreSupport/WebFrameLoaderClient.h | 1 - > Tools/ChangeLog | 17 +++++ > .../TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm | 84 +++++++++++++++++++--- > 17 files changed, 197 insertions(+), 51 deletions(-) > >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e74161c9a79..4433a6a5cee 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2017-08-31 David Quesada <david_quesada@apple.com> >+ >+ WKNavigationDelegatePrivate client redirect SPI needs to be able to detect redirects scheduled before the document finishes loading >+ https://bugs.webkit.org/show_bug.cgi?id=176128 >+ rdar://problem/34068476 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Removed FrameLoaderClient::dispatchDidPerformClientRedirect() since no client cares about this event anymore. >+ Also removed FrameLoader::performClientRedirect() since it wouldn't do anything but call changeLocation(). >+ >+ No new tests - no change in functionality. >+ >+ * loader/FrameLoader.cpp: >+ * loader/FrameLoader.h: >+ * loader/FrameLoaderClient.h: >+ * loader/NavigationScheduler.cpp: >+ > 2017-08-31 Chris Dumez <cdumez@apple.com> > > Use WTF::crossThreadCopy() in more places >diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp >index 5f6372c6dc0..b63fa6cc838 100644 >--- a/Source/WebCore/loader/FrameLoader.cpp >+++ b/Source/WebCore/loader/FrameLoader.cpp >@@ -2050,12 +2050,6 @@ void FrameLoader::clientRedirected(const URL& url, double seconds, double fireDa > m_quickRedirectComing = (lockBackForwardList == LockBackForwardList::Yes || history().currentItemShouldBeReplaced()) && m_documentLoader && !m_isExecutingJavaScriptFormAction; > } > >-void FrameLoader::performClientRedirect(FrameLoadRequest&& frameLoadRequest) >-{ >- changeLocation(WTFMove(frameLoadRequest)); >- m_client.dispatchDidPerformClientRedirect(); >-} >- > bool FrameLoader::shouldReload(const URL& currentURL, const URL& destinationURL) > { > // This function implements the rule: "Don't reload if navigating by fragment within >diff --git a/Source/WebCore/loader/FrameLoader.h b/Source/WebCore/loader/FrameLoader.h >index ace66b43049..b24c9e58649 100644 >--- a/Source/WebCore/loader/FrameLoader.h >+++ b/Source/WebCore/loader/FrameLoader.h >@@ -265,7 +265,6 @@ public: > bool allAncestorsAreComplete() const; // including this > void clientRedirected(const URL&, double delay, double fireDate, LockBackForwardList); > void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress); >- void performClientRedirect(FrameLoadRequest&&); > > // FIXME: This is public because this asynchronous callback from the FrameLoaderClient > // uses the policy machinery (and therefore is called via the PolicyChecker). Once we >diff --git a/Source/WebCore/loader/FrameLoaderClient.h b/Source/WebCore/loader/FrameLoaderClient.h >index cfa44e4b2f3..380312adfb3 100644 >--- a/Source/WebCore/loader/FrameLoaderClient.h >+++ b/Source/WebCore/loader/FrameLoaderClient.h >@@ -154,7 +154,6 @@ public: > virtual void dispatchDidChangeProvisionalURL() { } > virtual void dispatchDidCancelClientRedirect() = 0; > virtual void dispatchWillPerformClientRedirect(const URL&, double interval, double fireDate) = 0; >- virtual void dispatchDidPerformClientRedirect() { } > virtual void dispatchDidChangeMainDocument() { } > virtual void dispatchDidNavigateWithinPage() { } > virtual void dispatchDidChangeLocationWithinPage() = 0; >diff --git a/Source/WebCore/loader/NavigationScheduler.cpp b/Source/WebCore/loader/NavigationScheduler.cpp >index 86e73b2a316..a088d51642a 100644 >--- a/Source/WebCore/loader/NavigationScheduler.cpp >+++ b/Source/WebCore/loader/NavigationScheduler.cpp >@@ -185,7 +185,7 @@ public: > ResourceRequest resourceRequest { url(), referrer(), refresh ? ReloadIgnoringCacheData : UseProtocolCachePolicy }; > FrameLoadRequest frameLoadRequest { initiatingDocument(), *securityOrigin(), resourceRequest, "_self", lockHistory(), lockBackForwardList(), MaybeSendReferrer, AllowNavigationToInvalidURL::No, NewFrameOpenerPolicy::Allow, shouldOpenExternalURLs(), initiatedByMainFrame() }; > >- frame.loader().performClientRedirect(WTFMove(frameLoadRequest)); >+ frame.loader().changeLocation(WTFMove(frameLoadRequest)); > } > }; > >@@ -201,7 +201,7 @@ public: > ResourceRequest resourceRequest { url(), referrer(), UseProtocolCachePolicy }; > FrameLoadRequest frameLoadRequest { initiatingDocument(), *securityOrigin(), resourceRequest, "_self", lockHistory(), lockBackForwardList(), MaybeSendReferrer, AllowNavigationToInvalidURL::No, NewFrameOpenerPolicy::Allow, shouldOpenExternalURLs(), initiatedByMainFrame() }; > >- frame.loader().performClientRedirect(WTFMove(frameLoadRequest)); >+ frame.loader().changeLocation(WTFMove(frameLoadRequest)); > } > }; > >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 0a410fe7e86..5bd379c22a5 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,37 @@ >+2017-08-31 David Quesada <david_quesada@apple.com> >+ >+ WKNavigationDelegatePrivate client redirect SPI needs to be able to detect redirects scheduled before the document finishes loading >+ https://bugs.webkit.org/show_bug.cgi?id=176128 >+ rdar://problem/34068476 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ _webView:didPerformClientRedirect: isn't useful for delegates that want to know about client redirects >+ started before the document is finished loading. This is because the method would be called after the >+ navigation scheduler's timer fires and the navigation for the redirect has begun. Since this happens in >+ a later iteration of the run loop, the document has already finished loading. Address this by replacing >+ the method with two that give the navigation delegate more information about when client redirects are >+ scheduled and canceled. >+ >+ * UIProcess/API/APINavigationClient.h: >+ (API::NavigationClient::willPerformClientRedirect): >+ (API::NavigationClient::didCancelClientRedirect): >+ * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: >+ * UIProcess/Cocoa/NavigationState.h: >+ * UIProcess/Cocoa/NavigationState.mm: >+ (WebKit::NavigationState::setNavigationDelegate): >+ (WebKit::NavigationState::NavigationClient::willPerformClientRedirect): >+ (WebKit::NavigationState::NavigationClient::didCancelClientRedirect): >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::willPerformClientRedirectForFrame): >+ (WebKit::WebPageProxy::didCancelClientRedirectForFrame): >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/WebPageProxy.messages.in: >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: >+ (WebKit::WebFrameLoaderClient::dispatchDidCancelClientRedirect): >+ (WebKit::WebFrameLoaderClient::dispatchWillPerformClientRedirect): >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: >+ > 2017-08-31 Chris Dumez <cdumez@apple.com> > > Use WTF::crossThreadCopy() in more places >diff --git a/Source/WebKit/UIProcess/API/APINavigationClient.h b/Source/WebKit/UIProcess/API/APINavigationClient.h >index bcfb411d6fa..e11ca969be1 100644 >--- a/Source/WebKit/UIProcess/API/APINavigationClient.h >+++ b/Source/WebKit/UIProcess/API/APINavigationClient.h >@@ -69,7 +69,8 @@ public: > > virtual void didStartProvisionalNavigation(WebKit::WebPageProxy&, Navigation*, Object*) { } > virtual void didReceiveServerRedirectForProvisionalNavigation(WebKit::WebPageProxy&, Navigation*, Object*) { } >- virtual void didPerformClientRedirectForNavigation(WebKit::WebPageProxy&, Navigation*) { } >+ virtual void willPerformClientRedirect(WebKit::WebPageProxy&, const WTF::String&, double) { } >+ virtual void didCancelClientRedirect(WebKit::WebPageProxy&) { } > virtual void didFailProvisionalNavigationWithError(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, Navigation*, const WebCore::ResourceError&, Object*) { } > virtual void didFailProvisionalLoadInSubframeWithError(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, const WebCore::SecurityOriginData&, Navigation*, const WebCore::ResourceError&, Object*) { } > virtual void didCommitNavigation(WebKit::WebPageProxy&, Navigation*, Object*) { } >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h >index 717b55a4d6c..c1a9d0bde6e 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h >@@ -44,7 +44,8 @@ static const WKNavigationResponsePolicy _WKNavigationResponsePolicyBecomeDownloa > > - (void)_webView:(WKWebView *)webView navigation:(WKNavigation *)navigation didFailProvisionalLoadInSubframe:(WKFrameInfo *)subframe withError:(NSError *)error; > >-- (void)_webView:(WKWebView *)webView didPerformClientRedirectForNavigation:(WKNavigation *)navigation; >+- (void)_webView:(WKWebView *)webView willPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)delay; >+- (void)_webViewDidCancelClientRedirect:(WKWebView *)webView; > > - (void)_webView:(WKWebView *)webView navigationDidFinishDocumentLoad:(WKNavigation *)navigation; > - (void)_webView:(WKWebView *)webView navigation:(WKNavigation *)navigation didSameDocumentNavigation:(_WKSameDocumentNavigationType)navigationType; >diff --git a/Source/WebKit/UIProcess/Cocoa/NavigationState.h b/Source/WebKit/UIProcess/Cocoa/NavigationState.h >index 1999e82b1c6..26fed094fe8 100644 >--- a/Source/WebKit/UIProcess/Cocoa/NavigationState.h >+++ b/Source/WebKit/UIProcess/Cocoa/NavigationState.h >@@ -91,7 +91,8 @@ private: > private: > void didStartProvisionalNavigation(WebPageProxy&, API::Navigation*, API::Object*) override; > void didReceiveServerRedirectForProvisionalNavigation(WebPageProxy&, API::Navigation*, API::Object*) override; >- void didPerformClientRedirectForNavigation(WebPageProxy&, API::Navigation*) override; >+ void willPerformClientRedirect(WebKit::WebPageProxy&, const WTF::String&, double) override; >+ void didCancelClientRedirect(WebKit::WebPageProxy&) override; > void didFailProvisionalNavigationWithError(WebPageProxy&, WebFrameProxy&, API::Navigation*, const WebCore::ResourceError&, API::Object*) override; > void didFailProvisionalLoadInSubframeWithError(WebPageProxy&, WebFrameProxy&, const WebCore::SecurityOriginData&, API::Navigation*, const WebCore::ResourceError&, API::Object*) override; > void didCommitNavigation(WebPageProxy&, API::Navigation*, API::Object*) override; >@@ -173,7 +174,8 @@ private: > bool webViewDidReceiveServerRedirectForProvisionalNavigation : 1; > bool webViewDidFailProvisionalNavigationWithError : 1; > bool webViewNavigationDidFailProvisionalLoadInSubframeWithError : 1; >- bool webViewDidPerformClientRedirectForNavigation : 1; >+ bool webViewWillPerformClientRedirect : 1; >+ bool webViewDidCancelClientRedirect : 1; > bool webViewDidCommitNavigation : 1; > bool webViewNavigationDidFinishDocumentLoad : 1; > bool webViewDidFinishNavigation : 1; >diff --git a/Source/WebKit/UIProcess/Cocoa/NavigationState.mm b/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >index f363f35f32c..ee93921b381 100644 >--- a/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >+++ b/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >@@ -150,7 +150,8 @@ void NavigationState::setNavigationDelegate(id <WKNavigationDelegate> delegate) > m_navigationDelegateMethods.webViewDidFailNavigationWithError = [delegate respondsToSelector:@selector(webView:didFailNavigation:withError:)]; > > m_navigationDelegateMethods.webViewNavigationDidFailProvisionalLoadInSubframeWithError = [delegate respondsToSelector:@selector(_webView:navigation:didFailProvisionalLoadInSubframe:withError:)]; >- m_navigationDelegateMethods.webViewDidPerformClientRedirectForNavigation = [delegate respondsToSelector:@selector(_webView:didPerformClientRedirectForNavigation:)]; >+ m_navigationDelegateMethods.webViewWillPerformClientRedirect = [delegate respondsToSelector:@selector(_webView:willPerformClientRedirectToURL:delay:)]; >+ m_navigationDelegateMethods.webViewDidCancelClientRedirect = [delegate respondsToSelector:@selector(_webViewDidCancelClientRedirect:)]; > m_navigationDelegateMethods.webViewNavigationDidFinishDocumentLoad = [delegate respondsToSelector:@selector(_webView:navigationDidFinishDocumentLoad:)]; > m_navigationDelegateMethods.webViewNavigationDidSameDocumentNavigation = [delegate respondsToSelector:@selector(_webView:navigation:didSameDocumentNavigation:)]; > m_navigationDelegateMethods.webViewRenderingProgressDidChange = [delegate respondsToSelector:@selector(_webView:renderingProgressDidChange:)]; >@@ -489,21 +490,30 @@ void NavigationState::NavigationClient::didReceiveServerRedirectForProvisionalNa > [navigationDelegate webView:m_navigationState.m_webView didReceiveServerRedirectForProvisionalNavigation:wkNavigation]; > } > >-void NavigationState::NavigationClient::didPerformClientRedirectForNavigation(WebPageProxy& page, API::Navigation* navigation) >+void NavigationState::NavigationClient::willPerformClientRedirect(WebKit::WebPageProxy& page, const WTF::String& urlString, double delay) > { >- if (!m_navigationState.m_navigationDelegateMethods.webViewDidPerformClientRedirectForNavigation) >+ if (!m_navigationState.m_navigationDelegateMethods.webViewWillPerformClientRedirect) > return; > > auto navigationDelegate = m_navigationState.m_navigationDelegate.get(); > if (!navigationDelegate) > return; > >- // FIXME: We should assert that navigation is not null here, but it's currently null for some navigations through the page cache. >- WKNavigation *wkNavigation = nil; >- if (navigation) >- wkNavigation = wrapper(*navigation); >+ WebCore::URL url(WebCore::URL(), urlString); >+ >+ [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webView:m_navigationState.m_webView willPerformClientRedirectToURL:url delay:delay]; >+} >+ >+void NavigationState::NavigationClient::didCancelClientRedirect(WebKit::WebPageProxy& page) >+{ >+ if (!m_navigationState.m_navigationDelegateMethods.webViewDidCancelClientRedirect) >+ return; >+ >+ auto navigationDelegate = m_navigationState.m_navigationDelegate.get(); >+ if (!navigationDelegate) >+ return; > >- [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView didPerformClientRedirectForNavigation:wkNavigation]; >+ [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webViewDidCancelClientRedirect:m_navigationState.m_webView]; > } > > static RetainPtr<NSError> createErrorWithRecoveryAttempter(WKWebView *webView, WebFrameProxy& webFrameProxy, NSError *originalError) >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index d35e780e46d..507f523fbf4 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -3208,21 +3208,29 @@ void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t f > m_loaderClient->didReceiveServerRedirectForProvisionalLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get()); > } > >-void WebPageProxy::didPerformClientRedirectForLoadForFrame(uint64_t frameID, uint64_t navigationID) >+void WebPageProxy::willPerformClientRedirectForFrame(uint64_t frameID, const String& url, double delay) > { > PageClientProtector protector(m_pageClient); > > WebFrameProxy* frame = m_process->webFrame(frameID); > MESSAGE_CHECK(frame); > >- // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache. >- RefPtr<API::Navigation> navigation; >- if (frame->isMainFrame() && navigationID) >- navigation = &navigationState().navigation(navigationID); >+ if (m_navigationClient) { >+ if (frame->isMainFrame()) >+ m_navigationClient->willPerformClientRedirect(*this, url, delay); >+ } >+} >+ >+void WebPageProxy::didCancelClientRedirectForFrame(uint64_t frameID) >+{ >+ PageClientProtector protector(m_pageClient); >+ >+ WebFrameProxy* frame = m_process->webFrame(frameID); >+ MESSAGE_CHECK(frame); > > if (m_navigationClient) { > if (frame->isMainFrame()) >- m_navigationClient->didPerformClientRedirectForNavigation(*this, navigation.get()); >+ m_navigationClient->didCancelClientRedirect(*this); > } > } > >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 8541fc879e2..16287e807ac 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1247,7 +1247,8 @@ private: > > void didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const String& unreachableURL, const UserData&); > void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&, const UserData&); >- void didPerformClientRedirectForLoadForFrame(uint64_t frameID, uint64_t navigationID); >+ void willPerformClientRedirectForFrame(uint64_t frameID, const String& url, double delay); >+ void didCancelClientRedirectForFrame(uint64_t frameID); > void didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, const String& url); > void didFailProvisionalLoadForFrame(uint64_t frameID, const WebCore::SecurityOriginData& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError&, const UserData&); > void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&, bool containsPluginDocument, std::optional<WebCore::HasInsecureContent> forcedHasInsecureContent, const UserData&); >diff --git a/Source/WebKit/UIProcess/WebPageProxy.messages.in b/Source/WebKit/UIProcess/WebPageProxy.messages.in >index 011b42e8cb7..9f81111b8e9 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in >@@ -118,7 +118,8 @@ messages -> WebPageProxy { > # Frame load messages > DidStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, String unreachableURL, WebKit::UserData userData) > DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, WebKit::UserData userData) >- DidPerformClientRedirectForLoadForFrame(uint64_t frameID, uint64_t navigationID) >+ WillPerformClientRedirectForFrame(uint64_t frameID, String url, double delay) >+ DidCancelClientRedirectForFrame(uint64_t frameID) > DidChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, String url) > DidFailProvisionalLoadForFrame(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, String provisionalURL, WebCore::ResourceError error, WebKit::UserData userData) > DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, uint32_t loadType, WebCore::CertificateInfo certificateInfo, bool containsPluginDocument, std::optional<WebCore::HasInsecureContent> forcedHasInsecureContent, WebKit::UserData userData) >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >index 91eca9679bd..9c7b8cd288b 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >@@ -289,18 +289,6 @@ void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() > webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), url, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); > } > >-void WebFrameLoaderClient::dispatchDidPerformClientRedirect() >-{ >- WebPage* webPage = m_frame->page(); >- if (!webPage) >- return; >- >- auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID(); >- >- // Notify the UIProcess. >- webPage->send(Messages::WebPageProxy::DidPerformClientRedirectForLoadForFrame(m_frame->frameID(), navigationID)); >-} >- > void WebFrameLoaderClient::dispatchDidChangeProvisionalURL() > { > WebPage* webPage = m_frame->page(); >@@ -319,6 +307,9 @@ void WebFrameLoaderClient::dispatchDidCancelClientRedirect() > > // Notify the bundle client. > webPage->injectedBundleLoaderClient().didCancelClientRedirectForFrame(*webPage, *m_frame); >+ >+ // Notify the UIProcess. >+ webPage->send(Messages::WebPageProxy::DidCancelClientRedirectForFrame(m_frame->frameID())); > } > > void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const URL& url, double interval, double fireDate) >@@ -329,6 +320,9 @@ void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const URL& url, dou > > // Notify the bundle client. > webPage->injectedBundleLoaderClient().willPerformClientRedirectForFrame(*webPage, *m_frame, url, interval, fireDate); >+ >+ // Notify the UIProcess. >+ webPage->send(Messages::WebPageProxy::WillPerformClientRedirectForFrame(m_frame->frameID(), url.string(), interval)); > } > > void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >index 1a9dce0a045..4e40e9e9eb7 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >@@ -88,7 +88,6 @@ private: > > void dispatchDidDispatchOnloadEvents() final; > void dispatchDidReceiveServerRedirectForProvisionalLoad() final; >- void dispatchDidPerformClientRedirect() final; > void dispatchDidChangeProvisionalURL() final; > void dispatchDidCancelClientRedirect() final; > void dispatchWillPerformClientRedirect(const WebCore::URL&, double interval, double fireDate) final; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 376ed097ecc..ad8ab05a1e7 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,20 @@ >+2017-08-31 David Quesada <david_quesada@apple.com> >+ >+ WKNavigationDelegatePrivate client redirect SPI needs to be able to detect redirects scheduled before the document finishes loading >+ https://bugs.webkit.org/show_bug.cgi?id=176128 >+ rdar://problem/34068476 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Removed API test for the deleted WKNavigationDelegatePrivate method, >+ and added two new tests for the two new methods. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm: >+ (-[ClientRedirectNavigationDelegate _webView:willPerformClientRedirectToURL:delay:]): >+ (-[ClientRedirectNavigationDelegate _webViewDidCancelClientRedirect:]): >+ (-[ClientRedirectNavigationDelegate webView:didFinishNavigation:]): >+ (TEST): >+ > 2017-08-31 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK] Several InputMethodFilter tests are failing and crashing >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm >index 91de61dfa5a..2dde680960e 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm >@@ -37,6 +37,8 @@ > static bool isDone; > static RetainPtr<WKNavigation> currentNavigation; > static RetainPtr<NSURL> redirectURL; >+static NSTimeInterval redirectDelay; >+static bool didCancelRedirect; > > @interface NavigationDelegate : NSObject <WKNavigationDelegate> > @end >@@ -188,40 +190,106 @@ TEST(WKNavigation, DecidePolicyForPageCacheNavigation) > ASSERT_TRUE([delegate decidedPolicyForBackForwardNavigation]); > } > >-@interface DidPerformClientRedirectNavigationDelegate : NSObject<WKNavigationDelegatePrivate> >+@interface ClientRedirectNavigationDelegate : NSObject<WKNavigationDelegatePrivate> > @end > >-@implementation DidPerformClientRedirectNavigationDelegate >-- (void)_webView:(WKWebView *)webView didPerformClientRedirectForNavigation:(WKNavigation *)navigation >+@implementation ClientRedirectNavigationDelegate >+- (void)_webView:(WKWebView *)webView willPerformClientRedirectToURL:(NSURL *)URL delay:(NSTimeInterval)delay >+{ >+ redirectURL = URL; >+ redirectDelay = delay; >+} >+- (void)_webViewDidCancelClientRedirect:(WKWebView *)webView >+{ >+ didCancelRedirect = true; >+} >+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation > { > isDone = true; >- redirectURL = webView.URL; > } > @end > >-TEST(WKNavigation, DidPerformClientRedirect) >+TEST(WKNavigation, WebViewWillPerformClientRedirect) > { >- RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); > >- RetainPtr<DidPerformClientRedirectNavigationDelegate> delegate = adoptNS([[DidPerformClientRedirectNavigationDelegate alloc] init]); >+ auto delegate = adoptNS([[ClientRedirectNavigationDelegate alloc] init]); > [webView setNavigationDelegate:delegate.get()]; > >- NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,%3Cmeta%20http-equiv=%22refresh%22%20content=%220;URL=data:text/html,Page1%22%3E"]]; >+ auto request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,%3Cmeta%20http-equiv=%22refresh%22%20content=%22123;URL=data:text/html,Page1%22%3E"]]; > > isDone = false; > redirectURL = nil; >+ redirectDelay = 0; > [webView loadRequest:request]; > TestWebKitAPI::Util::run(&isDone); > >+ ASSERT_DOUBLE_EQ(redirectDelay, 123); > ASSERT_STREQ(redirectURL.get().absoluteString.UTF8String, "data:text/html,Page1"); > > request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,%3Cscript%3Ewindow.location=%22data:text/html,Page2%22;%3C/script%3E"]]; > isDone = false; > redirectURL = nil; >+ redirectDelay = NSTimeIntervalSince1970; // Use any non-zero value, we will test that the delegate receives a delay of 0. > [webView loadRequest:request]; > TestWebKitAPI::Util::run(&isDone); > >+ ASSERT_DOUBLE_EQ(redirectDelay, 0); > ASSERT_STREQ(redirectURL.get().absoluteString.UTF8String, "data:text/html,Page2"); > } > >+TEST(WKNavigation, WebViewDidCancelClientRedirect) >+{ >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]); >+ >+ auto delegate = adoptNS([[ClientRedirectNavigationDelegate alloc] init]); >+ [webView setNavigationDelegate:delegate.get()]; >+ >+ // Test 1: During a navigation that is not a client redirect, -_webViewDidCancelClientRedirect: should not be called. >+ >+ auto request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,Page1"]]; >+ >+ isDone = false; >+ didCancelRedirect = false; >+ [webView loadRequest:request]; >+ TestWebKitAPI::Util::run(&isDone); >+ >+ ASSERT_FALSE(didCancelRedirect); >+ >+ // Test 2: When a client redirect does happen, -_webViewDidCancelClientRedirect: should still be called. It essentially >+ // is called whenever the web view transitions from "expecting a redirect" to "not expecting a redirect". >+ >+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,%3Cscript%3Ewindow.location=%22data:text/html,Page2%22;%3C/script%3E"]]; >+ isDone = false; >+ didCancelRedirect = false; >+ [webView loadRequest:request]; >+ TestWebKitAPI::Util::run(&isDone); >+ >+ ASSERT_FALSE(didCancelRedirect); >+ >+ isDone = false; >+ TestWebKitAPI::Util::run(&isDone); >+ >+ ASSERT_TRUE(didCancelRedirect); >+ >+ // Test 3: When another navigation begins while a client redirect is scheduled, -_webViewDidCancelClientRedirect: >+ // should be called. >+ >+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,%3Cmeta%20http-equiv=%22refresh%22%20content=%2210000;URL=data:text/html,Page3%22%3E"]]; >+ >+ isDone = false; >+ didCancelRedirect = false; >+ [webView loadRequest:request]; >+ TestWebKitAPI::Util::run(&isDone); >+ >+ ASSERT_FALSE(didCancelRedirect); >+ >+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,Page4"]]; >+ isDone = false; >+ [webView loadRequest:request]; >+ TestWebKitAPI::Util::run(&isDone); >+ >+ ASSERT_TRUE(didCancelRedirect); >+} >+ > #endif >-- >2.13.3 (Apple Git-91) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 176128
:
319416
|
319474
| 319495