Commit 8a5544bb authored by Joe DeBlasio's avatar Joe DeBlasio Committed by Commit Bot

[Safety Tips] Fix NOTREACHED() on PageInfo of sensitive-keyword page.

This CL fixes a mistaken NOTREACHED() that was reached when a user
opened PageInfo on a page that triggered the (metrics-only)
sensitive-keyword heuristic. It also adds a test for such.

Fixed: 1061244
Change-Id: I11e6be8c4f75f308cc8f75f48523c4f64a275917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2103398Reviewed-by: default avatarChristopher Thompson <cthomp@chromium.org>
Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Commit-Queue: Joe DeBlasio <jdeblasio@chromium.org>
Auto-Submit: Joe DeBlasio <jdeblasio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750593}
parent 46874eca
......@@ -747,7 +747,6 @@ PageInfoUI::CreateSafetyTipSecurityDescription(
case security_state::SafetyTipStatus::kBadKeyword:
// Keyword safety tips are only used to collect metrics for now and are
// not visible to the user, so don't affect Page Info.
NOTREACHED();
break;
case security_state::SafetyTipStatus::kNone:
......
......@@ -37,6 +37,7 @@
#include "components/security_interstitials/core/common_string_util.h"
#include "components/security_state/core/features.h"
#include "components/security_state/core/security_state.h"
#include "components/strings/grit/components_chromium_strings.h"
#include "components/strings/grit/components_strings.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/web_contents.h"
......@@ -293,9 +294,11 @@ class SafetyTipPageInfoBubbleViewBrowserTest
auto* page_info = static_cast<PageInfoBubbleViewBase*>(
PageInfoBubbleViewBase::GetPageInfoBubbleForTesting());
ASSERT_TRUE(page_info);
EXPECT_NE(page_info->GetWindowTitle(),
l10n_util::GetStringUTF16(
IDS_PAGE_INFO_SAFETY_TIP_BAD_REPUTATION_TITLE));
EXPECT_TRUE(
page_info->GetWindowTitle() ==
l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_SUMMARY) ||
page_info->GetWindowTitle() ==
l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE));
EXPECT_NE(page_info->GetSecurityDescriptionType(),
PageInfoUI::SecurityDescriptionType::SAFETY_TIP);
}
......@@ -908,6 +911,30 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest,
ASSERT_NO_FATAL_FAILURE(CheckPageInfoDoesNotShowSafetyTipInfo(browser()));
}
// Ensure that the sensitive-keyword heuristic doesn't show up in PageInfo. Also
// a regression test for crbug/1061244.
IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest,
SensitiveKeywordHeuristicDoesntShowInPageInfo) {
const std::vector<const char*> kSensitiveKeywords = {"test"};
auto kNavigatedUrl = GetURL("test-secure.com");
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
ReputationWebContentsObserver* rep_observer =
ReputationWebContentsObserver::FromWebContents(contents);
ReputationService* rep_service = ReputationService::Get(browser()->profile());
rep_service->SetSensitiveKeywordsForTesting(kSensitiveKeywords.data(),
kSensitiveKeywords.size());
base::RunLoop loop;
rep_observer->RegisterReputationCheckCallbackForTesting(loop.QuitClosure());
SetEngagementScore(browser(), kNavigatedUrl, kLowEngagement);
NavigateToURL(browser(), kNavigatedUrl, WindowOpenDisposition::CURRENT_TAB);
loop.Run();
ASSERT_NO_FATAL_FAILURE(CheckPageInfoDoesNotShowSafetyTipInfo(browser()));
}
// Tests that UKM data gets properly recorded when safety tip heuristics get
// triggered.
IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest,
......
......@@ -89,8 +89,7 @@ std::string GetHistogramSuffixForSafetyTipStatus(
case security_state::SafetyTipStatus::kLookalikeIgnored:
return "SafetyTip_LookalikeIgnored";
case security_state::SafetyTipStatus::kBadKeyword:
NOTREACHED();
return std::string();
return "SafetyTip_BadKeyword";
}
NOTREACHED();
return std::string();
......
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