- Revision
- 247885
- Author
- jiewen_...@apple.com
- Date
- 2019-07-26 17:03:45 -0700 (Fri, 26 Jul 2019)
Log Message
NavigationSOAuthorizationSession should check the active URL of the responding page after waking up from waiting
https://bugs.webkit.org/show_bug.cgi?id=200150
<rdar://problem/53280170>
Reviewed by Brent Fulgham.
Source/WebKit:
NavigationSOAuthorizationSession should check the active URL of the responding page after waking up from waiting
as the page might have already changed the location.
* UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:
* UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm:
(WebKit::NavigationSOAuthorizationSession::shouldStartInternal):
(WebKit::NavigationSOAuthorizationSession::webViewDidMoveToWindow):
(WebKit::NavigationSOAuthorizationSession::pageActiveURLDidChangeDuringWaiting const):
* UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm:
(WebKit::SubFrameSOAuthorizationSession::abortInternal):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (247884 => 247885)
--- trunk/Source/WebKit/ChangeLog 2019-07-26 23:58:59 UTC (rev 247884)
+++ trunk/Source/WebKit/ChangeLog 2019-07-27 00:03:45 UTC (rev 247885)
@@ -1,3 +1,22 @@
+2019-07-26 Jiewen Tan <jiewen_...@apple.com>
+
+ NavigationSOAuthorizationSession should check the active URL of the responding page after waking up from waiting
+ https://bugs.webkit.org/show_bug.cgi?id=200150
+ <rdar://problem/53280170>
+
+ Reviewed by Brent Fulgham.
+
+ NavigationSOAuthorizationSession should check the active URL of the responding page after waking up from waiting
+ as the page might have already changed the location.
+
+ * UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:
+ * UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm:
+ (WebKit::NavigationSOAuthorizationSession::shouldStartInternal):
+ (WebKit::NavigationSOAuthorizationSession::webViewDidMoveToWindow):
+ (WebKit::NavigationSOAuthorizationSession::pageActiveURLDidChangeDuringWaiting const):
+ * UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm:
+ (WebKit::SubFrameSOAuthorizationSession::abortInternal):
+
2019-07-26 Chris Dumez <cdu...@apple.com>
Crashes under XPCServiceMain() / mach_msg_trap() due to sandboxing
Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h (247884 => 247885)
--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h 2019-07-26 23:58:59 UTC (rev 247884)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h 2019-07-27 00:03:45 UTC (rev 247885)
@@ -30,6 +30,7 @@
#include "SOAuthorizationSession.h"
#include "WebViewDidMoveToWindowObserver.h"
#include <wtf/CompletionHandler.h>
+#include <wtf/text/WTFString.h>
namespace WebKit {
@@ -62,7 +63,10 @@
virtual void beforeStart() = 0;
+ bool pageActiveURLDidChangeDuringWaiting() const;
+
Callback m_callback;
+ String m_waitingPageActiveURL;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm (247884 => 247885)
--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm 2019-07-26 23:58:59 UTC (rev 247884)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm 2019-07-27 00:03:45 UTC (rev 247885)
@@ -55,6 +55,8 @@
if (!page->isInWindow()) {
setState(State::Waiting);
page->addObserver(*this);
+ ASSERT(page->mainFrame());
+ m_waitingPageActiveURL = page->pageLoadState().activeURL();
return;
}
start();
@@ -65,10 +67,21 @@
auto* page = this->page();
if (state() != State::Waiting || !page || !page->isInWindow())
return;
+ if (pageActiveURLDidChangeDuringWaiting()) {
+ abort();
+ page->removeObserver(*this);
+ return;
+ }
start();
page->removeObserver(*this);
}
+bool NavigationSOAuthorizationSession::pageActiveURLDidChangeDuringWaiting() const
+{
+ auto* page = this->page();
+ return !page || page->pageLoadState().activeURL() != m_waitingPageActiveURL;
+}
+
} // namespace WebKit
#endif
Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm (247884 => 247885)
--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm 2019-07-26 23:58:59 UTC (rev 247884)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm 2019-07-27 00:03:45 UTC (rev 247885)
@@ -76,7 +76,6 @@
void SubFrameSOAuthorizationSession::abortInternal()
{
- ASSERT_NOT_REACHED();
}
void SubFrameSOAuthorizationSession::completeInternal(const WebCore::ResourceResponse& response, NSData *data)
Modified: trunk/Tools/ChangeLog (247884 => 247885)
--- trunk/Tools/ChangeLog 2019-07-26 23:58:59 UTC (rev 247884)
+++ trunk/Tools/ChangeLog 2019-07-27 00:03:45 UTC (rev 247885)
@@ -1,3 +1,14 @@
+2019-07-26 Jiewen Tan <jiewen_...@apple.com>
+
+ NavigationSOAuthorizationSession should check the active URL of the responding page after waking up from waiting
+ https://bugs.webkit.org/show_bug.cgi?id=200150
+ <rdar://problem/53280170>
+
+ Reviewed by Brent Fulgham.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm:
+ (TestWebKitAPI::TEST):
+
2019-07-26 Jonathan Bedard <jbed...@apple.com>
Follow-up fix: results.webkit.org: Suite results shouldn't be the landing page
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm (247884 => 247885)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm 2019-07-26 23:58:59 UTC (rev 247884)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm 2019-07-27 00:03:45 UTC (rev 247885)
@@ -761,7 +761,7 @@
auto delegate = adoptNS([[TestSOAuthorizationDelegate alloc] init]);
configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow);
- // The session will be waiting since the web view is is not int the window.
+ // The session will be waiting since the web view is is not in the window.
[webView removeFromSuperview];
[webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]];
Util::sleep(0.5);
@@ -783,6 +783,35 @@
EXPECT_WK_STREQ(redirectURL.get().absoluteString, finalURL);
}
+TEST(SOAuthorizationRedirect, InterceptionAbortedWithWaitingSession)
+{
+ resetState();
+ ClassMethodSwizzler swizzler1(PAL::getSOAuthorizationClass(), @selector(canPerformAuthorizationWithURL:responseCode:), reinterpret_cast<IMP>(overrideCanPerformAuthorizationWithURL));
+ InstanceMethodSwizzler swizzler2(PAL::getSOAuthorizationClass(), @selector(setDelegate:), reinterpret_cast<IMP>(overrideSetDelegate));
+ InstanceMethodSwizzler swizzler3(PAL::getSOAuthorizationClass(), @selector(beginAuthorizationWithURL:httpHeaders:httpBody:), reinterpret_cast<IMP>(overrideBeginAuthorizationWithURL));
+
+ RetainPtr<NSURL> testURL1 = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+ RetainPtr<NSURL> testURL2 = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
+
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+ auto delegate = adoptNS([[TestSOAuthorizationDelegate alloc] init]);
+ configureSOAuthorizationWebView(webView.get(), delegate.get(), OpenExternalSchemesPolicy::Allow);
+
+ // The session will be waiting since the web view is is not in the window.
+ [webView removeFromSuperview];
+ [webView loadRequest:[NSURLRequest requestWithURL:testURL1.get()]];
+ Util::sleep(0.5);
+ EXPECT_FALSE(authorizationPerformed);
+
+ [webView loadRequest:[NSURLRequest requestWithURL:testURL2.get()]];
+ // Should activate the session.
+ [webView addToTestWindow];
+
+ // The waiting session should be aborted as the previous navigation is overwritten by a new navigation.
+ Util::run(&navigationCompleted);
+ EXPECT_FALSE(authorizationPerformed);
+}
+
TEST(SOAuthorizationRedirect, InterceptionSucceedWithActiveSessionDidMoveWindow)
{
resetState();