Skip to content

Commit

Permalink
Do not induce kCrashOnUnexpectedURLChange if previous hostname is empty.
Browse files Browse the repository at this point in the history
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 c984463)

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 <danyao@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#562941}
Reviewed-on: https://chromium-review.googlesource.com/1079816
Reviewed-by: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/branch-heads/3440@{#50}
Cr-Branched-From: 010ddcf-refs/heads/master@{#561733}
  • Loading branch information
Eugene But authored and Eugene But committed May 30, 2018
1 parent 8e9c95f commit b4de322
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ios/web/web_state/ui/crw_web_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit b4de322

Please sign in to comment.