| Index: components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
|
| diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc b/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
|
| index b1f3228fd9c5529e40fbf03ea14f220d5eb51bdf..88c6bd224c67e7d3deac7d46980b2e5a54c75644 100644
|
| --- a/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
|
| +++ b/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
|
| @@ -442,6 +442,60 @@ TEST_F(MetricsWebContentsObserverTest, DontBackgroundQuickerLoad) {
|
| histogram_tester_.ExpectTotalCount(kHistogramFirstTextPaint, 0);
|
| }
|
|
|
| +TEST_F(MetricsWebContentsObserverTest, AbortStopClose) {
|
| + PageLoadTiming timing;
|
| + timing.navigation_start = base::Time::FromDoubleT(1);
|
| + content::WebContentsTester* web_contents_tester =
|
| + content::WebContentsTester::For(web_contents());
|
| + web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
|
| + observer_->OnMessageReceived(
|
| + PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing),
|
| + main_rfh());
|
| + // Simulate the user pressing the stop button.
|
| + observer_->NavigationStopped();
|
| + web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2));
|
| + observer_->OnMessageReceived(
|
| + PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing),
|
| + main_rfh());
|
| + // Kill the MetricsWebContentsObserver to simulate closing the tab.
|
| + observer_.reset();
|
| + histogram_tester_.ExpectTotalCount(kHistogramCommittedAbortStop, 1);
|
| + histogram_tester_.ExpectTotalCount(kHistogramCommittedAbortClose, 1);
|
| +}
|
| +
|
| +TEST_F(MetricsWebContentsObserverTest, AbortNewNavigation) {
|
| + PageLoadTiming timing;
|
| + timing.navigation_start = base::Time::FromDoubleT(1);
|
| + content::WebContentsTester* web_contents_tester =
|
| + content::WebContentsTester::For(web_contents());
|
| + web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
|
| + observer_->OnMessageReceived(
|
| + PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing),
|
| + main_rfh());
|
| + // Simulate the user performaning another navigation before first paint.
|
| + web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2));
|
| + histogram_tester_.ExpectTotalCount(kHistogramCommittedAbortNewNavigation, 1);
|
| +}
|
| +
|
| +TEST_F(MetricsWebContentsObserverTest, AbortBackground) {
|
| + PageLoadTiming timing;
|
| + timing.navigation_start = base::Time::FromDoubleT(1);
|
| + timing.first_paint = base::TimeDelta::FromSeconds(10);
|
| + content::WebContentsTester* web_contents_tester =
|
| + content::WebContentsTester::For(web_contents());
|
| + web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
|
| + // Background the tab and go for a coffee or something.
|
| + observer_->WasHidden();
|
| + observer_->OnMessageReceived(
|
| + PageLoadMetricsMsg_TimingUpdated(observer_->routing_id(), timing),
|
| + main_rfh());
|
| + // Come back and start browsing again.
|
| + observer_->WasShown();
|
| + // Simulate the user performaning another navigation.
|
| + web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl2));
|
| + histogram_tester_.ExpectTotalCount(kHistogramBackgroundBeforePaint, 1);
|
| +}
|
| +
|
| TEST_F(MetricsWebContentsObserverTest, FailProvisionalLoad) {
|
| content::WebContentsTester* web_contents_tester =
|
| content::WebContentsTester::For(web_contents());
|
|
|