- Revision
- 261390
- Author
- [email protected]
- Date
- 2020-05-08 10:13:36 -0700 (Fri, 08 May 2020)
Log Message
WKWebView.title should be safe browsing warning's title during a safe browsing warning
https://bugs.webkit.org/show_bug.cgi?id=211403
Patch by Alex Christensen <[email protected]> on 2020-05-08
Reviewed by Tim Horton.
Source/WebKit:
Add a new property to PageLoadState, which allows the title to be set underneath it.
That way, once the safe browsing warning is closed, we can update the title to what it would've been,
including any changes that happened while the warning was open.
Covered by an API test. I also manually verified this fixes rdar://problem/56201982
* UIProcess/PageLoadState.cpp:
(WebKit::PageLoadState::commitChanges):
(WebKit::PageLoadState::reset):
(WebKit::PageLoadState::didCommitLoad):
(WebKit::PageLoadState::title const):
(WebKit::PageLoadState::setTitleFromSafeBrowsingWarning):
* UIProcess/PageLoadState.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (261389 => 261390)
--- trunk/Source/WebKit/ChangeLog 2020-05-08 16:55:43 UTC (rev 261389)
+++ trunk/Source/WebKit/ChangeLog 2020-05-08 17:13:36 UTC (rev 261390)
@@ -1,3 +1,26 @@
+2020-05-08 Alex Christensen <[email protected]>
+
+ WKWebView.title should be safe browsing warning's title during a safe browsing warning
+ https://bugs.webkit.org/show_bug.cgi?id=211403
+
+ Reviewed by Tim Horton.
+
+ Add a new property to PageLoadState, which allows the title to be set underneath it.
+ That way, once the safe browsing warning is closed, we can update the title to what it would've been,
+ including any changes that happened while the warning was open.
+
+ Covered by an API test. I also manually verified this fixes rdar://problem/56201982
+
+ * UIProcess/PageLoadState.cpp:
+ (WebKit::PageLoadState::commitChanges):
+ (WebKit::PageLoadState::reset):
+ (WebKit::PageLoadState::didCommitLoad):
+ (WebKit::PageLoadState::title const):
+ (WebKit::PageLoadState::setTitleFromSafeBrowsingWarning):
+ * UIProcess/PageLoadState.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+
2020-05-08 Per Arne Vollan <[email protected]>
[iOS] Update message filtering rules in the WebContent process' sandbox
Modified: trunk/Source/WebKit/UIProcess/PageLoadState.cpp (261389 => 261390)
--- trunk/Source/WebKit/UIProcess/PageLoadState.cpp 2020-05-08 16:55:43 UTC (rev 261389)
+++ trunk/Source/WebKit/UIProcess/PageLoadState.cpp 2020-05-08 17:13:36 UTC (rev 261390)
@@ -95,7 +95,8 @@
bool canGoBackChanged = m_committedState.canGoBack != m_uncommittedState.canGoBack;
bool canGoForwardChanged = m_committedState.canGoForward != m_uncommittedState.canGoForward;
- bool titleChanged = m_committedState.title != m_uncommittedState.title;
+ bool titleChanged = m_committedState.title != m_uncommittedState.title
+ || m_committedState.titleFromSafeBrowsingWarning != m_uncommittedState.titleFromSafeBrowsingWarning;
bool isLoadingChanged = isLoading(m_committedState) != isLoading(m_uncommittedState);
bool activeURLChanged = activeURL(m_committedState) != activeURL(m_uncommittedState);
bool hasOnlySecureContentChanged = hasOnlySecureContent(m_committedState) != hasOnlySecureContent(m_uncommittedState);
@@ -167,6 +168,7 @@
m_lastUnreachableURL = String();
m_uncommittedState.title = String();
+ m_uncommittedState.titleFromSafeBrowsingWarning = { };
m_uncommittedState.estimatedProgress = 0;
m_uncommittedState.networkRequestsInProgress = false;
@@ -331,6 +333,7 @@
m_uncommittedState.negotiatedLegacyTLS = usedLegacyTLS;
m_uncommittedState.title = String();
+ m_uncommittedState.titleFromSafeBrowsingWarning = { };
}
void PageLoadState::didFinishLoad(const Transaction::Token& token)
@@ -375,6 +378,9 @@
const String& PageLoadState::title() const
{
+ if (!m_committedState.titleFromSafeBrowsingWarning.isNull())
+ return m_committedState.titleFromSafeBrowsingWarning;
+
return m_committedState.title;
}
@@ -384,6 +390,12 @@
m_uncommittedState.title = title;
}
+void PageLoadState::setTitleFromSafeBrowsingWarning(const Transaction::Token& token, const String& title)
+{
+ ASSERT_UNUSED(token, &token.m_pageLoadState == this);
+ m_uncommittedState.titleFromSafeBrowsingWarning = title;
+}
+
bool PageLoadState::canGoBack() const
{
return m_committedState.canGoBack;
Modified: trunk/Source/WebKit/UIProcess/PageLoadState.h (261389 => 261390)
--- trunk/Source/WebKit/UIProcess/PageLoadState.h 2020-05-08 16:55:43 UTC (rev 261389)
+++ trunk/Source/WebKit/UIProcess/PageLoadState.h 2020-05-08 17:13:36 UTC (rev 261390)
@@ -175,6 +175,7 @@
const String& title() const;
void setTitle(const Transaction::Token&, const String&);
+ void setTitleFromSafeBrowsingWarning(const Transaction::Token&, const String&);
bool canGoBack() const;
void setCanGoBack(const Transaction::Token&, bool);
@@ -217,6 +218,7 @@
String unreachableURL;
String title;
+ String titleFromSafeBrowsingWarning;
URL resourceDirectoryURL;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (261389 => 261390)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-05-08 16:55:43 UTC (rev 261389)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-05-08 17:13:36 UTC (rev 261390)
@@ -5218,7 +5218,14 @@
m_pageLoadState.commitChanges();
}
+ auto transaction = m_pageLoadState.transaction();
+ m_pageLoadState.setTitleFromSafeBrowsingWarning(transaction, safeBrowsingWarning->title());
+
m_pageClient->showSafeBrowsingWarning(*safeBrowsingWarning, [this, protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), policyAction] (auto&& result) mutable {
+
+ auto transaction = m_pageLoadState.transaction();
+ m_pageLoadState.setTitleFromSafeBrowsingWarning(transaction, { });
+
switchOn(result, [&] (const URL& url) {
completionHandler(PolicyAction::Ignore);
loadRequest({ url });
Modified: trunk/Tools/ChangeLog (261389 => 261390)
--- trunk/Tools/ChangeLog 2020-05-08 16:55:43 UTC (rev 261389)
+++ trunk/Tools/ChangeLog 2020-05-08 17:13:36 UTC (rev 261390)
@@ -1,3 +1,13 @@
+2020-05-08 Alex Christensen <[email protected]>
+
+ WKWebView.title should be safe browsing warning's title during a safe browsing warning
+ https://bugs.webkit.org/show_bug.cgi?id=211403
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
+ (TEST):
+
2020-05-08 Lauro Moura <[email protected]>
[GTK][WPE] Create common glib expectation file
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm (261389 => 261390)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm 2020-05-08 16:55:43 UTC (rev 261389)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm 2020-05-08 17:13:36 UTC (rev 261390)
@@ -283,10 +283,12 @@
#if PLATFORM(MAC)
EXPECT_GT(warning.subviews.firstObject.subviews[2].frame.size.height, 0);
#endif
+ EXPECT_WK_STREQ([webView title], "Deceptive Website Warning");
checkTitleAndClick(warning.subviews.firstObject.subviews[4], "Show Details");
EXPECT_EQ(warning.subviews.count, 2ull);
EXPECT_FALSE(committedNavigation);
visitUnsafeSite(warning);
+ EXPECT_WK_STREQ([webView title], "");
TestWebKitAPI::Util::run(&committedNavigation);
}