Commit f0860cf6 authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

Manually load the original page when ReloadType::ORIGINAL_REQUEST_URL

This is a manual workaround so that HTTPS Server Previews can be team
fooded in 71 and will need to be merged back into the M71 branch.

This checks if the user is on a preview page and is reloading via
clicking the "load original" UI and if so, loads the orignal page.

Bug: 864187
Change-Id: I2c8ed4edba98f30f398675c38d7f89d3848a0212
Reviewed-on: https://chromium-review.googlesource.com/c/1280853Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599699}
parent 989f5775
...@@ -680,6 +680,32 @@ IN_PROC_BROWSER_TEST_F(PreviewsLitePageServerBrowserTest, ...@@ -680,6 +680,32 @@ IN_PROC_BROWSER_TEST_F(PreviewsLitePageServerBrowserTest,
} }
} }
// Previews InfoBar (which these tests trigger) does not work on Mac.
// See https://crbug.com/782322 for detail.
// Also occasional flakes on win7 (https://crbug.com/789542).
#if defined(OS_ANDROID) || defined(OS_LINUX)
#define MAYBE_LitePagePreviewsReload LitePagePreviewsReload
#else
#define MAYBE_LitePagePreviewsReload DISABLED_LitePagePreviewsReload
#endif
IN_PROC_BROWSER_TEST_F(PreviewsLitePageServerBrowserTest,
MAYBE_LitePagePreviewsReload) {
ui_test_utils::NavigateToURL(browser(), HttpsLitePageURL(kSuccess));
VerifyPreviewLoaded();
GetWebContents()->GetController().Reload(content::ReloadType::NORMAL, false);
VerifyPreviewLoaded();
base::HistogramTester histogram_tester;
GetWebContents()->GetController().Reload(
content::ReloadType::ORIGINAL_REQUEST_URL, false);
VerifyPreviewNotLoaded();
histogram_tester.ExpectBucketCount(
"Previews.ServerLitePage.IneligibleReasons",
PreviewsLitePageNavigationThrottle::IneligibleReason::kLoadOriginalReload,
1);
}
// Previews InfoBar (which these tests trigger) does not work on Mac. // Previews InfoBar (which these tests trigger) does not work on Mac.
// See https://crbug.com/782322 for detail. // See https://crbug.com/782322 for detail.
// Also occasional flakes on win7 (https://crbug.com/789542). // Also occasional flakes on win7 (https://crbug.com/789542).
...@@ -893,10 +919,6 @@ IN_PROC_BROWSER_TEST_F(PreviewsLitePageServerBrowserTest, ...@@ -893,10 +919,6 @@ IN_PROC_BROWSER_TEST_F(PreviewsLitePageServerBrowserTest,
// Navigate back again. // Navigate back again.
GetWebContents()->GetController().GoBack(); GetWebContents()->GetController().GoBack();
VerifyPreviewLoaded(); VerifyPreviewLoaded();
// Reload.
GetWebContents()->GetController().Reload(content::ReloadType::NORMAL, false);
VerifyPreviewLoaded();
} }
class PreviewsLitePageServerTimeoutBrowserTest class PreviewsLitePageServerTimeoutBrowserTest
......
...@@ -399,6 +399,21 @@ PreviewsLitePageNavigationThrottle::TriggerPreview() const { ...@@ -399,6 +399,21 @@ PreviewsLitePageNavigationThrottle::TriggerPreview() const {
content::NavigationThrottle::ThrottleCheckResult content::NavigationThrottle::ThrottleCheckResult
PreviewsLitePageNavigationThrottle::MaybeNavigateToPreview() const { PreviewsLitePageNavigationThrottle::MaybeNavigateToPreview() const {
// First check if the user is attempting to load the original page on a
// preview.
std::string original_url;
if (navigation_handle()->GetReloadType() ==
content::ReloadType::ORIGINAL_REQUEST_URL &&
GetOriginalURL(navigation_handle()->GetURL(), &original_url)) {
LoadAndBypass(navigation_handle()->GetWebContents(), manager_,
MakeOpenURLParams(navigation_handle(), GURL(original_url),
std::string()),
true);
UMA_HISTOGRAM_ENUMERATION("Previews.ServerLitePage.IneligibleReasons",
IneligibleReason::kLoadOriginalReload);
return content::NavigationThrottle::CANCEL;
}
const bool trigger = const bool trigger =
IsEligibleForPreview() && IsEligibleForPreview() &&
!manager_->CheckSingleBypass(navigation_handle()->GetURL().spec()); !manager_->CheckSingleBypass(navigation_handle()->GetURL().spec());
......
...@@ -56,7 +56,8 @@ class PreviewsLitePageNavigationThrottle : public content::NavigationThrottle { ...@@ -56,7 +56,8 @@ class PreviewsLitePageNavigationThrottle : public content::NavigationThrottle {
kServerUnavailable = 3, kServerUnavailable = 3,
kInfoBarNotSeen = 4, kInfoBarNotSeen = 4,
kNetworkNotSlow = 5, kNetworkNotSlow = 5,
kMaxValue = kNetworkNotSlow, kLoadOriginalReload = 6,
kMaxValue = kLoadOriginalReload,
}; };
// The response type from the previews server. This enum must // The response type from the previews server. This enum must
......
...@@ -40882,6 +40882,7 @@ Called by update_net_trust_anchors.py.--> ...@@ -40882,6 +40882,7 @@ Called by update_net_trust_anchors.py.-->
<int value="3" label="Server Unavailable"/> <int value="3" label="Server Unavailable"/>
<int value="4" label="Infobar hasn't been seen by the user and needs to be"/> <int value="4" label="Infobar hasn't been seen by the user and needs to be"/>
<int value="5" label="Network was not slow"/> <int value="5" label="Network was not slow"/>
<int value="6" label="User opted out of this preview (pre-s13n only)"/>
</enum> </enum>
<enum name="PreviewsServerLitePageServerResponse"> <enum name="PreviewsServerLitePageServerResponse">
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