OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/feature_list.h" | 6 #include "base/feature_list.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
10 #include "base/test/scoped_feature_list.h" | 10 #include "base/test/scoped_feature_list.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 NavigateToUntrackedUrl(); | 335 NavigateToUntrackedUrl(); |
336 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); | 336 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); |
337 histogram_tester_.ExpectTotalCount( | 337 histogram_tester_.ExpectTotalCount( |
338 internal::kHistogramPageTimingForegroundDuration, 1); | 338 internal::kHistogramPageTimingForegroundDuration, 1); |
339 | 339 |
340 // Verify that NoPageLoadMetricsRecorded returns false when PageLoad metrics | 340 // Verify that NoPageLoadMetricsRecorded returns false when PageLoad metrics |
341 // have been recorded. | 341 // have been recorded. |
342 EXPECT_FALSE(NoPageLoadMetricsRecorded()); | 342 EXPECT_FALSE(NoPageLoadMetricsRecorded()); |
343 } | 343 } |
344 | 344 |
345 IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTest, NewPageInNewForegroundTab) { | |
346 ASSERT_TRUE(embedded_test_server()->Start()); | |
347 | |
348 // The IPCTypeVerifier watches for IPCs in the main web contents. This test | |
349 // navigates in a new web contents, so we need to indicate that we expect no | |
350 // timing updates in the main web contents. | |
351 ExpectNoTimingUpdates(); | |
352 | |
353 chrome::NavigateParams params(browser(), | |
354 embedded_test_server()->GetURL("/title1.html"), | |
355 ui::PAGE_TRANSITION_LINK); | |
356 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; | |
357 chrome::Navigate(¶ms); | |
358 auto waiter = base::MakeUnique<PageLoadMetricsWaiter>(params.target_contents); | |
359 waiter->AddMainFrameExpectation(TimingField::LOAD_EVENT); | |
360 waiter->Wait(); | |
361 | |
362 // Due to crbug.com/725347, with browser side navigation enabled, navigations | |
363 // in new tabs were recorded as starting in the background. Here we verify | |
364 // that navigations initiated in a new tab are recorded as happening in the | |
365 // foreground. | |
366 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1); | |
367 histogram_tester_.ExpectTotalCount(internal::kBackgroundHistogramLoad, 0); | |
368 } | |
369 | |
370 IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTest, NoPaintForEmptyDocument) { | 345 IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTest, NoPaintForEmptyDocument) { |
371 ASSERT_TRUE(embedded_test_server()->Start()); | 346 ASSERT_TRUE(embedded_test_server()->Start()); |
372 | 347 |
373 auto waiter = CreatePageLoadMetricsWaiter(); | 348 auto waiter = CreatePageLoadMetricsWaiter(); |
374 waiter->AddMainFrameExpectation(TimingField::FIRST_LAYOUT); | 349 waiter->AddMainFrameExpectation(TimingField::FIRST_LAYOUT); |
375 waiter->AddMainFrameExpectation(TimingField::LOAD_EVENT); | 350 waiter->AddMainFrameExpectation(TimingField::LOAD_EVENT); |
376 ui_test_utils::NavigateToURL(browser(), | 351 ui_test_utils::NavigateToURL(browser(), |
377 embedded_test_server()->GetURL("/empty.html")); | 352 embedded_test_server()->GetURL("/empty.html")); |
378 waiter->Wait(); | 353 waiter->Wait(); |
379 EXPECT_FALSE(waiter->DidObserveInMainFrame(TimingField::FIRST_PAINT)); | 354 EXPECT_FALSE(waiter->DidObserveInMainFrame(TimingField::FIRST_PAINT)); |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 | 1033 |
1059 // Verify that there is a single sample recorded in the 10kB bucket (the size | 1034 // Verify that there is a single sample recorded in the 10kB bucket (the size |
1060 // of the main HTML response). | 1035 // of the main HTML response). |
1061 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); | 1036 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); |
1062 } | 1037 } |
1063 | 1038 |
1064 INSTANTIATE_TEST_CASE_P( | 1039 INSTANTIATE_TEST_CASE_P( |
1065 /* no prefix */, | 1040 /* no prefix */, |
1066 PageLoadMetricsBrowserTest, | 1041 PageLoadMetricsBrowserTest, |
1067 testing::Values(IPCType::LEGACY, IPCType::MOJO)); | 1042 testing::Values(IPCType::LEGACY, IPCType::MOJO)); |
OLD | NEW |