Commit 46377533 authored by Joe DeBlasio's avatar Joe DeBlasio Committed by Commit Bot

Revert "Cleanup Lookalike interstitial browser tests."

This reverts commit bfa0a0c5.

Reason for revert: Out of an abundance of caution as suspected actual culprit behind https://chromium-review.googlesource.com/c/chromium/src/+/1509333

Original change's description:
> Cleanup Lookalike interstitial browser tests.
> 
> This is a cleanup CL to add a few missing, and simplify existing,
> interstitial tests. It also includes a few unaddressed nits from earlier
> CLs.
> 
> Bug: 927924
> Change-Id: Iaa177d8dfc69d127b6ba2af5c8f508d5e5d8db83
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1497756
> Commit-Queue: Joe DeBlasio <jdeblasio@chromium.org>
> Auto-Submit: Joe DeBlasio <jdeblasio@chromium.org>
> Reviewed-by: Michael Wasserman <msw@chromium.org>
> Reviewed-by: Mustafa Emre Acer <meacer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#638286}

TBR=msw@chromium.org,meacer@chromium.org,jdeblasio@chromium.org

Change-Id: Ie0b186fd3b3455c13eb1077cb134411416136da2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 927924
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1509463Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Commit-Queue: Joe DeBlasio <jdeblasio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638738}
parent 64de3916
...@@ -103,91 +103,26 @@ security_interstitials::SecurityInterstitialPage::TypeID GetInterstitialType( ...@@ -103,91 +103,26 @@ security_interstitials::SecurityInterstitialPage::TypeID GetInterstitialType(
return page->GetTypeForTesting(); return page->GetTypeForTesting();
} }
// Sets the absolute Site Engagement |score| for the testing origin.
void SetEngagementScore(Browser* browser, const GURL& url, double score) {
SiteEngagementService::Get(browser->profile())
->ResetBaseScoreForURL(url, score);
}
bool IsUrlShowing(Browser* browser) {
return !browser->location_bar_model()->GetFormattedFullURL().empty();
}
// Simulates a link click navigation. We don't use
// ui_test_utils::NavigateToURL(const GURL&) because it simulates the user
// typing the URL, causing the site to have a site engagement score of at
// least LOW.
void NavigateToURL(Browser* browser, const GURL& url) {
NavigateParams params(browser, url, ui::PAGE_TRANSITION_LINK);
params.initiator_origin = url::Origin::Create(GURL("about:blank"));
params.disposition = WindowOpenDisposition::CURRENT_TAB;
params.is_renderer_initiated = true;
ui_test_utils::NavigateToURL(&params);
}
// Same as NavigateToUrl, but wait for the load to complete before returning.
void NavigateToURLSync(Browser* browser, const GURL& url) {
content::TestNavigationObserver navigation_observer(
browser->tab_strip_model()->GetActiveWebContents(), 1);
NavigateToURL(browser, url);
navigation_observer.Wait();
}
// Load given URL and verify that it loaded an interstitial and hid the URL.
void LoadInterstitialAt(Browser* browser, const GURL& url) {
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
NavigateToURLSync(browser, url);
EXPECT_EQ(LookalikeUrlInterstitialPage::kTypeForTesting,
GetInterstitialType(web_contents));
EXPECT_FALSE(IsUrlShowing(browser));
}
void SendInterstitialCommand(content::WebContents* web_contents, void SendInterstitialCommand(content::WebContents* web_contents,
SecurityInterstitialCommand command) { SecurityInterstitialCommand command) {
GetCurrentInterstitial(web_contents) GetCurrentInterstitial(web_contents)
->CommandReceived(base::NumberToString(command)); ->CommandReceived(base::NumberToString(command));
} }
void SendInterstitialCommandSync(Browser* browser,
SecurityInterstitialCommand command) {
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(GetCurrentInterstitial(web_contents));
content::TestNavigationObserver navigation_observer(web_contents, 1);
SendInterstitialCommand(web_contents, command);
navigation_observer.Wait();
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
EXPECT_TRUE(IsUrlShowing(browser));
}
// Verify that no interstitial is shown, regardless of feature state.
void TestInterstitialNotShown(Browser* browser, const GURL& navigated_url) {
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
NavigateToURLSync(browser, navigated_url);
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
// Navigate to an empty page. This will happen after any
// LookalikeUrlService tasks, so will effectively wait for those tasks to
// finish.
NavigateToURLSync(browser, GURL("about:blank"));
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
}
} // namespace } // namespace
class LookalikeUrlNavigationThrottleBrowserTest class LookalikeUrlNavigationThrottleBrowserTest
: public InProcessBrowserTest, : public InProcessBrowserTest,
public testing::WithParamInterface<UIEnabled> { public testing::WithParamInterface<UIEnabled> {
protected: protected:
// Sets the absolute Site Engagement |score| for the testing origin.
static void SetEngagementScore(Browser* browser,
const GURL& url,
double score) {
SiteEngagementService::Get(browser->profile())
->ResetBaseScoreForURL(url, score);
}
void SetUp() override { void SetUp() override {
if (ui_enabled()) { if (ui_enabled()) {
feature_list_.InitAndEnableFeature( feature_list_.InitAndEnableFeature(
...@@ -250,9 +185,50 @@ class LookalikeUrlNavigationThrottleBrowserTest ...@@ -250,9 +185,50 @@ class LookalikeUrlNavigationThrottleBrowserTest
test_ukm_recorder()->GetEntriesByName(UkmEntry::kEntryName).empty()); test_ukm_recorder()->GetEntriesByName(UkmEntry::kEntryName).empty());
} }
void TestInterstitialNotShown(Browser* browser, const GURL& navigated_url) {
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
NavigateToURL(browser, navigated_url);
navigation_observer.Wait();
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
EXPECT_TRUE(IsUrlShowing(browser));
}
{
// Navigate to an empty page. This will happen after any
// LookalikeUrlService tasks, so will effectively wait for those tasks to
// finish.
content::TestNavigationObserver navigation_observer(web_contents, 1);
NavigateToURL(browser, GURL("about:blank"));
navigation_observer.Wait();
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
EXPECT_TRUE(IsUrlShowing(browser));
}
}
// Tests only that the interstitial is shown (when enabled) when the user
// tries to visit the provided URL.
void TestOnlyInterstitialShown(Browser* browser, const GURL& navigated_url) {
if (!ui_enabled()) {
return;
}
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
content::TestNavigationObserver navigation_observer(web_contents, 1);
NavigateToURL(browser, navigated_url);
navigation_observer.Wait();
EXPECT_EQ(LookalikeUrlInterstitialPage::kTypeForTesting,
GetInterstitialType(web_contents));
EXPECT_FALSE(IsUrlShowing(browser));
}
// Tests that the histogram event |expected_event| is recorded. If the UI is // Tests that the histogram event |expected_event| is recorded. If the UI is
// enabled, additional events for interstitial display and link click will // enabled, additinal events for interstitial display and link click will also
// also be tested. // be tested.
void TestHistogramEventsRecordedAndInterstitialShown( void TestHistogramEventsRecordedAndInterstitialShown(
Browser* browser, Browser* browser,
base::HistogramTester* histograms, base::HistogramTester* histograms,
...@@ -260,37 +236,14 @@ class LookalikeUrlNavigationThrottleBrowserTest ...@@ -260,37 +236,14 @@ class LookalikeUrlNavigationThrottleBrowserTest
const GURL& expected_suggested_url, const GURL& expected_suggested_url,
LookalikeUrlNavigationThrottle::NavigationSuggestionEvent LookalikeUrlNavigationThrottle::NavigationSuggestionEvent
expected_event) { expected_event) {
if (!ui_enabled()) { if (ui_enabled()) {
TestInterstitialNotShown(browser, navigated_url); // If the feature is enabled, the UI will be displayed.
TestInterstitialShown(browser, navigated_url, expected_suggested_url);
histograms->ExpectTotalCount( histograms->ExpectTotalCount(
LookalikeUrlNavigationThrottle::kHistogramName, 1); LookalikeUrlNavigationThrottle::kHistogramName, 1);
histograms->ExpectBucketCount( histograms->ExpectBucketCount(
LookalikeUrlNavigationThrottle::kHistogramName, expected_event, 1); LookalikeUrlNavigationThrottle::kHistogramName, expected_event, 1);
return;
}
history::HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(
browser->profile(), ServiceAccessType::EXPLICIT_ACCESS);
ui_test_utils::WaitForHistoryToLoad(history_service);
LoadInterstitialAt(browser, navigated_url);
SendInterstitialCommandSync(browser,
SecurityInterstitialCommand::CMD_DONT_PROCEED);
EXPECT_EQ(expected_suggested_url,
browser->tab_strip_model()->GetActiveWebContents()->GetURL());
// Clicking the link in the interstitial should also remove the original
// URL from history.
ui_test_utils::HistoryEnumerator enumerator(browser->profile());
EXPECT_FALSE(base::ContainsValue(enumerator.urls(), navigated_url));
histograms->ExpectTotalCount(LookalikeUrlNavigationThrottle::kHistogramName,
1);
histograms->ExpectBucketCount(
LookalikeUrlNavigationThrottle::kHistogramName, expected_event, 1);
histograms->ExpectTotalCount(kInterstitialDecisionMetric, 2); histograms->ExpectTotalCount(kInterstitialDecisionMetric, 2);
histograms->ExpectBucketCount(kInterstitialDecisionMetric, histograms->ExpectBucketCount(kInterstitialDecisionMetric,
MetricsHelper::SHOW, 1); MetricsHelper::SHOW, 1);
...@@ -300,6 +253,14 @@ class LookalikeUrlNavigationThrottleBrowserTest ...@@ -300,6 +253,14 @@ class LookalikeUrlNavigationThrottleBrowserTest
histograms->ExpectTotalCount(kInterstitialInteractionMetric, 1); histograms->ExpectTotalCount(kInterstitialInteractionMetric, 1);
histograms->ExpectBucketCount(kInterstitialInteractionMetric, histograms->ExpectBucketCount(kInterstitialInteractionMetric,
MetricsHelper::TOTAL_VISITS, 1); MetricsHelper::TOTAL_VISITS, 1);
return;
}
TestInterstitialNotShown(browser, navigated_url);
histograms->ExpectTotalCount(LookalikeUrlNavigationThrottle::kHistogramName,
1);
histograms->ExpectBucketCount(
LookalikeUrlNavigationThrottle::kHistogramName, expected_event, 1);
} }
// Tests that the histogram event |expected_event| is recorded. If the UI is // Tests that the histogram event |expected_event| is recorded. If the UI is
...@@ -311,39 +272,14 @@ class LookalikeUrlNavigationThrottleBrowserTest ...@@ -311,39 +272,14 @@ class LookalikeUrlNavigationThrottleBrowserTest
const GURL& navigated_url, const GURL& navigated_url,
LookalikeUrlNavigationThrottle::NavigationSuggestionEvent LookalikeUrlNavigationThrottle::NavigationSuggestionEvent
expected_event) { expected_event) {
if (!ui_enabled()) { if (ui_enabled()) {
TestInterstitialNotShown(browser, navigated_url); // If the feature is enabled, the UI will be displayed.
DisplayThenIgnoreInterstitial(browser, navigated_url);
histograms->ExpectTotalCount( histograms->ExpectTotalCount(
LookalikeUrlNavigationThrottle::kHistogramName, 1); LookalikeUrlNavigationThrottle::kHistogramName, 1);
histograms->ExpectBucketCount( histograms->ExpectBucketCount(
LookalikeUrlNavigationThrottle::kHistogramName, expected_event, 1); LookalikeUrlNavigationThrottle::kHistogramName, expected_event, 1);
return;
}
history::HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(
browser->profile(), ServiceAccessType::EXPLICIT_ACCESS);
ui_test_utils::WaitForHistoryToLoad(history_service);
LoadInterstitialAt(browser, navigated_url);
// Clicking the ignore button in the interstitial should remove the
// interstitial and navigate to the original URL.
SendInterstitialCommandSync(browser,
SecurityInterstitialCommand::CMD_PROCEED);
EXPECT_EQ(navigated_url,
browser->tab_strip_model()->GetActiveWebContents()->GetURL());
// Clicking the link should cause the original URL to appear in history.
ui_test_utils::HistoryEnumerator enumerator(browser->profile());
EXPECT_TRUE(base::ContainsValue(enumerator.urls(), navigated_url));
histograms->ExpectTotalCount(LookalikeUrlNavigationThrottle::kHistogramName,
1);
histograms->ExpectBucketCount(
LookalikeUrlNavigationThrottle::kHistogramName, expected_event, 1);
histograms->ExpectTotalCount(kInterstitialDecisionMetric, 2); histograms->ExpectTotalCount(kInterstitialDecisionMetric, 2);
histograms->ExpectBucketCount(kInterstitialDecisionMetric, histograms->ExpectBucketCount(kInterstitialDecisionMetric,
MetricsHelper::SHOW, 1); MetricsHelper::SHOW, 1);
...@@ -355,15 +291,127 @@ class LookalikeUrlNavigationThrottleBrowserTest ...@@ -355,15 +291,127 @@ class LookalikeUrlNavigationThrottleBrowserTest
MetricsHelper::TOTAL_VISITS, 1); MetricsHelper::TOTAL_VISITS, 1);
TestInterstitialNotShown(browser, navigated_url); TestInterstitialNotShown(browser, navigated_url);
return;
}
TestInterstitialNotShown(browser, navigated_url);
histograms->ExpectTotalCount(LookalikeUrlNavigationThrottle::kHistogramName,
1);
histograms->ExpectBucketCount(
LookalikeUrlNavigationThrottle::kHistogramName, expected_event, 1);
} }
ukm::TestUkmRecorder* test_ukm_recorder() { return test_ukm_recorder_.get(); } ukm::TestUkmRecorder* test_ukm_recorder() { return test_ukm_recorder_.get(); }
base::SimpleTestClock* test_clock() { return &test_clock_; } base::SimpleTestClock* test_clock() { return &test_clock_; }
protected:
virtual bool ui_enabled() const { return GetParam() == UIEnabled::kEnabled; } virtual bool ui_enabled() const { return GetParam() == UIEnabled::kEnabled; }
private: static bool IsUrlShowing(Browser* browser) {
return !browser->location_bar_model()->GetFormattedFullURL().empty();
}
// Simulates a link click navigation. We don't use
// ui_test_utils::NavigateToURL(const GURL&) because it simulates the user
// typing the URL, causing the site to have a site engagement score of at
// least LOW.
static void NavigateToURL(Browser* browser, const GURL& url) {
NavigateParams params(browser, url, ui::PAGE_TRANSITION_LINK);
params.initiator_origin = url::Origin::Create(GURL("about:blank"));
params.disposition = WindowOpenDisposition::CURRENT_TAB;
params.is_renderer_initiated = true;
ui_test_utils::NavigateToURL(&params);
}
// Checks that navigating to |navigated_url| results in displaying an
// interstitial suggesting navigation to |expected_suggestion_url|.
// Both |navigated_url| and |expected_suggested_url| can be ASCII or IDN.
static void TestInterstitialShown(Browser* browser,
const GURL& navigated_url,
const GURL& expected_suggested_url) {
history::HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(
browser->profile(), ServiceAccessType::EXPLICIT_ACCESS);
ui_test_utils::WaitForHistoryToLoad(history_service);
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
EXPECT_TRUE(IsUrlShowing(browser));
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
NavigateToURL(browser, navigated_url);
navigation_observer.Wait();
}
EXPECT_EQ(LookalikeUrlInterstitialPage::kTypeForTesting,
GetInterstitialType(web_contents));
EXPECT_FALSE(IsUrlShowing(browser));
// Clicking the link in the interstitial should remove the interstitial and
// navigate to the suggested URL.
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
SendInterstitialCommand(web_contents,
SecurityInterstitialCommand::CMD_DONT_PROCEED);
navigation_observer.Wait();
}
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
EXPECT_EQ(expected_suggested_url, web_contents->GetURL());
EXPECT_TRUE(IsUrlShowing(browser));
// Clicking the link in the interstitial should also remove the original URL
// from history.
ui_test_utils::HistoryEnumerator enumerator(browser->profile());
EXPECT_FALSE(base::ContainsValue(enumerator.urls(), navigated_url));
}
// Checks that navigating to |navigated_url| results in displaying an
// interstitial, that, when ignored, proceeds to |navigated_url|.
// |navigated_url| can be ASCII or IDN.
static void DisplayThenIgnoreInterstitial(Browser* browser,
const GURL& navigated_url) {
history::HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(
browser->profile(), ServiceAccessType::EXPLICIT_ACCESS);
ui_test_utils::WaitForHistoryToLoad(history_service);
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
NavigateToURL(browser, navigated_url);
navigation_observer.Wait();
}
EXPECT_EQ(LookalikeUrlInterstitialPage::kTypeForTesting,
GetInterstitialType(web_contents));
EXPECT_FALSE(IsUrlShowing(browser));
// Clicking the ignore button in the interstitial should remove the
// interstitial and navigate to the original URL.
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
SendInterstitialCommand(web_contents,
SecurityInterstitialCommand::CMD_PROCEED);
navigation_observer.Wait();
}
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
EXPECT_EQ(navigated_url, web_contents->GetURL());
EXPECT_TRUE(IsUrlShowing(browser));
// Clicking the link should result in the original URL appearing in history.
ui_test_utils::HistoryEnumerator enumerator(browser->profile());
EXPECT_TRUE(base::ContainsValue(enumerator.urls(), navigated_url));
}
base::test::ScopedFeatureList feature_list_; base::test::ScopedFeatureList feature_list_;
std::unique_ptr<ukm::TestAutoSetUkmRecorder> test_ukm_recorder_; std::unique_ptr<ukm::TestAutoSetUkmRecorder> test_ukm_recorder_;
base::SimpleTestClock test_clock_; base::SimpleTestClock test_clock_;
...@@ -371,6 +419,64 @@ class LookalikeUrlNavigationThrottleBrowserTest ...@@ -371,6 +419,64 @@ class LookalikeUrlNavigationThrottleBrowserTest
class LookalikeUrlInterstitialPageBrowserTest class LookalikeUrlInterstitialPageBrowserTest
: public LookalikeUrlNavigationThrottleBrowserTest { : public LookalikeUrlNavigationThrottleBrowserTest {
public:
// Checks that navigating to |navigated_url| displays an interstitial with a
// hidden URL, and then navigating to other pages shows/hides the URLs
// appropriately both when a URL is expected to be hidden (by navigating to
// "chrome://newtab") and when expected to be shown (by navigating to
// |subsequent_url|).
static void TestInterstitialHidesUrlThenRestores(Browser* browser,
const GURL& navigated_url,
const GURL& subsequent_url) {
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
EXPECT_TRUE(IsUrlShowing(browser));
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
NavigateToURL(browser, navigated_url);
navigation_observer.Wait();
}
EXPECT_EQ(LookalikeUrlInterstitialPage::kTypeForTesting,
GetInterstitialType(web_contents));
EXPECT_FALSE(IsUrlShowing(browser));
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
ui_test_utils::NavigateToURL(browser, subsequent_url);
navigation_observer.Wait();
}
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
EXPECT_TRUE(IsUrlShowing(browser));
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
ui_test_utils::NavigateToURL(browser, GURL("chrome://newtab"));
navigation_observer.Wait();
}
EXPECT_FALSE(IsUrlShowing(browser));
}
// Load the given URL and verify that it loaded an interstitial.
void LoadInterstitialAt(const GURL& navigated_url) {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(nullptr, GetCurrentInterstitial(web_contents));
{
content::TestNavigationObserver navigation_observer(web_contents, 1);
NavigateToURL(browser(), navigated_url);
navigation_observer.Wait();
}
EXPECT_EQ(LookalikeUrlInterstitialPage::kTypeForTesting,
GetInterstitialType(web_contents));
}
protected: protected:
bool ui_enabled() const override { return true; } bool ui_enabled() const override { return true; }
}; };
...@@ -682,28 +788,23 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -682,28 +788,23 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kEditDistance); CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kEditDistance);
} }
// Navigate to lookalike domains that redirect to benign domains and ensure that // Navigate to lookalike domains that redirect to benign domains. Ensure that
// we display an interstitial along the way. // we display an interstitial along the way if configured via a feature param.
IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest, IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
Interstitial_CapturesRedirects) { Interstitial_CapturesRedirects) {
{ {
// Verify it works when the lookalike domain is the first in the chain // Verify it works when the lookalike domain is the first in the chain
const GURL kNavigatedUrl = const GURL kNavigatedUrl =
GetLongRedirect("goooglé.com", "example.net", "example.com"); GetLongRedirect("goooglé.com", "example.net", "example.com");
SetEngagementScore(browser(), kNavigatedUrl, kLowEngagement); SetEngagementScore(browser(), kNavigatedUrl, kLowEngagement);
LoadInterstitialAt(browser(), kNavigatedUrl); TestOnlyInterstitialShown(browser(), kNavigatedUrl);
} }
// LoadInterstitialAt assumes there's not an interstitial already showing
// (since otherwise it can't be sure that the navigation caused it).
NavigateToURLSync(browser(), GetURL("example.com"));
{ {
// ...or when it's later in the chain // ...or when it's later in the chain
const GURL kNavigatedUrl = const GURL kNavigatedUrl =
GetLongRedirect("example.net", "goooglé.com", "example.com"); GetLongRedirect("example.net", "goooglé.com", "example.com");
SetEngagementScore(browser(), kNavigatedUrl, kLowEngagement); SetEngagementScore(browser(), kNavigatedUrl, kLowEngagement);
LoadInterstitialAt(browser(), kNavigatedUrl); TestOnlyInterstitialShown(browser(), kNavigatedUrl);
} }
} }
...@@ -716,7 +817,9 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -716,7 +817,9 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
return; return;
const GURL navigated_url = GetURL("goooglé.com"); const GURL navigated_url = GetURL("goooglé.com");
TestInterstitialNotShown(browser(), navigated_url); TestInterstitialNotShown(browser(), navigated_url);
CheckUkm({navigated_url}, "UserAction", UserAction::kInterstitialNotShown); CheckUkm({navigated_url}, "UserAction", UserAction::kInterstitialNotShown);
} }
...@@ -727,8 +830,14 @@ IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest, ...@@ -727,8 +830,14 @@ IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest,
const GURL navigated_url = GetURL("goooglé.com"); const GURL navigated_url = GetURL("goooglé.com");
const GURL subsequent_url = GetURL("example.com"); const GURL subsequent_url = GetURL("example.com");
LoadInterstitialAt(browser(), navigated_url); LoadInterstitialAt(navigated_url);
NavigateToURLSync(browser(), subsequent_url);
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
content::TestNavigationObserver navigation_observer(web_contents, 1);
ui_test_utils::NavigateToURL(browser(), subsequent_url);
navigation_observer.Wait();
CheckUkm({navigated_url}, "UserAction", UserAction::kCloseOrBack); CheckUkm({navigated_url}, "UserAction", UserAction::kCloseOrBack);
} }
...@@ -738,9 +847,15 @@ IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest, ...@@ -738,9 +847,15 @@ IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest,
UkmRecordedAfterSuggestionAccepted) { UkmRecordedAfterSuggestionAccepted) {
const GURL navigated_url = GetURL("goooglé.com"); const GURL navigated_url = GetURL("goooglé.com");
LoadInterstitialAt(browser(), navigated_url); LoadInterstitialAt(navigated_url);
SendInterstitialCommandSync(browser(),
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
content::TestNavigationObserver navigation_observer(web_contents, 1);
SendInterstitialCommand(web_contents,
SecurityInterstitialCommand::CMD_DONT_PROCEED); SecurityInterstitialCommand::CMD_DONT_PROCEED);
navigation_observer.Wait();
CheckUkm({navigated_url}, "UserAction", UserAction::kAcceptSuggestion); CheckUkm({navigated_url}, "UserAction", UserAction::kAcceptSuggestion);
} }
...@@ -750,22 +865,23 @@ IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest, ...@@ -750,22 +865,23 @@ IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest,
UkmRecordedAfterSuggestionIgnored) { UkmRecordedAfterSuggestionIgnored) {
const GURL navigated_url = GetURL("goooglé.com"); const GURL navigated_url = GetURL("goooglé.com");
LoadInterstitialAt(browser(), navigated_url); LoadInterstitialAt(navigated_url);
SendInterstitialCommandSync(browser(),
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
content::TestNavigationObserver navigation_observer(web_contents, 1);
SendInterstitialCommand(web_contents,
SecurityInterstitialCommand::CMD_PROCEED); SecurityInterstitialCommand::CMD_PROCEED);
navigation_observer.Wait();
CheckUkm({navigated_url}, "UserAction", UserAction::kClickThrough); CheckUkm({navigated_url}, "UserAction", UserAction::kClickThrough);
} }
// Verify that the URL shows normally on pages after a lookalike interstitial. // Verify that the URL shows normally on pages after a lookalike interstitial.
IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest, IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest,
UrlShownAfterInterstitial) { UrlShownAfterInterstitial) {
LoadInterstitialAt(browser(), GetURL("goooglé.com")); const GURL kNavigatedUrl = GetURL("goooglé.com");
const GURL kSubsequentUrl = GetURL("example.com");
// URL should be showing again when we navigate to a normal URL TestInterstitialHidesUrlThenRestores(browser(), kNavigatedUrl,
NavigateToURLSync(browser(), GetURL("example.com")); kSubsequentUrl);
EXPECT_TRUE(IsUrlShowing(browser()));
// URL should still get hidden when we navigate to a page with a hidden URL.
NavigateToURLSync(browser(), GURL("chrome://newtab"));
EXPECT_FALSE(IsUrlShowing(browser()));
} }
...@@ -76,7 +76,6 @@ GURL AlternateNavInfoBarDelegate::GetLinkURL() const { ...@@ -76,7 +76,6 @@ GURL AlternateNavInfoBarDelegate::GetLinkURL() const {
bool AlternateNavInfoBarDelegate::LinkClicked( bool AlternateNavInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) { WindowOpenDisposition disposition) {
DCHECK(match_);
history::HistoryService* const history_service = history::HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(profile_, HistoryServiceFactory::GetForProfile(profile_,
ServiceAccessType::IMPLICIT_ACCESS); ServiceAccessType::IMPLICIT_ACCESS);
......
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