Commit b53647c4 authored by Livvie Lin's avatar Livvie Lin Committed by Commit Bot

Set a reload URL in iOS interstitial page load time data

iOS interstitial pages get reloaded to prevent loading them from
cache, since that breaks JavaScript commands. For safety, set
the reload URL in |load_time_data| instead of relying on
window.location, which can have arbitrary URL params.

Bug: 1087282
Change-Id: Idd3c8619371fd7e5ed5875579f4bd86eda2e42c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2248450
Commit-Queue: Livvie Lin <livvielin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Reviewed-by: default avatarCarlos IL <carlosil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779484}
parent cac76bb9
......@@ -135,6 +135,7 @@ function preventDefaultOnPoundLinkClicks() {
});
}
// <if expr="is_ios">
/**
* Ensures interstitial pages on iOS aren't loaded from cache, which breaks
* the commands due to ErrorRetryStateMachine::DidFailProvisionalNavigation
......@@ -144,15 +145,14 @@ function setupIosRefresh() {
if (!loadTimeData.getBoolean('committed_interstitials_enabled')) {
return;
}
const params = new URLSearchParams(window.location.search.substring(1));
const failedUrl = decodeURIComponent(params.get('url') || '');
const load = () => {
window.location.replace(failedUrl);
window.location.replace(loadTimeData.getString('url_to_reload'));
};
window.addEventListener('pageshow', function(e) {
window.onpageshow = load;
}, {once: true});
}
// </if>
// <if expr="is_ios">
document.addEventListener('DOMContentLoaded', setupIosRefresh);
......
......@@ -72,6 +72,10 @@ std::string IOSSecurityInterstitialPage::GetHtmlContents() const {
load_time_data.SetBoolean(
"committed_interstitials_enabled",
base::FeatureList::IsEnabled(web::features::kSSLCommittedInterstitials));
// Interstitial pages on iOS get reloaded to prevent loading from cache, since
// loading from cache breaks JavaScript commands. Set as |load_time_data|
// for safety.
load_time_data.SetString("url_to_reload", request_url_.spec());
PopulateInterstitialStrings(&load_time_data);
webui::SetLoadTimeDataDefaults(client_->GetApplicationLocale(),
&load_time_data);
......
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