Chromium Code Reviews| 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/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" | |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/render_process_host.h" | |
| 29 #include "content/public/browser/render_view_host.h" | |
| 27 #include "content/public/test/browser_test_utils.h" | 30 #include "content/public/test/browser_test_utils.h" |
| 28 #include "content/public/test/download_test_observer.h" | 31 #include "content/public/test/download_test_observer.h" |
| 29 #include "net/http/failing_http_transaction_factory.h" | 32 #include "net/http/failing_http_transaction_factory.h" |
| 30 #include "net/http/http_cache.h" | 33 #include "net/http/http_cache.h" |
| 31 #include "net/test/embedded_test_server/embedded_test_server.h" | 34 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 32 #include "net/test/url_request/url_request_failed_job.h" | 35 #include "net/test/url_request/url_request_failed_job.h" |
| 33 #include "net/url_request/url_request_context.h" | 36 #include "net/url_request/url_request_context.h" |
| 34 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
| 35 | 38 |
| 39 namespace { | |
| 40 | |
| 41 // Waits until a PageLoadMetricsMsg_TimingUpdated message IPC is received | |
| 42 // matching a PageLoadTiming. See WaitForMatchingIPC for details. | |
| 43 class TimingUpdatedObserver : public content::BrowserMessageFilter { | |
| 44 public: | |
| 45 explicit TimingUpdatedObserver(content::RenderWidgetHost* render_widget_host) | |
| 46 : content::BrowserMessageFilter(PageLoadMetricsMsgStart) { | |
| 47 render_widget_host->GetProcess()->AddFilter(this); | |
| 48 | |
| 49 // Roundtrip to the IO thread, to ensure that the filter is properly | |
| 50 // installed. | |
| 51 content::BrowserThread::PostTaskAndReply( | |
| 52 content::BrowserThread::IO, FROM_HERE, base::Bind(&base::DoNothing), | |
| 53 base::Bind(&TimingUpdatedObserver::Quit, this)); | |
| 54 run_loop_.reset(new base::RunLoop()); | |
| 55 run_loop_->Run(); | |
| 56 run_loop_.reset(nullptr); | |
| 57 } | |
| 58 | |
| 59 // Instructs observer to also watch for |count| | |
| 60 // WebLoadingBehaviorDocumentWriteBlockReload events. | |
| 61 void MatchDocumentWriteBlockReload(int count) { | |
| 62 match_document_write_block_reload_ = count; | |
| 63 } | |
| 64 | |
| 65 // Waits for a TimingUpdated IPC that matches the template PageLoadTiming | |
| 66 // given to the constructor. An IPC matches when its PageLoadTiming contains a | |
| 67 // non-zero field that is non-zero in the template. | |
| 68 void WaitForMatchingIPC() { | |
| 69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 70 if (matched_timing_update_) | |
| 71 return; | |
| 72 | |
| 73 run_loop_.reset(new base::RunLoop()); | |
| 74 run_loop_->Run(); | |
| 75 run_loop_.reset(nullptr); | |
| 76 } | |
| 77 | |
| 78 page_load_metrics::PageLoadTiming* template_timing() { | |
|
Bryan McQuade
2017/02/17 18:54:48
looking at this some more i think my suggestion to
mattcary
2017/02/20 10:25:25
Done.
| |
| 79 return &template_timing_; | |
| 80 } | |
| 81 | |
| 82 private: | |
| 83 bool OnMessageReceived(const IPC::Message& message) override { | |
| 84 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | |
| 85 | |
| 86 IPC_BEGIN_MESSAGE_MAP(TimingUpdatedObserver, message) | |
| 87 IPC_MESSAGE_HANDLER(PageLoadMetricsMsg_TimingUpdated, OnTimingUpdated) | |
| 88 IPC_END_MESSAGE_MAP() | |
| 89 | |
| 90 return false; | |
| 91 } | |
| 92 | |
| 93 bool OnTimingUpdated(const page_load_metrics::PageLoadTiming& timing, | |
| 94 const page_load_metrics::PageLoadMetadata& metadata) { | |
| 95 if (match_document_write_block_reload_ > 0 && | |
| 96 metadata.behavior_flags & | |
| 97 blink::WebLoadingBehaviorFlag:: | |
| 98 WebLoadingBehaviorDocumentWriteBlockReload) { | |
| 99 --match_document_write_block_reload_; | |
| 100 } | |
| 101 | |
| 102 if (match_document_write_block_reload_ > 0) { | |
| 103 return true; | |
| 104 } | |
| 105 | |
| 106 if ((!template_timing_.dom_content_loaded_event_start || | |
| 107 timing.dom_content_loaded_event_start) && | |
| 108 (!template_timing_.load_event_start || timing.load_event_start) && | |
| 109 (!template_timing_.first_layout || timing.first_layout) && | |
| 110 (!template_timing_.first_paint || timing.first_paint) && | |
| 111 (!template_timing_.first_text_paint || timing.first_text_paint) && | |
| 112 (!template_timing_.first_image_paint || timing.first_image_paint) && | |
| 113 (!template_timing_.first_contentful_paint || | |
| 114 timing.first_contentful_paint) && | |
| 115 (!template_timing_.first_meaningful_paint || | |
| 116 timing.first_meaningful_paint) && | |
| 117 (!template_timing_.parse_start || timing.parse_start) && | |
| 118 (!template_timing_.parse_stop || timing.parse_stop)) { | |
| 119 // Ensure that any other handlers of this message, for example the real | |
| 120 // PageLoadMetric observers, get a chance to handle this message before | |
| 121 // this waiter unblocks. | |
| 122 content::BrowserThread::PostTask( | |
| 123 content::BrowserThread::IO, FROM_HERE, | |
| 124 base::Bind(&TimingUpdatedObserver::BounceTimingUpdate, this, timing, | |
| 125 metadata)); | |
| 126 } | |
| 127 return true; | |
| 128 } | |
| 129 | |
| 130 void BounceTimingUpdate(const page_load_metrics::PageLoadTiming& timing, | |
| 131 const page_load_metrics::PageLoadMetadata& metadata) { | |
| 132 content::BrowserThread::PostTask( | |
| 133 content::BrowserThread::UI, FROM_HERE, | |
| 134 base::Bind(&TimingUpdatedObserver::SetTimingUpdatedAndQuit, this)); | |
| 135 } | |
| 136 | |
| 137 void Quit() { | |
| 138 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 139 if (run_loop_) | |
| 140 run_loop_->Quit(); | |
| 141 } | |
| 142 | |
| 143 void SetTimingUpdatedAndQuit() { | |
| 144 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 145 matched_timing_update_ = true; | |
| 146 Quit(); | |
| 147 } | |
| 148 | |
| 149 ~TimingUpdatedObserver() override {} | |
| 150 | |
| 151 std::unique_ptr<base::RunLoop> run_loop_; | |
| 152 page_load_metrics::PageLoadTiming template_timing_; | |
| 153 bool matched_timing_update_ = false; | |
| 154 int match_document_write_block_reload_ = 0; | |
| 155 }; | |
| 156 | |
| 157 } // namespace | |
| 158 | |
| 36 class PageLoadMetricsBrowserTest : public InProcessBrowserTest { | 159 class PageLoadMetricsBrowserTest : public InProcessBrowserTest { |
| 37 public: | 160 public: |
| 38 PageLoadMetricsBrowserTest() {} | 161 PageLoadMetricsBrowserTest() {} |
| 39 ~PageLoadMetricsBrowserTest() override {} | 162 ~PageLoadMetricsBrowserTest() override {} |
| 40 | 163 |
| 41 protected: | 164 protected: |
| 42 void NavigateToUntrackedUrl() { | 165 void NavigateToUntrackedUrl() { |
| 43 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 166 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 44 } | 167 } |
| 45 | 168 |
| 46 bool NoPageLoadMetricsRecorded() { | 169 bool NoPageLoadMetricsRecorded() { |
| 47 return histogram_tester_.GetTotalCountsForPrefix("PageLoad.").empty(); | 170 return histogram_tester_.GetTotalCountsForPrefix("PageLoad.").empty(); |
| 48 } | 171 } |
| 49 | 172 |
| 173 scoped_refptr<TimingUpdatedObserver> CreateEmptyTimingUpdatedObserver() { | |
| 174 content::WebContents* web_contents = | |
| 175 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 176 scoped_refptr<TimingUpdatedObserver> observer(new TimingUpdatedObserver( | |
| 177 web_contents->GetRenderViewHost()->GetWidget())); | |
| 178 return observer; | |
| 179 } | |
| 180 | |
| 181 scoped_refptr<TimingUpdatedObserver> CreateFCPTimingUpdatedObserver() { | |
| 182 scoped_refptr<TimingUpdatedObserver> observer = | |
| 183 CreateEmptyTimingUpdatedObserver(); | |
| 184 observer->template_timing()->first_contentful_paint = | |
| 185 base::TimeDelta::FromInternalValue(1); // Set to nonzero for matching. | |
| 186 return observer; | |
| 187 } | |
| 188 | |
| 50 base::HistogramTester histogram_tester_; | 189 base::HistogramTester histogram_tester_; |
| 51 | 190 |
| 52 private: | 191 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsBrowserTest); | 192 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsBrowserTest); |
| 54 }; | 193 }; |
| 55 | 194 |
| 56 void FailAllNetworkTransactions(net::URLRequestContextGetter* getter) { | 195 void FailAllNetworkTransactions(net::URLRequestContextGetter* getter) { |
| 57 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 196 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 58 net::HttpCache* cache( | 197 net::HttpCache* cache( |
| 59 getter->GetURLRequestContext()->http_transaction_factory()->GetCache()); | 198 getter->GetURLRequestContext()->http_transaction_factory()->GetCache()); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 browser(), embedded_test_server()->GetURL("/download-test3.gif")); | 330 browser(), embedded_test_server()->GetURL("/download-test3.gif")); |
| 192 downloads_observer.WaitForFinished(); | 331 downloads_observer.WaitForFinished(); |
| 193 | 332 |
| 194 NavigateToUntrackedUrl(); | 333 NavigateToUntrackedUrl(); |
| 195 EXPECT_TRUE(NoPageLoadMetricsRecorded()); | 334 EXPECT_TRUE(NoPageLoadMetricsRecorded()); |
| 196 } | 335 } |
| 197 | 336 |
| 198 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PreloadDocumentWrite) { | 337 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PreloadDocumentWrite) { |
| 199 ASSERT_TRUE(embedded_test_server()->Start()); | 338 ASSERT_TRUE(embedded_test_server()->Start()); |
| 200 | 339 |
| 340 scoped_refptr<TimingUpdatedObserver> fcp_observer = | |
| 341 CreateFCPTimingUpdatedObserver(); | |
| 342 | |
| 201 ui_test_utils::NavigateToURL( | 343 ui_test_utils::NavigateToURL( |
| 202 browser(), embedded_test_server()->GetURL( | 344 browser(), embedded_test_server()->GetURL( |
| 203 "/page_load_metrics/document_write_external_script.html")); | 345 "/page_load_metrics/document_write_external_script.html")); |
| 204 NavigateToUntrackedUrl(); | 346 fcp_observer->WaitForMatchingIPC(); |
| 205 | 347 |
| 206 histogram_tester_.ExpectTotalCount( | 348 histogram_tester_.ExpectTotalCount( |
| 207 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 1); | 349 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 1); |
| 208 } | 350 } |
| 209 | 351 |
| 210 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPreloadDocumentWrite) { | 352 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPreloadDocumentWrite) { |
| 211 ASSERT_TRUE(embedded_test_server()->Start()); | 353 ASSERT_TRUE(embedded_test_server()->Start()); |
| 212 | 354 |
| 213 ui_test_utils::NavigateToURL( | 355 ui_test_utils::NavigateToURL( |
| 214 browser(), embedded_test_server()->GetURL( | 356 browser(), embedded_test_server()->GetURL( |
| 215 "/page_load_metrics/document_write_no_script.html")); | 357 "/page_load_metrics/document_write_no_script.html")); |
| 216 NavigateToUntrackedUrl(); | 358 NavigateToUntrackedUrl(); |
| 217 | 359 |
| 218 histogram_tester_.ExpectTotalCount( | 360 histogram_tester_.ExpectTotalCount( |
| 219 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0); | 361 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0); |
| 220 } | 362 } |
| 221 | 363 |
| 222 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWrite) { | 364 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWrite) { |
| 223 ASSERT_TRUE(embedded_test_server()->Start()); | 365 ASSERT_TRUE(embedded_test_server()->Start()); |
| 224 | 366 |
| 367 scoped_refptr<TimingUpdatedObserver> fcp_observer = | |
| 368 CreateFCPTimingUpdatedObserver(); | |
| 369 | |
| 225 ui_test_utils::NavigateToURL(browser(), | 370 ui_test_utils::NavigateToURL(browser(), |
| 226 embedded_test_server()->GetURL("/title1.html")); | 371 embedded_test_server()->GetURL("/title1.html")); |
| 227 NavigateToUntrackedUrl(); | 372 fcp_observer->WaitForMatchingIPC(); |
| 373 | |
| 228 histogram_tester_.ExpectTotalCount( | 374 histogram_tester_.ExpectTotalCount( |
| 229 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0); | 375 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0); |
| 230 histogram_tester_.ExpectTotalCount( | 376 histogram_tester_.ExpectTotalCount( |
| 231 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 0); | 377 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 0); |
| 232 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0); | 378 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0); |
| 233 } | 379 } |
| 234 | 380 |
| 235 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteBlock) { | 381 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteBlock) { |
| 236 ASSERT_TRUE(embedded_test_server()->Start()); | 382 ASSERT_TRUE(embedded_test_server()->Start()); |
| 237 | 383 |
| 384 scoped_refptr<TimingUpdatedObserver> fcp_observer = | |
| 385 CreateFCPTimingUpdatedObserver(); | |
| 386 | |
| 238 ui_test_utils::NavigateToURL( | 387 ui_test_utils::NavigateToURL( |
| 239 browser(), embedded_test_server()->GetURL( | 388 browser(), embedded_test_server()->GetURL( |
| 240 "/page_load_metrics/document_write_script_block.html")); | 389 "/page_load_metrics/document_write_script_block.html")); |
| 241 NavigateToUntrackedUrl(); | 390 fcp_observer->WaitForMatchingIPC(); |
| 242 | 391 |
| 243 histogram_tester_.ExpectTotalCount( | 392 histogram_tester_.ExpectTotalCount( |
| 244 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | 393 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); |
| 245 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); | 394 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); |
| 246 } | 395 } |
| 247 | 396 |
| 248 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) { | 397 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) { |
| 249 ASSERT_TRUE(embedded_test_server()->Start()); | 398 ASSERT_TRUE(embedded_test_server()->Start()); |
| 250 | 399 |
| 400 scoped_refptr<TimingUpdatedObserver> fcp_observer = | |
| 401 CreateFCPTimingUpdatedObserver(); | |
| 402 scoped_refptr<TimingUpdatedObserver> reload_observer = | |
| 403 CreateEmptyTimingUpdatedObserver(); | |
| 404 reload_observer->MatchDocumentWriteBlockReload(2); | |
| 405 | |
| 251 ui_test_utils::NavigateToURL( | 406 ui_test_utils::NavigateToURL( |
| 252 browser(), embedded_test_server()->GetURL( | 407 browser(), embedded_test_server()->GetURL( |
| 253 "/page_load_metrics/document_write_script_block.html")); | 408 "/page_load_metrics/document_write_script_block.html")); |
| 254 | 409 |
| 255 // Reload should not log the histogram as the script is not blocked. | 410 // Reload should not log the histogram as the script is not blocked. |
| 256 ui_test_utils::NavigateToURL( | 411 ui_test_utils::NavigateToURL( |
| 257 browser(), embedded_test_server()->GetURL( | 412 browser(), embedded_test_server()->GetURL( |
| 258 "/page_load_metrics/document_write_script_block.html")); | 413 "/page_load_metrics/document_write_script_block.html")); |
| 259 | 414 |
| 260 ui_test_utils::NavigateToURL( | 415 ui_test_utils::NavigateToURL( |
| 261 browser(), embedded_test_server()->GetURL( | 416 browser(), embedded_test_server()->GetURL( |
| 262 "/page_load_metrics/document_write_script_block.html")); | 417 "/page_load_metrics/document_write_script_block.html")); |
| 263 | 418 |
| 264 histogram_tester_.ExpectTotalCount( | 419 histogram_tester_.ExpectTotalCount( |
| 265 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | 420 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); |
| 266 | 421 |
| 267 NavigateToUntrackedUrl(); | 422 fcp_observer->WaitForMatchingIPC(); |
| 423 reload_observer->WaitForMatchingIPC(); | |
| 268 | 424 |
| 269 histogram_tester_.ExpectTotalCount( | 425 histogram_tester_.ExpectTotalCount( |
| 270 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | 426 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); |
| 271 | 427 |
| 272 histogram_tester_.ExpectTotalCount( | 428 histogram_tester_.ExpectTotalCount( |
| 273 internal::kHistogramDocWriteBlockReloadCount, 2); | 429 internal::kHistogramDocWriteBlockReloadCount, 2); |
| 274 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); | 430 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); |
| 275 } | 431 } |
| 276 | 432 |
| 277 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteAsync) { | 433 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteAsync) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 NavigateToUntrackedUrl(); | 465 NavigateToUntrackedUrl(); |
| 310 | 466 |
| 311 histogram_tester_.ExpectTotalCount( | 467 histogram_tester_.ExpectTotalCount( |
| 312 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 0); | 468 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 0); |
| 313 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0); | 469 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0); |
| 314 } | 470 } |
| 315 | 471 |
| 316 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, BadXhtml) { | 472 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, BadXhtml) { |
| 317 ASSERT_TRUE(embedded_test_server()->Start()); | 473 ASSERT_TRUE(embedded_test_server()->Start()); |
| 318 | 474 |
| 475 scoped_refptr<TimingUpdatedObserver> timing_observer = | |
| 476 CreateEmptyTimingUpdatedObserver(); | |
| 477 timing_observer->template_timing()->first_paint = | |
| 478 base::TimeDelta::FromInternalValue(1); // Set to nonzero for matching. | |
| 479 | |
| 319 // When an XHTML page contains invalid XML, it causes a paint of the error | 480 // When an XHTML page contains invalid XML, it causes a paint of the error |
| 320 // message without a layout. Page load metrics currently treats this as an | 481 // message without a layout. Page load metrics currently treats this as an |
| 321 // error. Eventually, we'll fix this by special casing the handling of | 482 // error. Eventually, we'll fix this by special casing the handling of |
| 322 // documents with non-well-formed XML on the blink side. See crbug.com/627607 | 483 // documents with non-well-formed XML on the blink side. See crbug.com/627607 |
| 323 // for more. | 484 // for more. |
| 324 ui_test_utils::NavigateToURL( | 485 ui_test_utils::NavigateToURL( |
| 325 browser(), | 486 browser(), |
| 326 embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml")); | 487 embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml")); |
| 327 NavigateToUntrackedUrl(); | 488 |
| 489 timing_observer->WaitForMatchingIPC(); | |
| 328 | 490 |
| 329 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 0); | 491 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 0); |
| 330 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0); | 492 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0); |
| 331 histogram_tester_.ExpectBucketCount(page_load_metrics::internal::kErrorEvents, | 493 histogram_tester_.ExpectBucketCount(page_load_metrics::internal::kErrorEvents, |
| 332 page_load_metrics::ERR_BAD_TIMING_IPC, 1); | 494 page_load_metrics::ERR_BAD_TIMING_IPC, 1); |
| 333 } | 495 } |
| 334 | 496 |
| 335 // Test code that aborts provisional navigations. | 497 // Test code that aborts provisional navigations. |
| 336 // TODO(csharrison): Move these to unit tests once the navigation API in content | 498 // TODO(csharrison): Move these to unit tests once the navigation API in content |
| 337 // properly calls NavigationHandle/NavigationThrottle methods. | 499 // properly calls NavigationHandle/NavigationThrottle methods. |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 | 670 |
| 509 histogram_tester_.ExpectUniqueSample( | 671 histogram_tester_.ExpectUniqueSample( |
| 510 internal::kHistogramFirstMeaningfulPaintStatus, | 672 internal::kHistogramFirstMeaningfulPaintStatus, |
| 511 internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE, 1); | 673 internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE, 1); |
| 512 histogram_tester_.ExpectTotalCount( | 674 histogram_tester_.ExpectTotalCount( |
| 513 internal::kHistogramFirstMeaningfulPaint, 0); | 675 internal::kHistogramFirstMeaningfulPaint, 0); |
| 514 histogram_tester_.ExpectTotalCount( | 676 histogram_tester_.ExpectTotalCount( |
| 515 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); | 677 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); |
| 516 } | 678 } |
| 517 | 679 |
| 518 // Flaky on Linux (timing out or failing in an expectation) crbug.com/657022 | |
| 519 #if defined(OS_LINUX) | |
| 520 #define MAYBE_NoStatePrefetchObserverCacheable \ | |
| 521 DISABLED_NoStatePrefetchObserverCacheable | |
| 522 #else | |
| 523 #define MAYBE_NoStatePrefetchObserverCacheable NoStatePrefetchObserverCacheable | |
| 524 #endif | |
| 525 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, | 680 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, |
| 526 MAYBE_NoStatePrefetchObserverCacheable) { | 681 NoStatePrefetchObserverCacheable) { |
| 527 ASSERT_TRUE(embedded_test_server()->Start()); | 682 ASSERT_TRUE(embedded_test_server()->Start()); |
| 528 | 683 |
| 684 scoped_refptr<TimingUpdatedObserver> fcp_observer = | |
| 685 CreateFCPTimingUpdatedObserver(); | |
| 686 | |
| 529 ui_test_utils::NavigateToURL(browser(), | 687 ui_test_utils::NavigateToURL(browser(), |
| 530 embedded_test_server()->GetURL("/title1.html")); | 688 embedded_test_server()->GetURL("/title1.html")); |
| 531 NavigateToUntrackedUrl(); | 689 |
| 690 fcp_observer->WaitForMatchingIPC(); | |
| 532 | 691 |
| 533 histogram_tester_.ExpectTotalCount( | 692 histogram_tester_.ExpectTotalCount( |
| 534 "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 0); | 693 "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 0); |
| 535 histogram_tester_.ExpectTotalCount( | 694 histogram_tester_.ExpectTotalCount( |
| 536 "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 1); | 695 "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 1); |
| 537 } | 696 } |
| 538 | 697 |
| 539 // Flaky on Linux (timing out or failing in an expectation) crbug.com/657022 | |
| 540 #if defined(OS_LINUX) | |
| 541 #define MAYBE_NoStatePrefetchObserverNoStore \ | |
| 542 DISABLED_NoStatePrefetchObserverNoStore | |
| 543 #else | |
| 544 #define MAYBE_NoStatePrefetchObserverNoStore NoStatePrefetchObserverNoStore | |
| 545 #endif | |
| 546 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, | 698 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, |
| 547 MAYBE_NoStatePrefetchObserverNoStore) { | 699 NoStatePrefetchObserverNoStore) { |
| 548 ASSERT_TRUE(embedded_test_server()->Start()); | 700 ASSERT_TRUE(embedded_test_server()->Start()); |
| 549 | 701 |
| 702 scoped_refptr<TimingUpdatedObserver> fcp_observer = | |
| 703 CreateFCPTimingUpdatedObserver(); | |
| 704 | |
| 550 ui_test_utils::NavigateToURL(browser(), | 705 ui_test_utils::NavigateToURL(browser(), |
| 551 embedded_test_server()->GetURL("/nostore.html")); | 706 embedded_test_server()->GetURL("/nostore.html")); |
| 552 NavigateToUntrackedUrl(); | 707 |
| 708 fcp_observer->WaitForMatchingIPC(); | |
| 553 | 709 |
| 554 histogram_tester_.ExpectTotalCount( | 710 histogram_tester_.ExpectTotalCount( |
| 555 "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 1); | 711 "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 1); |
| 556 histogram_tester_.ExpectTotalCount( | 712 histogram_tester_.ExpectTotalCount( |
| 557 "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 0); | 713 "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 0); |
| 558 } | 714 } |
| 559 | 715 |
| 560 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, CSSTiming) { | 716 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, CSSTiming) { |
| 561 ASSERT_TRUE(embedded_test_server()->Start()); | 717 ASSERT_TRUE(embedded_test_server()->Start()); |
| 562 | 718 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 584 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( | 740 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( |
| 585 "/page_load_metrics/large.html")); | 741 "/page_load_metrics/large.html")); |
| 586 NavigateToUntrackedUrl(); | 742 NavigateToUntrackedUrl(); |
| 587 | 743 |
| 588 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); | 744 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); |
| 589 | 745 |
| 590 // Verify that there is a single sample recorded in the 10kB bucket (the size | 746 // Verify that there is a single sample recorded in the 10kB bucket (the size |
| 591 // of the main HTML response). | 747 // of the main HTML response). |
| 592 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); | 748 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); |
| 593 } | 749 } |
| OLD | NEW |