Commit 4b5ccf17 authored by Eugene But's avatar Eugene But Committed by Commit Bot

[Breadcrumbs] Fix NTP URL matching for DidStartNavigation event

NTP url path may contain trailing slash ("//newtab/").

Bug: 1046231
Change-Id: I3fd313c6489d7a78e471affa86089d6a9bcae8de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2081239
Commit-Queue: Eugene But <eugenebut@chromium.org>
Auto-Submit: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746409}
parent 5aeb5fb1
......@@ -25,7 +25,8 @@ namespace {
// Returns true if navigation URL repesents Chrome's New Tab Page.
bool IsNptUrl(const GURL& url) {
return url.GetOrigin() == kChromeUINewTabURL ||
(url.SchemeIs(url::kAboutScheme) && url.path() == "//newtab");
(url.SchemeIs(url::kAboutScheme) &&
(url.path() == "//newtab" || url.path() == "//newtab/"));
}
}
......
......@@ -146,6 +146,25 @@ TEST_F(BreadcrumbManagerTabHelperTest, AboutNewTabNavigationStart) {
<< events.front();
}
// Tests metadata for about://newtab/ NTP navigation.
TEST_F(BreadcrumbManagerTabHelperTest, AboutNewTabNavigationStart2) {
BreadcrumbManagerTabHelper::CreateForWebState(&first_web_state_);
ASSERT_EQ(0ul, breadcrumb_service_->GetEvents(0).size());
web::FakeNavigationContext context;
context.SetUrl(GURL("about://newtab/"));
first_web_state_.OnNavigationStarted(&context);
std::list<std::string> events = breadcrumb_service_->GetEvents(0);
ASSERT_EQ(1ul, events.size());
EXPECT_NE(std::string::npos, events.front().find(base::StringPrintf(
"%s%lld", kBreadcrumbDidStartNavigation,
context.GetNavigationId())))
<< events.front();
EXPECT_NE(std::string::npos, events.front().find(kBreadcrumbNtpNavigation))
<< events.front();
}
// Tests unique ID in DidStartNavigation and DidStartNavigation.
TEST_F(BreadcrumbManagerTabHelperTest, NavigationUniqueId) {
BreadcrumbManagerTabHelper::CreateForWebState(&first_web_state_);
......
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