Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc

Issue 2894973002: Provide WebContents::CreateParams to tab helpers. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(&params);
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
345 IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTest, NoPaintForEmptyDocument) { 370 IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTest, NoPaintForEmptyDocument) {
346 ASSERT_TRUE(embedded_test_server()->Start()); 371 ASSERT_TRUE(embedded_test_server()->Start());
347 372
348 auto waiter = CreatePageLoadMetricsWaiter(); 373 auto waiter = CreatePageLoadMetricsWaiter();
349 waiter->AddMainFrameExpectation(TimingField::FIRST_LAYOUT); 374 waiter->AddMainFrameExpectation(TimingField::FIRST_LAYOUT);
350 waiter->AddMainFrameExpectation(TimingField::LOAD_EVENT); 375 waiter->AddMainFrameExpectation(TimingField::LOAD_EVENT);
351 ui_test_utils::NavigateToURL(browser(), 376 ui_test_utils::NavigateToURL(browser(),
352 embedded_test_server()->GetURL("/empty.html")); 377 embedded_test_server()->GetURL("/empty.html"));
353 waiter->Wait(); 378 waiter->Wait();
354 EXPECT_FALSE(waiter->DidObserveInMainFrame(TimingField::FIRST_PAINT)); 379 EXPECT_FALSE(waiter->DidObserveInMainFrame(TimingField::FIRST_PAINT));
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 1058
1034 // Verify that there is a single sample recorded in the 10kB bucket (the size 1059 // Verify that there is a single sample recorded in the 10kB bucket (the size
1035 // of the main HTML response). 1060 // of the main HTML response).
1036 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); 1061 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1);
1037 } 1062 }
1038 1063
1039 INSTANTIATE_TEST_CASE_P( 1064 INSTANTIATE_TEST_CASE_P(
1040 /* no prefix */, 1065 /* no prefix */,
1041 PageLoadMetricsBrowserTest, 1066 PageLoadMetricsBrowserTest,
1042 testing::Values(IPCType::LEGACY, IPCType::MOJO)); 1067 testing::Values(IPCType::LEGACY, IPCType::MOJO));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698