Index: ios/web/web_state/ui/crw_web_controller.mm |
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm |
index 6e5ae32c21d697a687a03e16476677f7c5f03dcd..4f03cc6e35e57d70111e54a120d197d8b89642e7 100644 |
--- a/ios/web/web_state/ui/crw_web_controller.mm |
+++ b/ios/web/web_state/ui/crw_web_controller.mm |
@@ -4304,14 +4304,17 @@ - (void)webView:(WKWebView*)webView |
// retrieved state will be pending until |didCommitNavigation| callback. |
[self updatePendingNavigationInfoFromNavigationAction:action]; |
- // Invalid URLs should not be loaded. However, simply doing nothing upon |
- // tapping a link or button is a jarring user experience. Instead, cancel |
- // the invalid navigation and load about:blank if navigation was requested for |
- // the main frame. |
+ // Invalid URLs should not be loaded. |
GURL requestURL = net::GURLWithNSURL(action.request.URL); |
if (!requestURL.is_valid()) { |
decisionHandler(WKNavigationActionPolicyCancel); |
- if (action.targetFrame.mainFrame) { |
+ // The HTML5 spec indicates that window.open with an invalid URL should open |
+ // about:blank. |
+ BOOL isFirstLoadInOpenedWindow = |
+ self.webState->HasOpener() && |
+ !self.webState->GetNavigationManager()->GetLastCommittedItem(); |
+ BOOL isMainFrame = action.targetFrame.mainFrame; |
+ if (isFirstLoadInOpenedWindow && isMainFrame) { |
Eugene But (OOO till 7-30)
2017/04/06 18:34:19
I thought this will break CRWWebControllerInvalidU
kkhorimoto
2017/04/07 00:03:40
It looks like WKWebView's |-loadHTMLString:baseURL
Eugene But (OOO till 7-30)
2017/04/07 01:03:36
Sorry looks like that test was useless :( I will d
|
GURL aboutBlankURL(url::kAboutBlankURL); |
web::NavigationManager::WebLoadParams loadParams(aboutBlankURL); |
loadParams.referrer = [self currentReferrer]; |