Title: [259770] trunk
- Revision
- 259770
- Author
- [email protected]
- Date
- 2020-04-08 17:38:51 -0700 (Wed, 08 Apr 2020)
Log Message
WKWebViews should behave as if they had loaded something after restoring session state
https://bugs.webkit.org/show_bug.cgi?id=210097
<rdar://problem/58778490>
Patch by Alex Christensen <[email protected]> on 2020-04-08
Reviewed by Chris Dumez.
Source/WebKit:
Specifically, we don't want to close a WKWebView after restoring the session state into another
WKWebView into it then navigating to a phishing page. We want to be at the previous page after
the user clicks "Go back".
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::restoreFromSessionState):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (259769 => 259770)
--- trunk/Source/WebKit/ChangeLog 2020-04-09 00:38:27 UTC (rev 259769)
+++ trunk/Source/WebKit/ChangeLog 2020-04-09 00:38:51 UTC (rev 259770)
@@ -1,3 +1,18 @@
+2020-04-08 Alex Christensen <[email protected]>
+
+ WKWebViews should behave as if they had loaded something after restoring session state
+ https://bugs.webkit.org/show_bug.cgi?id=210097
+ <rdar://problem/58778490>
+
+ Reviewed by Chris Dumez.
+
+ Specifically, we don't want to close a WKWebView after restoring the session state into another
+ WKWebView into it then navigating to a phishing page. We want to be at the previous page after
+ the user clicks "Go back".
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::restoreFromSessionState):
+
2020-04-08 Kate Cheney <[email protected]>
Add curly braces after one line if statement for the case when we aren't using the internal SDK
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (259769 => 259770)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-04-09 00:38:27 UTC (rev 259769)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-04-09 00:38:51 UTC (rev 259770)
@@ -5136,15 +5136,15 @@
m_pageLoadState.commitChanges();
}
- m_pageClient->showSafeBrowsingWarning(*safeBrowsingWarning, [protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), policyAction] (auto&& result) mutable {
+ m_pageClient->showSafeBrowsingWarning(*safeBrowsingWarning, [this, protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), policyAction] (auto&& result) mutable {
switchOn(result, [&] (const URL& url) {
completionHandler(PolicyAction::Ignore);
- protectedThis->loadRequest({ url });
+ loadRequest({ url });
}, [&] (ContinueUnsafeLoad continueUnsafeLoad) {
switch (continueUnsafeLoad) {
case ContinueUnsafeLoad::No:
- if (!protectedThis->hasCommittedAnyProvisionalLoads())
- protectedThis->m_uiClient->close(protectedThis.ptr());
+ if (!hasCommittedAnyProvisionalLoads() && !m_sessionStateWasRestoredByAPIRequest)
+ m_uiClient->close(protectedThis.ptr());
completionHandler(PolicyAction::Ignore);
break;
case ContinueUnsafeLoad::Yes:
Modified: trunk/Tools/ChangeLog (259769 => 259770)
--- trunk/Tools/ChangeLog 2020-04-09 00:38:27 UTC (rev 259769)
+++ trunk/Tools/ChangeLog 2020-04-09 00:38:51 UTC (rev 259770)
@@ -1,3 +1,14 @@
+2020-04-08 Alex Christensen <[email protected]>
+
+ WKWebViews should behave as if they had loaded something after restoring session state
+ https://bugs.webkit.org/show_bug.cgi?id=210097
+ <rdar://problem/58778490>
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
+ (TEST):
+
2020-04-08 Ross Kirsling <[email protected]>
Remove ENABLE_INTL define
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm (259769 => 259770)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm 2020-04-09 00:38:27 UTC (rev 259769)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm 2020-04-09 00:38:51 UTC (rev 259770)
@@ -239,6 +239,37 @@
EXPECT_TRUE(didCloseCalled);
}
+TEST(SafeBrowsing, GoBackAfterRestoreFromSessionState)
+{
+ auto webView1 = adoptNS([WKWebView new]);
+ [webView1 loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+ [webView1 _test_waitForDidFinishNavigation];
+ _WKSessionState *state = [webView1 _sessionState];
+
+ ClassMethodSwizzler swizzler(objc_getClass("SSBLookupContext"), @selector(sharedLookupContext), [TestLookupContext methodForSelector:@selector(sharedLookupContext)]);
+
+ auto delegate = adoptNS([SafeBrowsingNavigationDelegate new]);
+ auto webView2 = adoptNS([WKWebView new]);
+ [webView2 configuration].preferences.fraudulentWebsiteWarningEnabled = YES;
+ [webView2 setNavigationDelegate:delegate.get()];
+ [webView2 setUIDelegate:delegate.get()];
+ [webView2 _restoreSessionState:state andNavigate:YES];
+ EXPECT_FALSE(warningShown);
+ while (![webView2 _safeBrowsingWarning])
+ TestWebKitAPI::Util::spinRunLoop();
+ EXPECT_TRUE(warningShown);
+#if !PLATFORM(MAC)
+ [[webView2 _safeBrowsingWarning] didMoveToWindow];
+#endif
+ EXPECT_FALSE(didCloseCalled);
+ goBack([webView2 _safeBrowsingWarning]);
+ EXPECT_FALSE(didCloseCalled);
+ WKBackForwardList *list = [webView2 backForwardList];
+ EXPECT_FALSE(!!list.backItem);
+ EXPECT_FALSE(!!list.forwardItem);
+ EXPECT_TRUE([list.currentItem.URL.path hasSuffix:@"/simple.html"]);
+}
+
template<typename ViewType> void visitUnsafeSite(ViewType *view)
{
[view performSelector:NSSelectorFromString(@"clickedOnLink:") withObject:[NSURL URLWithString:@"WKVisitUnsafeWebsiteSentinel"]];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes