Commit 7f06a198 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

NavigationPredictor: Fix ClickAnchorElementOffTheRecord test

This CL fixes ClickAnchorElementOffTheRecord test in
NavigationPredictorBrowserTest. The test navigates an incognito browser
to "/simple_page_with_anchors.html", makes the browser click one of the
anchor links, and then checks PageLoad UKMs.

Before this CL, the test checks the UKM recorder immediately after
clicking the anchor link. This is not correct because PageLoad metrics
are recorded when the page navigates away or becomes hidden (see callers
of UkmPageLoadMetricsObserver::RecordPageLoadMetrics()). This means no
UKMs are recorded regardless of the test configuration.

After this CL, the test ensures that the browser navigates to the linked
page before checking the UKM recorder.

Also, this CL removes comments about cache interaction because this test
doesn't refer to the cache.

Bug: n/a
Change-Id: Iecbe502718828f3dcb9bbbec811810ba66bc2d62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245428
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779625}
parent 841f3ad0
......@@ -431,8 +431,7 @@ IN_PROC_BROWSER_TEST_F(NavigationPredictorBrowserTest,
"NavigationPredictor.LinkClickedPrerenderResult", 1);
}
// Simulate a click at the anchor element in off-the-record profile. Metrics
// should not be recorded.
// Simulate a click at the anchor element in off-the-record profile.
IN_PROC_BROWSER_TEST_F(NavigationPredictorBrowserTest,
ClickAnchorElementOffTheRecord) {
auto test_ukm_recorder = std::make_unique<ukm::TestAutoSetUkmRecorder>();
......@@ -449,14 +448,14 @@ IN_PROC_BROWSER_TEST_F(NavigationPredictorBrowserTest,
EXPECT_TRUE(content::ExecuteScript(
incognito->tab_strip_model()->GetActiveWebContents(),
"document.getElementById('google').click();"));
content::WaitForLoadStop(
incognito->tab_strip_model()->GetActiveWebContents());
// Check that the page was loaded from cache.
auto entries = test_ukm_recorder->GetMergedEntriesByName(
ukm::builders::PageLoad::kEntryName);
EXPECT_EQ(0u, entries.size());
EXPECT_EQ(1u, entries.size());
}
IN_PROC_BROWSER_TEST_F(NavigationPredictorBrowserTest,
AnchorElementClickedOnSearchEnginePage) {
static const char kShortName[] = "test";
......
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