Commit e3f10ed9 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Don't rewrite transition reloads to chrome URLs.

iOS13 will commit a URL change when using window.open followed by a
child.location change.  If the browser triggers a reload here we
shouldn't rewrite URLs to chrome, as window.open to chrome URLs are
not allowed.

Bug: 1017564
Change-Id: I09384f4e6825c9ae34523458516b20715d4b4961
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879328Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709173}
parent bbbb1727
......@@ -506,10 +506,11 @@ NavigationManagerImpl::CreateNavigationItemWithRewriters(
}
// The URL should not be changed to app-specific URL if the load is
// renderer-initiated requested by non-app-specific URL. Pages with
// app-specific urls have elevated previledges and should not be allowed to
// open app-specific URLs.
if (initiation_type == web::NavigationInitiationType::RENDERER_INITIATED &&
// renderer-initiated or a reload requested by non-app-specific URL. Pages
// with app-specific urls have elevated previledges and should not be allowed
// to open app-specific URLs.
if ((initiation_type == web::NavigationInitiationType::RENDERER_INITIATED ||
PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD)) &&
loaded_url != url && web::GetWebClient()->IsAppSpecificURL(loaded_url) &&
!web::GetWebClient()->IsAppSpecificURL(previous_url)) {
loaded_url = url;
......
......@@ -1907,7 +1907,7 @@ TEST_P(NavigationManagerTest, ReloadWithUserAgentTypeOnIntenalUrl) {
}
// Tests that app-specific URLs are not rewritten for renderer-initiated loads
// unless requested by a page with app-specific url.
// or reloads unless requested by a page with app-specific url.
TEST_P(NavigationManagerTest, RewritingAppSpecificUrls) {
// URL should not be rewritten as there is no committed URL.
GURL url1(url::SchemeHostPort(kSchemeToRewrite, "test", 0).Serialize());
......@@ -1928,6 +1928,15 @@ TEST_P(NavigationManagerTest, RewritingAppSpecificUrls) {
web::NavigationManager::UserAgentOverrideOption::INHERIT);
EXPECT_EQ(url2, navigation_manager()->GetPendingItem()->GetURL());
// URL should not be rewritten for user initiated reload navigations.
GURL url_reload(
url::SchemeHostPort(kSchemeToRewrite, "test-reload", 0).Serialize());
navigation_manager()->AddPendingItem(
url_reload, Referrer(), ui::PAGE_TRANSITION_RELOAD,
web::NavigationInitiationType::BROWSER_INITIATED,
web::NavigationManager::UserAgentOverrideOption::INHERIT);
EXPECT_EQ(url_reload, navigation_manager()->GetPendingItem()->GetURL());
// URL should be rewritten for user initiated navigations.
GURL url3(url::SchemeHostPort(kSchemeToRewrite, "test3", 0).Serialize());
navigation_manager()->AddPendingItem(
......
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