forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FirstInputDelay integration test
This CL adds a test for FID that tests equality between the JS value and the value reported in UKM and in UMA. Change-Id: I00de8c947895700d86788ee4a95ea228458bb25f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067077 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Steve Kobes <skobes@chromium.org> Cr-Commit-Position: refs/heads/master@{#743212}
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
chrome/browser/page_load_metrics/integration_tests/first_input_delay_browsertest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/page_load_metrics/integration_tests/metric_integration_test.h" | ||
|
||
#include "base/test/trace_event_analyzer.h" | ||
#include "chrome/test/base/ui_test_utils.h" | ||
#include "services/metrics/public/cpp/ukm_builders.h" | ||
|
||
using base::Bucket; | ||
using base::Value; | ||
using trace_analyzer::Query; | ||
using trace_analyzer::TraceAnalyzer; | ||
using trace_analyzer::TraceEventVector; | ||
using ukm::builders::PageLoad; | ||
|
||
IN_PROC_BROWSER_TEST_F(MetricIntegrationTest, FirstInputDelay) { | ||
LoadHTML(R"HTML( | ||
<script> | ||
runtest = async () => { | ||
const observePromise = new Promise(resolve => { | ||
new PerformanceObserver(e => { | ||
e.getEntries().forEach(entry => { | ||
const fid = entry.processingStart - entry.startTime; | ||
resolve(fid); | ||
}) | ||
}).observe({type: 'first-input', buffered: true}); | ||
}); | ||
return await observePromise; | ||
}; | ||
</script> | ||
)HTML"); | ||
|
||
StartTracing({"loading"}); | ||
|
||
content::SimulateMouseClickAt(web_contents(), 0, | ||
blink::WebMouseEvent::Button::kLeft, | ||
gfx::Point(10, 10)); | ||
|
||
// Check web perf API. | ||
double expected_fid = EvalJs(web_contents(), "runtest()").ExtractDouble(); | ||
EXPECT_GT(expected_fid, 0.0); | ||
|
||
ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | ||
|
||
// Check UKM. | ||
ExpectUKMPageLoadMetric(PageLoad::kInteractiveTiming_FirstInputDelay4Name, | ||
expected_fid); | ||
|
||
// Check UMA. | ||
auto samples = histogram_tester().GetAllSamples( | ||
"PageLoad.InteractiveTiming.FirstInputDelay4"); | ||
EXPECT_EQ(1ul, samples.size()); | ||
EXPECT_EQ(samples[0], Bucket(expected_fid, 1)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters