Commit 74a3e615 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Relax DCHECK for window.open.write cases.

On iOS13, WebKit started changing the URL visible webView.URL when
opening a new tab and then writing to it, e.g.
window.open('javascript:document.write(1)').  This URL is never committed,
so it should be OK to ignore this URL change.

Bug: 1012718
Change-Id: Id7f24384f3146ecad3af0fbfabfdfa02a9bb63f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849993
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704518}
parent e9b113a3
...@@ -941,6 +941,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -941,6 +941,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
- (void)setDocumentURL:(const GURL&)newURL - (void)setDocumentURL:(const GURL&)newURL
context:(web::NavigationContextImpl*)context { context:(web::NavigationContextImpl*)context {
GURL oldDocumentURL = _documentURL;
if (newURL != _documentURL && newURL.is_valid()) { if (newURL != _documentURL && newURL.is_valid()) {
_documentURL = newURL; _documentURL = newURL;
_userInteractionState.SetUserInteractionRegisteredSinceLastUrlChange(false); _userInteractionState.SetUserInteractionRegisteredSinceLastUrlChange(false);
...@@ -949,6 +950,16 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -949,6 +950,16 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
!context->IsLoadingHtmlString() && !context->IsLoadingErrorPage() && !context->IsLoadingHtmlString() && !context->IsLoadingErrorPage() &&
!IsWKInternalUrl(newURL) && !newURL.SchemeIs(url::kAboutScheme) && !IsWKInternalUrl(newURL) && !newURL.SchemeIs(url::kAboutScheme) &&
self.webView) { self.webView) {
// On iOS13, WebKit started changing the URL visible webView.URL when
// opening a new tab and then writing to it, e.g.
// window.open('javascript:document.write(1)'). This URL is never commited,
// so it should be OK to ignore this URL change.
if (base::ios::IsRunningOnIOS13OrLater() && oldDocumentURL.IsAboutBlank() &&
!self.webStateImpl->GetNavigationManager()->GetLastCommittedItem() &&
!self.webView.loading) {
return;
}
GURL documentOrigin = newURL.GetOrigin(); GURL documentOrigin = newURL.GetOrigin();
web::NavigationItem* committedItem = web::NavigationItem* committedItem =
self.webStateImpl->GetNavigationManager()->GetLastCommittedItem(); self.webStateImpl->GetNavigationManager()->GetLastCommittedItem();
...@@ -1930,7 +1941,8 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -1930,7 +1941,8 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
if (!IsRestoreSessionUrl(_documentURL) && !IsRestoreSessionUrl(newURL)) { if (!IsRestoreSessionUrl(_documentURL) && !IsRestoreSessionUrl(newURL)) {
bool ignore_host_change = bool ignore_host_change =
// On iOS13 document.write() can change URL origin for about:blank page. // On iOS13 document.write() can change URL origin for about:blank page.
(_documentURL.IsAboutBlank() && base::ios::IsRunningOnIOS13OrLater()); (_documentURL.IsAboutBlank() && base::ios::IsRunningOnIOS13OrLater() &&
!self.webView.loading);
if (!ignore_host_change) { if (!ignore_host_change) {
DCHECK_EQ(_documentURL.host(), newURL.host()); DCHECK_EQ(_documentURL.host(), newURL.host());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment