From b4de32248c9cd87b474e650ba106862f7b49c462 Mon Sep 17 00:00:00 2001 From: Eugene But Date: Wed, 30 May 2018 20:12:37 +0000 Subject: [PATCH] Do not induce kCrashOnUnexpectedURLChange if previous hostname is empty. URLDidChangeWithoutDocumentChange should not be called if previous document hostname is empty. This state is a bug, but there is no value in crashing. TBR=eugenebut@google.com (cherry picked from commit c9844631d6ea9627ce08846f9dd615fc6917d3b2) Bug: 845933 Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet Change-Id: I83ddc62ebc4211aa14f7819f8ea9a6d80d1b7e25 Reviewed-on: https://chromium-review.googlesource.com/1079368 Reviewed-by: Danyao Wang Reviewed-by: Rohit Rao Commit-Queue: Eugene But Cr-Original-Commit-Position: refs/heads/master@{#562941} Reviewed-on: https://chromium-review.googlesource.com/1079816 Reviewed-by: Eugene But Cr-Commit-Position: refs/branch-heads/3440@{#50} Cr-Branched-From: 010ddcfda246975d194964ccf20038ebbdec6084-refs/heads/master@{#561733} --- ios/web/web_state/ui/crw_web_controller.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm index a09e8d6af8f26..78c76559337bd 100644 --- a/ios/web/web_state/ui/crw_web_controller.mm +++ b/ios/web/web_state/ui/crw_web_controller.mm @@ -5273,12 +5273,14 @@ - (BOOL)isKVOChangePotentialSameDocumentNavigationToURL:(const GURL&)newURL { - (void)URLDidChangeWithoutDocumentChange:(const GURL&)newURL { DCHECK(newURL == net::GURLWithNSURL([_webView URL])); + DCHECK(!_documentURL.host().empty() || _documentURL.SchemeIsFile()); if (base::FeatureList::IsEnabled( web::features::kCrashOnUnexpectedURLChange)) { if (_documentURL.GetOrigin() != newURL.GetOrigin()) { - if (newURL.username().find(_documentURL.host()) != std::string::npos || - newURL.password().find(_documentURL.host()) != std::string::npos) { + if (!_documentURL.host().empty() && + (newURL.username().find(_documentURL.host()) != std::string::npos || + newURL.password().find(_documentURL.host()) != std::string::npos)) { CHECK(false); } }