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

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

Issue 2479293003: Revert "Fix flakiness in page_load_metrics_browser_test" (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" 9 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
10 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h" 10 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h"
11 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" 11 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h"
12 #include "chrome/browser/page_load_metrics/observers/document_write_page_load_me trics_observer.h" 12 #include "chrome/browser/page_load_metrics/observers/document_write_page_load_me trics_observer.h"
13 #include "chrome/browser/page_load_metrics/observers/no_state_prefetch_page_load _metrics_observer.h" 13 #include "chrome/browser/page_load_metrics/observers/no_state_prefetch_page_load _metrics_observer.h"
14 #include "chrome/browser/page_load_metrics/page_load_tracker.h" 14 #include "chrome/browser/page_load_metrics/page_load_tracker.h"
15 #include "chrome/browser/prerender/prerender_histograms.h" 15 #include "chrome/browser/prerender/prerender_histograms.h"
16 #include "chrome/browser/prerender/prerender_origin.h" 16 #include "chrome/browser/prerender/prerender_origin.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_navigator_params.h" 19 #include "chrome/browser/ui/browser_navigator_params.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h"
22 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
23 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
24 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
26 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
27 #include "content/public/browser/browser_message_filter.h"
28 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/render_view_host.h"
31 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
32 #include "content/public/test/download_test_observer.h" 28 #include "content/public/test/download_test_observer.h"
33 #include "ipc/ipc_message_start.h"
34 #include "net/http/failing_http_transaction_factory.h" 29 #include "net/http/failing_http_transaction_factory.h"
35 #include "net/http/http_cache.h" 30 #include "net/http/http_cache.h"
36 #include "net/test/embedded_test_server/embedded_test_server.h" 31 #include "net/test/embedded_test_server/embedded_test_server.h"
37 #include "net/test/url_request/url_request_failed_job.h" 32 #include "net/test/url_request/url_request_failed_job.h"
38 #include "net/url_request/url_request_context.h" 33 #include "net/url_request/url_request_context.h"
39 #include "net/url_request/url_request_context_getter.h" 34 #include "net/url_request/url_request_context_getter.h"
40 35
41 namespace {
42
43 // Waits until a PageLoadMetricsMsg_TimingUpdated message IPC is received.
44 class TimingUpdatedObserver : public content::BrowserMessageFilter {
45 public:
46 explicit TimingUpdatedObserver(content::RenderWidgetHost* render_widget_host)
47 : content::BrowserMessageFilter(PageLoadMetricsMsgStart) {
48 render_widget_host->GetProcess()->AddFilter(this);
49
50 // Roudtrip to the IO thread, to ensure that the filter is properly
51 // installed.
52 content::BrowserThread::PostTaskAndReply(
53 content::BrowserThread::IO, FROM_HERE, base::Bind(&base::DoNothing),
54 base::Bind(&TimingUpdatedObserver::Quit, this));
55 run_loop_.reset(new base::RunLoop());
56 run_loop_->Run();
57 run_loop_.reset(nullptr);
58 }
59
60 // Waits for the IPC. Returns immediately if the IPC has already been received
61 // before this call.
62 void WaitForTimingUpdatedIPC() {
63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
64 if (timing_updated_)
65 return;
66
67 run_loop_.reset(new base::RunLoop());
68 run_loop_->Run();
69 run_loop_.reset(nullptr);
70 }
71
72 private:
73 bool OnMessageReceived(const IPC::Message& message) override {
74 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
75
76 if (message.type() == PageLoadMetricsMsg_TimingUpdated::ID) {
77 content::BrowserThread::PostTask(
78 content::BrowserThread::UI, FROM_HERE,
79 base::Bind(&TimingUpdatedObserver::SetTimingUpdatedAndQuit, this));
80 }
81
82 return false;
83 }
84
85 void Quit() {
86 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
87 if (run_loop_)
88 run_loop_->Quit();
89 }
90
91 void SetTimingUpdatedAndQuit() {
92 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
93 timing_updated_ = true;
94 Quit();
95 }
96
97 ~TimingUpdatedObserver() override {}
98
99 std::unique_ptr<base::RunLoop> run_loop_;
100 bool timing_updated_ = false;
101 };
102
103 } // namespace
104
105 class PageLoadMetricsBrowserTest : public InProcessBrowserTest { 36 class PageLoadMetricsBrowserTest : public InProcessBrowserTest {
106 public: 37 public:
107 PageLoadMetricsBrowserTest() {} 38 PageLoadMetricsBrowserTest() {}
108 ~PageLoadMetricsBrowserTest() override {} 39 ~PageLoadMetricsBrowserTest() override {}
109 40
110 protected: 41 protected:
111 void NavigateToUntrackedUrl() { 42 void NavigateToUntrackedUrl() {
112 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); 43 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
113 } 44 }
114 45
115 bool NoPageLoadMetricsRecorded() { 46 bool NoPageLoadMetricsRecorded() {
116 return histogram_tester_.GetTotalCountsForPrefix("PageLoad.").empty(); 47 return histogram_tester_.GetTotalCountsForPrefix("PageLoad.").empty();
117 } 48 }
118 49
119 void WaitForTimingUpdatedIPC() {
120 content::WebContents* web_contents =
121 browser()->tab_strip_model()->GetActiveWebContents();
122 scoped_refptr<TimingUpdatedObserver> observer(new TimingUpdatedObserver(
123 web_contents->GetRenderViewHost()->GetWidget()));
124
125 // The observer must be created before checking this, to avoid a race
126 // condition.
127 if (!NoPageLoadMetricsRecorded())
128 return;
129
130 observer->WaitForTimingUpdatedIPC();
131 }
132
133 base::HistogramTester histogram_tester_; 50 base::HistogramTester histogram_tester_;
134 51
135 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsBrowserTest); 52 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsBrowserTest);
136 }; 53 };
137 54
138 void FailAllNetworkTransactions(net::URLRequestContextGetter* getter) { 55 void FailAllNetworkTransactions(net::URLRequestContextGetter* getter) {
139 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
140 net::HttpCache* cache( 57 net::HttpCache* cache(
141 getter->GetURLRequestContext()->http_transaction_factory()->GetCache()); 58 getter->GetURLRequestContext()->http_transaction_factory()->GetCache());
142 DCHECK(cache); 59 DCHECK(cache);
(...skipping 10 matching lines...) Expand all
153 EXPECT_TRUE(NoPageLoadMetricsRecorded()); 70 EXPECT_TRUE(NoPageLoadMetricsRecorded());
154 } 71 }
155 72
156 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NewPage) { 73 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NewPage) {
157 ASSERT_TRUE(embedded_test_server()->Start()); 74 ASSERT_TRUE(embedded_test_server()->Start());
158 75
159 ui_test_utils::NavigateToURL(browser(), 76 ui_test_utils::NavigateToURL(browser(),
160 embedded_test_server()->GetURL("/title1.html")); 77 embedded_test_server()->GetURL("/title1.html"));
161 NavigateToUntrackedUrl(); 78 NavigateToUntrackedUrl();
162 79
163 WaitForTimingUpdatedIPC();
164 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1); 80 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1);
165 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1); 81 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1);
166 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); 82 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1);
167 histogram_tester_.ExpectTotalCount(internal::kHistogramParseDuration, 1); 83 histogram_tester_.ExpectTotalCount(internal::kHistogramParseDuration, 1);
168 histogram_tester_.ExpectTotalCount( 84 histogram_tester_.ExpectTotalCount(
169 internal::kHistogramParseBlockedOnScriptLoad, 1); 85 internal::kHistogramParseBlockedOnScriptLoad, 1);
170 histogram_tester_.ExpectTotalCount( 86 histogram_tester_.ExpectTotalCount(
171 internal::kHistogramParseBlockedOnScriptExecution, 1); 87 internal::kHistogramParseBlockedOnScriptExecution, 1);
172 88
173 // Verify that NoPageLoadMetricsRecorded returns false when PageLoad metrics 89 // Verify that NoPageLoadMetricsRecorded returns false when PageLoad metrics
174 // have been recorded. 90 // have been recorded.
175 EXPECT_FALSE(NoPageLoadMetricsRecorded()); 91 EXPECT_FALSE(NoPageLoadMetricsRecorded());
176 } 92 }
177 93
178 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SamePageNavigation) { 94 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SamePageNavigation) {
179 ASSERT_TRUE(embedded_test_server()->Start()); 95 ASSERT_TRUE(embedded_test_server()->Start());
180 96
181 ui_test_utils::NavigateToURL(browser(), 97 ui_test_utils::NavigateToURL(browser(),
182 embedded_test_server()->GetURL("/title1.html")); 98 embedded_test_server()->GetURL("/title1.html"));
183 ui_test_utils::NavigateToURL( 99 ui_test_utils::NavigateToURL(
184 browser(), embedded_test_server()->GetURL("/title1.html#hash")); 100 browser(), embedded_test_server()->GetURL("/title1.html#hash"));
185 NavigateToUntrackedUrl(); 101 NavigateToUntrackedUrl();
186 102
187 WaitForTimingUpdatedIPC();
188 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1); 103 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1);
189 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1); 104 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1);
190 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); 105 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1);
191 } 106 }
192 107
193 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameUrlNavigation) { 108 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameUrlNavigation) {
194 ASSERT_TRUE(embedded_test_server()->Start()); 109 ASSERT_TRUE(embedded_test_server()->Start());
195 110
196 ui_test_utils::NavigateToURL(browser(), 111 ui_test_utils::NavigateToURL(browser(),
197 embedded_test_server()->GetURL("/title1.html")); 112 embedded_test_server()->GetURL("/title1.html"));
198 ui_test_utils::NavigateToURL(browser(), 113 ui_test_utils::NavigateToURL(browser(),
199 embedded_test_server()->GetURL("/title1.html")); 114 embedded_test_server()->GetURL("/title1.html"));
200 NavigateToUntrackedUrl(); 115 NavigateToUntrackedUrl();
201 116
202 // We expect one histogram sample for each navigation to title1.html. 117 // We expect one histogram sample for each navigation to title1.html.
203 WaitForTimingUpdatedIPC();
204 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 2); 118 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 2);
205 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 2); 119 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 2);
206 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 2); 120 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 2);
207 } 121 }
208 122
209 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NonHtmlMainResource) { 123 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NonHtmlMainResource) {
210 ASSERT_TRUE(embedded_test_server()->Start()); 124 ASSERT_TRUE(embedded_test_server()->Start());
211 125
212 ui_test_utils::NavigateToURL(browser(), 126 ui_test_utils::NavigateToURL(browser(),
213 embedded_test_server()->GetURL("/circle.svg")); 127 embedded_test_server()->GetURL("/circle.svg"));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 194 }
281 195
282 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PreloadDocumentWrite) { 196 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PreloadDocumentWrite) {
283 ASSERT_TRUE(embedded_test_server()->Start()); 197 ASSERT_TRUE(embedded_test_server()->Start());
284 198
285 ui_test_utils::NavigateToURL( 199 ui_test_utils::NavigateToURL(
286 browser(), embedded_test_server()->GetURL( 200 browser(), embedded_test_server()->GetURL(
287 "/page_load_metrics/document_write_external_script.html")); 201 "/page_load_metrics/document_write_external_script.html"));
288 NavigateToUntrackedUrl(); 202 NavigateToUntrackedUrl();
289 203
290 WaitForTimingUpdatedIPC();
291 histogram_tester_.ExpectTotalCount( 204 histogram_tester_.ExpectTotalCount(
292 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 1); 205 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 1);
293 } 206 }
294 207
295 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPreloadDocumentWrite) { 208 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPreloadDocumentWrite) {
296 ASSERT_TRUE(embedded_test_server()->Start()); 209 ASSERT_TRUE(embedded_test_server()->Start());
297 210
298 ui_test_utils::NavigateToURL( 211 ui_test_utils::NavigateToURL(
299 browser(), embedded_test_server()->GetURL( 212 browser(), embedded_test_server()->GetURL(
300 "/page_load_metrics/document_write_no_script.html")); 213 "/page_load_metrics/document_write_no_script.html"));
(...skipping 16 matching lines...) Expand all
317 } 230 }
318 231
319 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteBlock) { 232 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteBlock) {
320 ASSERT_TRUE(embedded_test_server()->Start()); 233 ASSERT_TRUE(embedded_test_server()->Start());
321 234
322 ui_test_utils::NavigateToURL( 235 ui_test_utils::NavigateToURL(
323 browser(), embedded_test_server()->GetURL( 236 browser(), embedded_test_server()->GetURL(
324 "/page_load_metrics/document_write_script_block.html")); 237 "/page_load_metrics/document_write_script_block.html"));
325 NavigateToUntrackedUrl(); 238 NavigateToUntrackedUrl();
326 239
327 WaitForTimingUpdatedIPC();
328 histogram_tester_.ExpectTotalCount( 240 histogram_tester_.ExpectTotalCount(
329 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); 241 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1);
330 } 242 }
331 243
332 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) { 244 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) {
333 ASSERT_TRUE(embedded_test_server()->Start()); 245 ASSERT_TRUE(embedded_test_server()->Start());
334 246
335 ui_test_utils::NavigateToURL( 247 ui_test_utils::NavigateToURL(
336 browser(), embedded_test_server()->GetURL( 248 browser(), embedded_test_server()->GetURL(
337 "/page_load_metrics/document_write_script_block.html")); 249 "/page_load_metrics/document_write_script_block.html"));
338 250
339 // Reload should not log the histogram as the script is not blocked. 251 // Reload should not log the histogram as the script is not blocked.
340 ui_test_utils::NavigateToURL( 252 ui_test_utils::NavigateToURL(
341 browser(), embedded_test_server()->GetURL( 253 browser(), embedded_test_server()->GetURL(
342 "/page_load_metrics/document_write_script_block.html")); 254 "/page_load_metrics/document_write_script_block.html"));
343 255
344 ui_test_utils::NavigateToURL( 256 ui_test_utils::NavigateToURL(
345 browser(), embedded_test_server()->GetURL( 257 browser(), embedded_test_server()->GetURL(
346 "/page_load_metrics/document_write_script_block.html")); 258 "/page_load_metrics/document_write_script_block.html"));
347 259
348 WaitForTimingUpdatedIPC();
349 histogram_tester_.ExpectTotalCount( 260 histogram_tester_.ExpectTotalCount(
350 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); 261 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1);
351 262
352 NavigateToUntrackedUrl(); 263 NavigateToUntrackedUrl();
353 264
354 histogram_tester_.ExpectTotalCount( 265 histogram_tester_.ExpectTotalCount(
355 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); 266 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1);
356 267
357 histogram_tester_.ExpectTotalCount( 268 histogram_tester_.ExpectTotalCount(
358 internal::kHistogramDocWriteBlockReloadCount, 2); 269 internal::kHistogramDocWriteBlockReloadCount, 2);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // When an XHTML page contains invalid XML, it causes a paint of the error 311 // When an XHTML page contains invalid XML, it causes a paint of the error
401 // message without a layout. Page load metrics currently treats this as an 312 // message without a layout. Page load metrics currently treats this as an
402 // error. Eventually, we'll fix this by special casing the handling of 313 // error. Eventually, we'll fix this by special casing the handling of
403 // documents with non-well-formed XML on the blink side. See crbug.com/627607 314 // documents with non-well-formed XML on the blink side. See crbug.com/627607
404 // for more. 315 // for more.
405 ui_test_utils::NavigateToURL( 316 ui_test_utils::NavigateToURL(
406 browser(), 317 browser(),
407 embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml")); 318 embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml"));
408 NavigateToUntrackedUrl(); 319 NavigateToUntrackedUrl();
409 320
410 WaitForTimingUpdatedIPC();
411 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 0); 321 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 0);
412 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0); 322 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0);
413 histogram_tester_.ExpectBucketCount(page_load_metrics::internal::kErrorEvents, 323 histogram_tester_.ExpectBucketCount(page_load_metrics::internal::kErrorEvents,
414 page_load_metrics::ERR_BAD_TIMING_IPC, 1); 324 page_load_metrics::ERR_BAD_TIMING_IPC, 1);
415 } 325 }
416 326
417 // Test code that aborts provisional navigations. 327 // Test code that aborts provisional navigations.
418 // TODO(csharrison): Move these to unit tests once the navigation API in content 328 // TODO(csharrison): Move these to unit tests once the navigation API in content
419 // properly calls NavigationHandle/NavigationThrottle methods. 329 // properly calls NavigationHandle/NavigationThrottle methods.
420 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortNewNavigation) { 330 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortNewNavigation) {
421 ASSERT_TRUE(embedded_test_server()->Start()); 331 ASSERT_TRUE(embedded_test_server()->Start());
422 332
423 GURL url(embedded_test_server()->GetURL("/title1.html")); 333 GURL url(embedded_test_server()->GetURL("/title1.html"));
424 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK); 334 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK);
425 content::TestNavigationManager manager( 335 content::TestNavigationManager manager(
426 browser()->tab_strip_model()->GetActiveWebContents(), url); 336 browser()->tab_strip_model()->GetActiveWebContents(), url);
427 337
428 chrome::Navigate(&params); 338 chrome::Navigate(&params);
429 EXPECT_TRUE(manager.WaitForRequestStart()); 339 EXPECT_TRUE(manager.WaitForRequestStart());
430 340
431 GURL url2(embedded_test_server()->GetURL("/title2.html")); 341 GURL url2(embedded_test_server()->GetURL("/title2.html"));
432 chrome::NavigateParams params2(browser(), url2, 342 chrome::NavigateParams params2(browser(), url2,
433 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); 343 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
434 content::TestNavigationManager manager2( 344 content::TestNavigationManager manager2(
435 browser()->tab_strip_model()->GetActiveWebContents(), url2); 345 browser()->tab_strip_model()->GetActiveWebContents(), url2);
436 chrome::Navigate(&params2); 346 chrome::Navigate(&params2);
437 347
438 manager2.WaitForNavigationFinished(); 348 manager2.WaitForNavigationFinished();
439 WaitForTimingUpdatedIPC();
440 histogram_tester_.ExpectTotalCount( 349 histogram_tester_.ExpectTotalCount(
441 internal::kHistogramAbortNewNavigationBeforeCommit, 1); 350 internal::kHistogramAbortNewNavigationBeforeCommit, 1);
442 } 351 }
443 352
444 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortReload) { 353 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortReload) {
445 ASSERT_TRUE(embedded_test_server()->Start()); 354 ASSERT_TRUE(embedded_test_server()->Start());
446 355
447 GURL url(embedded_test_server()->GetURL("/title1.html")); 356 GURL url(embedded_test_server()->GetURL("/title1.html"));
448 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK); 357 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK);
449 content::TestNavigationManager manager( 358 content::TestNavigationManager manager(
450 browser()->tab_strip_model()->GetActiveWebContents(), url); 359 browser()->tab_strip_model()->GetActiveWebContents(), url);
451 360
452 chrome::Navigate(&params); 361 chrome::Navigate(&params);
453 EXPECT_TRUE(manager.WaitForRequestStart()); 362 EXPECT_TRUE(manager.WaitForRequestStart());
454 363
455 chrome::NavigateParams params2(browser(), url, ui::PAGE_TRANSITION_RELOAD); 364 chrome::NavigateParams params2(browser(), url, ui::PAGE_TRANSITION_RELOAD);
456 content::TestNavigationManager manager2( 365 content::TestNavigationManager manager2(
457 browser()->tab_strip_model()->GetActiveWebContents(), url); 366 browser()->tab_strip_model()->GetActiveWebContents(), url);
458 chrome::Navigate(&params2); 367 chrome::Navigate(&params2);
459 368
460 manager2.WaitForNavigationFinished(); 369 manager2.WaitForNavigationFinished();
461 WaitForTimingUpdatedIPC();
462 histogram_tester_.ExpectTotalCount( 370 histogram_tester_.ExpectTotalCount(
463 internal::kHistogramAbortReloadBeforeCommit, 1); 371 internal::kHistogramAbortReloadBeforeCommit, 1);
464 } 372 }
465 373
466 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortClose) { 374 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, AbortClose) {
467 ASSERT_TRUE(embedded_test_server()->Start()); 375 ASSERT_TRUE(embedded_test_server()->Start());
468 376
469 GURL url(embedded_test_server()->GetURL("/title1.html")); 377 GURL url(embedded_test_server()->GetURL("/title1.html"));
470 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK); 378 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_LINK);
471 content::TestNavigationManager manager( 379 content::TestNavigationManager manager(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 { 442 {
535 content::TestNavigationManager reload_manager( 443 content::TestNavigationManager reload_manager(
536 browser()->tab_strip_model()->GetActiveWebContents(), first_url); 444 browser()->tab_strip_model()->GetActiveWebContents(), first_url);
537 EXPECT_TRUE(content::ExecuteScript( 445 EXPECT_TRUE(content::ExecuteScript(
538 browser()->tab_strip_model()->GetActiveWebContents(), 446 browser()->tab_strip_model()->GetActiveWebContents(),
539 "window.location.reload();")); 447 "window.location.reload();"));
540 } 448 }
541 449
542 manager.WaitForNavigationFinished(); 450 manager.WaitForNavigationFinished();
543 451
544 WaitForTimingUpdatedIPC();
545 histogram_tester_.ExpectTotalCount( 452 histogram_tester_.ExpectTotalCount(
546 internal::kHistogramAbortClientRedirectBeforeCommit, 1); 453 internal::kHistogramAbortClientRedirectBeforeCommit, 1);
547 } 454 }
548 455
549 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, 456 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
550 FirstMeaningfulPaintRecorded) { 457 FirstMeaningfulPaintRecorded) {
551 ASSERT_TRUE(embedded_test_server()->Start()); 458 ASSERT_TRUE(embedded_test_server()->Start());
552 459
553 ui_test_utils::NavigateToURL(browser(), 460 ui_test_utils::NavigateToURL(browser(),
554 embedded_test_server()->GetURL("/title1.html")); 461 embedded_test_server()->GetURL("/title1.html"));
555 462
556 // Wait until the renderer finishes observing layouts. 463 // Wait until the renderer finishes observing layouts.
557 const int kNetworkIdleTime = 500; 464 const int kNetworkIdleTime = 500;
558 const int kMargin = 500; 465 const int kMargin = 500;
559 const std::string javascript = base::StringPrintf( 466 const std::string javascript = base::StringPrintf(
560 "setTimeout(() => window.domAutomationController.send(true), %d)", 467 "setTimeout(() => window.domAutomationController.send(true), %d)",
561 kNetworkIdleTime + kMargin); 468 kNetworkIdleTime + kMargin);
562 bool result; 469 bool result;
563 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 470 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
564 browser()->tab_strip_model()->GetActiveWebContents(), 471 browser()->tab_strip_model()->GetActiveWebContents(),
565 javascript, &result)); 472 javascript, &result));
566 EXPECT_TRUE(result); 473 EXPECT_TRUE(result);
567 474
568 NavigateToUntrackedUrl(); 475 NavigateToUntrackedUrl();
569 WaitForTimingUpdatedIPC();
570 histogram_tester_.ExpectUniqueSample( 476 histogram_tester_.ExpectUniqueSample(
571 internal::kHistogramFirstMeaningfulPaintStatus, 477 internal::kHistogramFirstMeaningfulPaintStatus,
572 internal::FIRST_MEANINGFUL_PAINT_RECORDED, 1); 478 internal::FIRST_MEANINGFUL_PAINT_RECORDED, 1);
573 histogram_tester_.ExpectTotalCount( 479 histogram_tester_.ExpectTotalCount(
574 internal::kHistogramFirstMeaningfulPaint, 1); 480 internal::kHistogramFirstMeaningfulPaint, 1);
575 histogram_tester_.ExpectTotalCount( 481 histogram_tester_.ExpectTotalCount(
576 internal::kHistogramParseStartToFirstMeaningfulPaint, 1); 482 internal::kHistogramParseStartToFirstMeaningfulPaint, 1);
577 } 483 }
578 484
579 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, 485 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
580 FirstMeaningfulPaintNotRecorded) { 486 FirstMeaningfulPaintNotRecorded) {
581 ASSERT_TRUE(embedded_test_server()->Start()); 487 ASSERT_TRUE(embedded_test_server()->Start());
582 488
583 ui_test_utils::NavigateToURL(browser(), 489 ui_test_utils::NavigateToURL(browser(),
584 embedded_test_server()->GetURL("/title1.html")); 490 embedded_test_server()->GetURL("/title1.html"));
585 491
586 // Navigate away before a FMP is reported. 492 // Navigate away before a FMP is reported.
587 NavigateToUntrackedUrl(); 493 NavigateToUntrackedUrl();
588 494
589 WaitForTimingUpdatedIPC();
590 histogram_tester_.ExpectUniqueSample( 495 histogram_tester_.ExpectUniqueSample(
591 internal::kHistogramFirstMeaningfulPaintStatus, 496 internal::kHistogramFirstMeaningfulPaintStatus,
592 internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE, 1); 497 internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE, 1);
593 histogram_tester_.ExpectTotalCount( 498 histogram_tester_.ExpectTotalCount(
594 internal::kHistogramFirstMeaningfulPaint, 0); 499 internal::kHistogramFirstMeaningfulPaint, 0);
595 histogram_tester_.ExpectTotalCount( 500 histogram_tester_.ExpectTotalCount(
596 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); 501 internal::kHistogramParseStartToFirstMeaningfulPaint, 0);
597 } 502 }
598 503
599 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, 504 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
600 NoStatePrefetchObserverCacheable) { 505 NoStatePrefetchObserverCacheable) {
601 ASSERT_TRUE(embedded_test_server()->Start()); 506 ASSERT_TRUE(embedded_test_server()->Start());
602 507
603 ui_test_utils::NavigateToURL(browser(), 508 ui_test_utils::NavigateToURL(browser(),
604 embedded_test_server()->GetURL("/title1.html")); 509 embedded_test_server()->GetURL("/title1.html"));
605 NavigateToUntrackedUrl(); 510 NavigateToUntrackedUrl();
606 511
607 WaitForTimingUpdatedIPC();
608 histogram_tester_.ExpectTotalCount( 512 histogram_tester_.ExpectTotalCount(
609 prerender::PrerenderHistograms::GetFirstContentfulPaintHistogramName( 513 prerender::PrerenderHistograms::GetFirstContentfulPaintHistogramName(
610 prerender::ORIGIN_NONE, false, true, base::TimeDelta()), 514 prerender::ORIGIN_NONE, false, true, base::TimeDelta()),
611 0); 515 0);
612 histogram_tester_.ExpectTotalCount( 516 histogram_tester_.ExpectTotalCount(
613 prerender::PrerenderHistograms::GetFirstContentfulPaintHistogramName( 517 prerender::PrerenderHistograms::GetFirstContentfulPaintHistogramName(
614 prerender::ORIGIN_NONE, false, false, base::TimeDelta()), 518 prerender::ORIGIN_NONE, false, false, base::TimeDelta()),
615 1); 519 1);
616 } 520 }
617 521
618 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, 522 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest,
619 NoStatePrefetchObserverNoStore) { 523 NoStatePrefetchObserverNoStore) {
620 ASSERT_TRUE(embedded_test_server()->Start()); 524 ASSERT_TRUE(embedded_test_server()->Start());
621 525
622 ui_test_utils::NavigateToURL(browser(), 526 ui_test_utils::NavigateToURL(browser(),
623 embedded_test_server()->GetURL("/nostore.html")); 527 embedded_test_server()->GetURL("/nostore.html"));
624 NavigateToUntrackedUrl(); 528 NavigateToUntrackedUrl();
625 529
626 WaitForTimingUpdatedIPC();
627 histogram_tester_.ExpectTotalCount( 530 histogram_tester_.ExpectTotalCount(
628 prerender::PrerenderHistograms::GetFirstContentfulPaintHistogramName( 531 prerender::PrerenderHistograms::GetFirstContentfulPaintHistogramName(
629 prerender::ORIGIN_NONE, false, true, base::TimeDelta()), 532 prerender::ORIGIN_NONE, false, true, base::TimeDelta()),
630 1); 533 1);
631 histogram_tester_.ExpectTotalCount( 534 histogram_tester_.ExpectTotalCount(
632 prerender::PrerenderHistograms::GetFirstContentfulPaintHistogramName( 535 prerender::PrerenderHistograms::GetFirstContentfulPaintHistogramName(
633 prerender::ORIGIN_NONE, false, false, base::TimeDelta()), 536 prerender::ORIGIN_NONE, false, false, base::TimeDelta()),
634 0); 537 0);
635 } 538 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698