Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2799953002: Treat loads of invalid URLs as no-ops unless triggered by window.open. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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];
« ios/testing/data/http_server_files/window_location.js ('K') | « ios/web/public/web_state/web_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698