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/command_line.h" | |
| 6 #include "base/feature_list.h" | |
| 5 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 6 #include "base/macros.h" | 8 #include "base/macros.h" |
| 7 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
| 8 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 9 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 10 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" | 12 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
| 11 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h" | 13 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h" |
| 12 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" | 14 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" |
| 13 #include "chrome/browser/page_load_metrics/observers/document_write_page_load_me trics_observer.h" | 15 #include "chrome/browser/page_load_metrics/observers/document_write_page_load_me trics_observer.h" |
| 14 #include "chrome/browser/page_load_metrics/observers/no_state_prefetch_page_load _metrics_observer.h" | 16 #include "chrome/browser/page_load_metrics/observers/no_state_prefetch_page_load _metrics_observer.h" |
| 15 #include "chrome/browser/page_load_metrics/page_load_tracker.h" | 17 #include "chrome/browser/page_load_metrics/page_load_tracker.h" |
| 16 #include "chrome/browser/prerender/prerender_histograms.h" | 18 #include "chrome/browser/prerender/prerender_histograms.h" |
| 17 #include "chrome/browser/prerender/prerender_origin.h" | 19 #include "chrome/browser/prerender/prerender_origin.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_navigator_params.h" | 22 #include "chrome/browser/ui/browser_navigator_params.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h" | 24 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h" |
| 23 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 25 #include "chrome/test/base/in_process_browser_test.h" | 27 #include "chrome/test/base/in_process_browser_test.h" |
| 26 #include "chrome/test/base/ui_test_utils.h" | 28 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "components/prefs/pref_service.h" | 29 #include "components/prefs/pref_service.h" |
| 28 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 30 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 33 #include "content/public/common/content_switches.h" | |
| 31 #include "content/public/test/browser_test_utils.h" | 34 #include "content/public/test/browser_test_utils.h" |
| 32 #include "content/public/test/download_test_observer.h" | 35 #include "content/public/test/download_test_observer.h" |
| 36 #include "net/dns/mock_host_resolver.h" | |
| 33 #include "net/http/failing_http_transaction_factory.h" | 37 #include "net/http/failing_http_transaction_factory.h" |
| 34 #include "net/http/http_cache.h" | 38 #include "net/http/http_cache.h" |
| 35 #include "net/test/embedded_test_server/embedded_test_server.h" | 39 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 36 #include "net/test/url_request/url_request_failed_job.h" | 40 #include "net/test/url_request/url_request_failed_job.h" |
| 37 #include "net/url_request/url_request_context.h" | 41 #include "net/url_request/url_request_context.h" |
| 38 #include "net/url_request/url_request_context_getter.h" | 42 #include "net/url_request/url_request_context_getter.h" |
| 39 | 43 |
| 40 namespace { | 44 namespace { |
| 41 | 45 |
| 42 // Waits until specified timing and metadata expectations are satisfied. | 46 // Waits until specified timing and metadata expectations are satisfied. |
| 43 class PageLoadMetricsWaiter | 47 class PageLoadMetricsWaiter |
| 44 : public page_load_metrics::MetricsWebContentsObserver::TestingObserver { | 48 : public page_load_metrics::MetricsWebContentsObserver::TestingObserver { |
| 45 public: | 49 public: |
| 46 // A bitvector to express which timing fields to match on. | 50 // A bitvector to express which timing fields to match on. |
| 47 enum ExpectedTimingFields { | 51 enum ExpectedTimingFields { |
|
jkarlin
2017/05/10 16:55:28
enum class
Bryan McQuade
2017/05/10 18:06:15
thanks! i moved this whole change to https://coder
| |
| 48 FIRST_PAINT = 1 << 0, | 52 FIRST_LAYOUT = 1 << 0, |
| 49 FIRST_CONTENTFUL_PAINT = 1 << 1, | 53 FIRST_PAINT = 1 << 1, |
| 50 STYLE_UPDATE_BEFORE_FCP = 1 << 2 | 54 FIRST_CONTENTFUL_PAINT = 1 << 2, |
| 55 STYLE_UPDATE_BEFORE_FCP = 1 << 3, | |
| 56 DOCUMENT_WRITE_BLOCK_RELOAD = 1 << 4 | |
| 51 }; | 57 }; |
| 52 | 58 |
| 53 explicit PageLoadMetricsWaiter(content::WebContents* web_contents) | 59 explicit PageLoadMetricsWaiter(content::WebContents* web_contents) |
| 54 : TestingObserver(web_contents) {} | 60 : TestingObserver(web_contents) {} |
| 55 | 61 |
| 56 ~PageLoadMetricsWaiter() override { DCHECK_EQ(nullptr, run_loop_.get()); } | 62 ~PageLoadMetricsWaiter() override { DCHECK_EQ(nullptr, run_loop_.get()); } |
| 57 | 63 |
| 58 // Add the given expectation to match on. | 64 // Add the given expectation to match on. |
| 59 void AddExpectation(ExpectedTimingFields fields) { | 65 void AddMainFrameExpectation(ExpectedTimingFields fields) { |
| 60 matching_fields_ |= fields; | 66 main_frame_expected_fields_ |= fields; |
| 61 } | 67 } |
| 62 | 68 void AddSubFrameExpectation(ExpectedTimingFields fields) { |
| 63 // Instructs observer to also watch for |count| | 69 child_frame_expected_fields_ |= fields; |
| 64 // WebLoadingBehaviorDocumentWriteBlockReload events. | |
| 65 void ExpectDocumentWriteBlockReload(int count) { | |
| 66 match_document_write_block_reload_ = count; | |
| 67 } | 70 } |
| 68 | 71 |
| 69 // Waits for a TimingUpdated IPC that matches the fields set by | 72 // Waits for a TimingUpdated IPC that matches the fields set by |
| 70 // |AddExpectation|. All matching fields must be set in a TimingUpdated | 73 // |AddExpectation|. All matching fields must be set in a TimingUpdated |
| 71 // IPC for it to end this wait. | 74 // IPC for it to end this wait. |
| 72 void Wait() { | 75 void Wait() { |
| 73 if (expectations_satisfied_) | 76 if (expectations_satisfied_) |
| 74 return; | 77 return; |
| 75 | 78 |
| 76 run_loop_.reset(new base::RunLoop()); | 79 run_loop_.reset(new base::RunLoop()); |
| 77 run_loop_->Run(); | 80 run_loop_->Run(); |
| 78 run_loop_.reset(nullptr); | 81 run_loop_.reset(nullptr); |
| 79 | 82 |
| 80 EXPECT_TRUE(expectations_satisfied_); | 83 EXPECT_TRUE(expectations_satisfied_); |
| 81 } | 84 } |
| 82 | 85 |
| 83 private: | 86 private: |
| 87 static int GetMatchedBits( | |
| 88 const page_load_metrics::PageLoadTiming& timing, | |
| 89 const page_load_metrics::PageLoadMetadata& metadata) { | |
| 90 int matched_bits = 0; | |
| 91 if (timing.document_timing.first_layout) | |
| 92 matched_bits |= FIRST_LAYOUT; | |
| 93 if (timing.paint_timing.first_paint) | |
| 94 matched_bits |= FIRST_PAINT; | |
| 95 if (timing.paint_timing.first_contentful_paint) | |
| 96 matched_bits |= FIRST_CONTENTFUL_PAINT; | |
| 97 if (timing.style_sheet_timing.update_style_duration_before_fcp) | |
| 98 matched_bits |= STYLE_UPDATE_BEFORE_FCP; | |
| 99 if (metadata.behavior_flags & | |
| 100 blink::WebLoadingBehaviorFlag:: | |
| 101 kWebLoadingBehaviorDocumentWriteBlockReload) | |
| 102 matched_bits |= DOCUMENT_WRITE_BLOCK_RELOAD; | |
| 103 | |
| 104 return matched_bits; | |
| 105 } | |
| 106 | |
| 84 void OnTimingUpdated( | 107 void OnTimingUpdated( |
| 108 bool is_main_frame, | |
| 85 const page_load_metrics::PageLoadTiming& timing, | 109 const page_load_metrics::PageLoadTiming& timing, |
| 86 const page_load_metrics::PageLoadMetadata& metadata) override { | 110 const page_load_metrics::PageLoadMetadata& metadata) override { |
| 87 if (match_document_write_block_reload_ > 0 && | 111 if (expectations_satisfied_) |
| 88 metadata.behavior_flags & | 112 return; |
| 89 blink::WebLoadingBehaviorFlag:: | |
| 90 kWebLoadingBehaviorDocumentWriteBlockReload) { | |
| 91 --match_document_write_block_reload_; | |
| 92 } | |
| 93 | 113 |
| 94 if (match_document_write_block_reload_ > 0) { | 114 int matched_bits = GetMatchedBits(timing, metadata); |
| 95 return; | 115 if (is_main_frame) |
| 96 } | 116 main_frame_expected_fields_ &= ~matched_bits; |
|
jkarlin
2017/05/10 16:55:28
Maybe add a comment that we're incrementally remov
Bryan McQuade
2017/05/10 18:06:15
i think the refactor i did in the other change mak
| |
| 117 else | |
| 118 child_frame_expected_fields_ &= ~matched_bits; | |
| 97 | 119 |
| 98 if ((!(matching_fields_ & FIRST_PAINT) || | 120 if (main_frame_expected_fields_ == 0 && child_frame_expected_fields_ == 0) { |
| 99 timing.paint_timing.first_paint) && | |
| 100 (!(matching_fields_ & FIRST_CONTENTFUL_PAINT) || | |
| 101 timing.paint_timing.first_contentful_paint) && | |
| 102 (!(matching_fields_ & STYLE_UPDATE_BEFORE_FCP) || | |
| 103 timing.style_sheet_timing.update_style_duration_before_fcp)) { | |
| 104 expectations_satisfied_ = true; | 121 expectations_satisfied_ = true; |
| 105 if (run_loop_) | 122 if (run_loop_) |
| 106 run_loop_->Quit(); | 123 run_loop_->Quit(); |
| 107 } | 124 } |
| 108 } | 125 } |
| 109 | 126 |
| 110 std::unique_ptr<base::RunLoop> run_loop_; | 127 std::unique_ptr<base::RunLoop> run_loop_; |
| 111 int matching_fields_ = 0; // A bitvector composed from ExpectedTimingFields. | 128 |
| 129 // Bitvectors composed from ExpectedTimingFields. | |
| 130 int child_frame_expected_fields_ = 0; | |
| 131 int main_frame_expected_fields_ = 0; | |
| 132 | |
| 112 bool expectations_satisfied_ = false; | 133 bool expectations_satisfied_ = false; |
|
jkarlin
2017/05/10 16:55:28
expectations_satisfied_ can be replaced with main_
Bryan McQuade
2017/05/10 18:06:15
done in other change
| |
| 113 int match_document_write_block_reload_ = 0; | |
| 114 }; | 134 }; |
| 115 | 135 |
| 136 // Due to crbug/705315, paints in child frames are associated with the main | |
| 137 // frame, unless the child frame is cross-origin and Chrome is running with out | |
| 138 // of process cross-origin child frames. As a result, some tests wait for | |
| 139 // different behavior to be observed depending on which mode we are in. | |
| 140 // TODO(crbug/705315): remove this method once the bug is addressed. | |
| 141 static bool AreCrossOriginChildFramesOutOfProcess() { | |
| 142 return base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 143 switches::kSitePerProcess) || | |
| 144 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 145 switches::kTopDocumentIsolation); | |
| 146 } | |
| 147 | |
| 116 } // namespace | 148 } // namespace |
| 117 | 149 |
| 118 class PageLoadMetricsBrowserTest : public InProcessBrowserTest { | 150 class PageLoadMetricsBrowserTest : public InProcessBrowserTest { |
| 119 public: | 151 public: |
| 120 PageLoadMetricsBrowserTest() {} | 152 PageLoadMetricsBrowserTest() {} |
| 121 ~PageLoadMetricsBrowserTest() override {} | 153 ~PageLoadMetricsBrowserTest() override {} |
| 122 | 154 |
| 123 protected: | 155 protected: |
| 124 void NavigateToUntrackedUrl() { | 156 void NavigateToUntrackedUrl() { |
| 125 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | 157 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); |
| 126 } | 158 } |
| 127 | 159 |
| 160 // TODO(crbug/705315): remove this method once the bug is addressed. | |
| 161 void SetUpOnMainThread() override { | |
| 162 InProcessBrowserTest::SetUpOnMainThread(); | |
| 163 host_resolver()->AddRule("a.com", "127.0.0.1"); | |
| 164 host_resolver()->AddRule("b.com", "127.0.0.1"); | |
| 165 host_resolver()->AddRule("c.com", "127.0.0.1"); | |
| 166 content::SetupCrossSiteRedirector(embedded_test_server()); | |
| 167 } | |
| 168 | |
| 128 bool NoPageLoadMetricsRecorded() { | 169 bool NoPageLoadMetricsRecorded() { |
| 129 // Determine whether any 'public' page load metrics are recorded. We exclude | 170 // Determine whether any 'public' page load metrics are recorded. We exclude |
| 130 // 'internal' metrics as these may be recorded for debugging purposes. | 171 // 'internal' metrics as these may be recorded for debugging purposes. |
| 131 size_t total_pageload_histograms = | 172 size_t total_pageload_histograms = |
| 132 histogram_tester_.GetTotalCountsForPrefix("PageLoad.").size(); | 173 histogram_tester_.GetTotalCountsForPrefix("PageLoad.").size(); |
| 133 size_t total_internal_histograms = | 174 size_t total_internal_histograms = |
| 134 histogram_tester_.GetTotalCountsForPrefix("PageLoad.Internal.").size(); | 175 histogram_tester_.GetTotalCountsForPrefix("PageLoad.Internal.").size(); |
| 135 DCHECK_GE(total_pageload_histograms, total_internal_histograms); | 176 DCHECK_GE(total_pageload_histograms, total_internal_histograms); |
| 136 return total_pageload_histograms - total_internal_histograms == 0; | 177 return total_pageload_histograms - total_internal_histograms == 0; |
| 137 } | 178 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 162 } | 203 } |
| 163 | 204 |
| 164 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoNavigation) { | 205 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoNavigation) { |
| 165 ASSERT_TRUE(embedded_test_server()->Start()); | 206 ASSERT_TRUE(embedded_test_server()->Start()); |
| 166 EXPECT_TRUE(NoPageLoadMetricsRecorded()); | 207 EXPECT_TRUE(NoPageLoadMetricsRecorded()); |
| 167 } | 208 } |
| 168 | 209 |
| 169 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NewPage) { | 210 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NewPage) { |
| 170 ASSERT_TRUE(embedded_test_server()->Start()); | 211 ASSERT_TRUE(embedded_test_server()->Start()); |
| 171 | 212 |
| 213 std::unique_ptr<PageLoadMetricsWaiter> timing_waiter = | |
| 214 CreatePageLoadMetricsWaiter(); | |
| 215 timing_waiter->AddMainFrameExpectation(PageLoadMetricsWaiter::FIRST_PAINT); | |
| 172 ui_test_utils::NavigateToURL(browser(), | 216 ui_test_utils::NavigateToURL(browser(), |
| 173 embedded_test_server()->GetURL("/title1.html")); | 217 embedded_test_server()->GetURL("/title1.html")); |
| 218 timing_waiter->Wait(); | |
| 174 NavigateToUntrackedUrl(); | 219 NavigateToUntrackedUrl(); |
| 175 | 220 |
| 176 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1); | 221 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1); |
| 177 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1); | 222 histogram_tester_.ExpectTotalCount(internal::kHistogramLoad, 1); |
| 178 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); | 223 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); |
| 224 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 1); | |
| 179 histogram_tester_.ExpectTotalCount(internal::kHistogramParseDuration, 1); | 225 histogram_tester_.ExpectTotalCount(internal::kHistogramParseDuration, 1); |
| 180 histogram_tester_.ExpectTotalCount( | 226 histogram_tester_.ExpectTotalCount( |
| 181 internal::kHistogramParseBlockedOnScriptLoad, 1); | 227 internal::kHistogramParseBlockedOnScriptLoad, 1); |
| 182 histogram_tester_.ExpectTotalCount( | 228 histogram_tester_.ExpectTotalCount( |
| 183 internal::kHistogramParseBlockedOnScriptExecution, 1); | 229 internal::kHistogramParseBlockedOnScriptExecution, 1); |
| 184 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); | 230 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); |
| 185 histogram_tester_.ExpectTotalCount( | 231 histogram_tester_.ExpectTotalCount( |
| 186 internal::kHistogramPageTimingForegroundDuration, 1); | 232 internal::kHistogramPageTimingForegroundDuration, 1); |
| 187 | 233 |
| 188 // Verify that NoPageLoadMetricsRecorded returns false when PageLoad metrics | 234 // Verify that NoPageLoadMetricsRecorded returns false when PageLoad metrics |
| 189 // have been recorded. | 235 // have been recorded. |
| 190 EXPECT_FALSE(NoPageLoadMetricsRecorded()); | 236 EXPECT_FALSE(NoPageLoadMetricsRecorded()); |
| 191 } | 237 } |
| 192 | 238 |
| 239 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPaintForEmptyDocument) { | |
| 240 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 241 | |
| 242 std::unique_ptr<PageLoadMetricsWaiter> timing_waiter = | |
| 243 CreatePageLoadMetricsWaiter(); | |
| 244 timing_waiter->AddMainFrameExpectation(PageLoadMetricsWaiter::FIRST_LAYOUT); | |
| 245 ui_test_utils::NavigateToURL(browser(), | |
| 246 embedded_test_server()->GetURL("/empty.html")); | |
| 247 timing_waiter->Wait(); | |
| 248 | |
| 249 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); | |
| 250 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0); | |
| 251 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstContentfulPaint, | |
| 252 0); | |
| 253 } | |
| 254 | |
| 255 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, | |
| 256 NoPaintForEmptyDocumentInChildFrame) { | |
| 257 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 258 | |
| 259 std::unique_ptr<PageLoadMetricsWaiter> timing_waiter = | |
| 260 CreatePageLoadMetricsWaiter(); | |
| 261 timing_waiter->AddMainFrameExpectation(PageLoadMetricsWaiter::FIRST_LAYOUT); | |
| 262 timing_waiter->AddSubFrameExpectation(PageLoadMetricsWaiter::FIRST_LAYOUT); | |
| 263 // TODO(crbug/705315): remove the a.com domain once the bug is addressed. | |
| 264 GURL a_url(embedded_test_server()->GetURL( | |
| 265 "a.com", "/page_load_metrics/empty_iframe.html")); | |
| 266 ui_test_utils::NavigateToURL(browser(), a_url); | |
| 267 timing_waiter->Wait(); | |
| 268 | |
| 269 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); | |
| 270 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 0); | |
| 271 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstContentfulPaint, | |
| 272 0); | |
| 273 } | |
| 274 | |
| 275 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PaintInChildFrame) { | |
|
jkarlin
2017/05/10 16:55:28
I'd like to see a set of tests w/ mocked navigatio
Bryan McQuade
2017/05/10 18:06:15
i'd like to do this in a unit test too, and we onc
| |
| 276 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 277 | |
| 278 std::unique_ptr<PageLoadMetricsWaiter> timing_waiter = | |
| 279 CreatePageLoadMetricsWaiter(); | |
| 280 // TODO(crbug/705315): Once the bug is fixed, remove the else case and make | |
| 281 // the if case the default behavior. | |
| 282 if (AreCrossOriginChildFramesOutOfProcess()) { | |
| 283 timing_waiter->AddSubFrameExpectation(PageLoadMetricsWaiter::FIRST_PAINT); | |
| 284 timing_waiter->AddSubFrameExpectation( | |
| 285 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 286 } else { | |
| 287 timing_waiter->AddMainFrameExpectation(PageLoadMetricsWaiter::FIRST_PAINT); | |
| 288 timing_waiter->AddMainFrameExpectation( | |
| 289 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 290 } | |
| 291 // TODO(crbug/705315): remove the a.com domain once the bug is addressed. | |
| 292 GURL a_url(embedded_test_server()->GetURL("a.com", | |
| 293 "/page_load_metrics/iframe.html")); | |
| 294 ui_test_utils::NavigateToURL(browser(), a_url); | |
| 295 timing_waiter->Wait(); | |
| 296 | |
| 297 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); | |
| 298 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 1); | |
| 299 } | |
| 300 | |
| 301 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PaintInMultipleChildFrames) { | |
| 302 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 303 | |
| 304 std::unique_ptr<PageLoadMetricsWaiter> timing_waiter = | |
| 305 CreatePageLoadMetricsWaiter(); | |
| 306 // TODO(crbug/705315): Once the bug is fixed, remove the else case and make | |
| 307 // the if case the default behavior. | |
| 308 if (AreCrossOriginChildFramesOutOfProcess()) { | |
| 309 timing_waiter->AddSubFrameExpectation(PageLoadMetricsWaiter::FIRST_PAINT); | |
| 310 timing_waiter->AddSubFrameExpectation( | |
| 311 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 312 } else { | |
| 313 timing_waiter->AddMainFrameExpectation(PageLoadMetricsWaiter::FIRST_PAINT); | |
| 314 timing_waiter->AddMainFrameExpectation( | |
| 315 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 316 } | |
| 317 | |
| 318 // TODO(crbug/705315): remove the a.com domain once the bug is addressed. | |
| 319 GURL a_url(embedded_test_server()->GetURL("a.com", | |
| 320 "/page_load_metrics/iframes.html")); | |
| 321 ui_test_utils::NavigateToURL(browser(), a_url); | |
| 322 timing_waiter->Wait(); | |
| 323 | |
| 324 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); | |
| 325 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 1); | |
| 326 } | |
| 327 | |
| 328 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PaintInMainAndChildFrame) { | |
| 329 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 330 | |
| 331 std::unique_ptr<PageLoadMetricsWaiter> timing_waiter = | |
| 332 CreatePageLoadMetricsWaiter(); | |
| 333 timing_waiter->AddMainFrameExpectation(PageLoadMetricsWaiter::FIRST_PAINT); | |
| 334 timing_waiter->AddMainFrameExpectation( | |
| 335 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 336 // TODO(crbug/705315): Once the bug is fixed, make the if case the default | |
| 337 // behavior. | |
| 338 if (AreCrossOriginChildFramesOutOfProcess()) { | |
| 339 timing_waiter->AddSubFrameExpectation(PageLoadMetricsWaiter::FIRST_PAINT); | |
| 340 timing_waiter->AddSubFrameExpectation( | |
| 341 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 342 } | |
| 343 | |
| 344 // TODO(crbug/705315): remove the a.com domain once the bug is addressed. | |
| 345 GURL a_url(embedded_test_server()->GetURL( | |
| 346 "a.com", "/page_load_metrics/main_frame_with_iframe.html")); | |
| 347 ui_test_utils::NavigateToURL(browser(), a_url); | |
| 348 timing_waiter->Wait(); | |
| 349 | |
| 350 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstLayout, 1); | |
| 351 histogram_tester_.ExpectTotalCount(internal::kHistogramFirstPaint, 1); | |
| 352 } | |
| 353 | |
| 193 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameDocumentNavigation) { | 354 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, SameDocumentNavigation) { |
| 194 ASSERT_TRUE(embedded_test_server()->Start()); | 355 ASSERT_TRUE(embedded_test_server()->Start()); |
| 195 | 356 |
| 196 ui_test_utils::NavigateToURL(browser(), | 357 ui_test_utils::NavigateToURL(browser(), |
| 197 embedded_test_server()->GetURL("/title1.html")); | 358 embedded_test_server()->GetURL("/title1.html")); |
| 198 ui_test_utils::NavigateToURL( | 359 ui_test_utils::NavigateToURL( |
| 199 browser(), embedded_test_server()->GetURL("/title1.html#hash")); | 360 browser(), embedded_test_server()->GetURL("/title1.html#hash")); |
| 200 NavigateToUntrackedUrl(); | 361 NavigateToUntrackedUrl(); |
| 201 | 362 |
| 202 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1); | 363 histogram_tester_.ExpectTotalCount(internal::kHistogramDomContentLoaded, 1); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 | 452 |
| 292 NavigateToUntrackedUrl(); | 453 NavigateToUntrackedUrl(); |
| 293 EXPECT_TRUE(NoPageLoadMetricsRecorded()); | 454 EXPECT_TRUE(NoPageLoadMetricsRecorded()); |
| 294 } | 455 } |
| 295 | 456 |
| 296 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PreloadDocumentWrite) { | 457 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, PreloadDocumentWrite) { |
| 297 ASSERT_TRUE(embedded_test_server()->Start()); | 458 ASSERT_TRUE(embedded_test_server()->Start()); |
| 298 | 459 |
| 299 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = | 460 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = |
| 300 CreatePageLoadMetricsWaiter(); | 461 CreatePageLoadMetricsWaiter(); |
| 301 fcp_waiter->AddExpectation(PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | 462 fcp_waiter->AddMainFrameExpectation( |
| 463 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 302 | 464 |
| 303 ui_test_utils::NavigateToURL( | 465 ui_test_utils::NavigateToURL( |
| 304 browser(), embedded_test_server()->GetURL( | 466 browser(), embedded_test_server()->GetURL( |
| 305 "/page_load_metrics/document_write_external_script.html")); | 467 "/page_load_metrics/document_write_external_script.html")); |
| 306 fcp_waiter->Wait(); | 468 fcp_waiter->Wait(); |
| 307 | 469 |
| 308 histogram_tester_.ExpectTotalCount( | 470 histogram_tester_.ExpectTotalCount( |
| 309 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 1); | 471 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 1); |
| 310 } | 472 } |
| 311 | 473 |
| 312 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPreloadDocumentWrite) { | 474 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoPreloadDocumentWrite) { |
| 313 ASSERT_TRUE(embedded_test_server()->Start()); | 475 ASSERT_TRUE(embedded_test_server()->Start()); |
| 314 | 476 |
| 315 ui_test_utils::NavigateToURL( | 477 ui_test_utils::NavigateToURL( |
| 316 browser(), embedded_test_server()->GetURL( | 478 browser(), embedded_test_server()->GetURL( |
| 317 "/page_load_metrics/document_write_no_script.html")); | 479 "/page_load_metrics/document_write_no_script.html")); |
| 318 NavigateToUntrackedUrl(); | 480 NavigateToUntrackedUrl(); |
| 319 | 481 |
| 320 histogram_tester_.ExpectTotalCount( | 482 histogram_tester_.ExpectTotalCount( |
| 321 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0); | 483 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0); |
| 322 } | 484 } |
| 323 | 485 |
| 324 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWrite) { | 486 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, NoDocumentWrite) { |
| 325 ASSERT_TRUE(embedded_test_server()->Start()); | 487 ASSERT_TRUE(embedded_test_server()->Start()); |
| 326 | 488 |
| 327 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = | 489 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = |
| 328 CreatePageLoadMetricsWaiter(); | 490 CreatePageLoadMetricsWaiter(); |
| 329 fcp_waiter->AddExpectation(PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | 491 fcp_waiter->AddMainFrameExpectation( |
| 492 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 330 | 493 |
| 331 ui_test_utils::NavigateToURL(browser(), | 494 ui_test_utils::NavigateToURL(browser(), |
| 332 embedded_test_server()->GetURL("/title1.html")); | 495 embedded_test_server()->GetURL("/title1.html")); |
| 333 fcp_waiter->Wait(); | 496 fcp_waiter->Wait(); |
| 334 | 497 |
| 335 histogram_tester_.ExpectTotalCount( | 498 histogram_tester_.ExpectTotalCount( |
| 336 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0); | 499 internal::kHistogramDocWriteParseStartToFirstContentfulPaint, 0); |
| 337 histogram_tester_.ExpectTotalCount( | 500 histogram_tester_.ExpectTotalCount( |
| 338 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 0); | 501 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 0); |
| 339 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0); | 502 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 0); |
| 340 } | 503 } |
| 341 | 504 |
| 342 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteBlock) { | 505 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteBlock) { |
| 343 ASSERT_TRUE(embedded_test_server()->Start()); | 506 ASSERT_TRUE(embedded_test_server()->Start()); |
| 344 | 507 |
| 345 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = | 508 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = |
| 346 CreatePageLoadMetricsWaiter(); | 509 CreatePageLoadMetricsWaiter(); |
| 347 fcp_waiter->AddExpectation(PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | 510 fcp_waiter->AddMainFrameExpectation( |
| 511 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 348 | 512 |
| 349 ui_test_utils::NavigateToURL( | 513 ui_test_utils::NavigateToURL( |
| 350 browser(), embedded_test_server()->GetURL( | 514 browser(), embedded_test_server()->GetURL( |
| 351 "/page_load_metrics/document_write_script_block.html")); | 515 "/page_load_metrics/document_write_script_block.html")); |
| 352 fcp_waiter->Wait(); | 516 fcp_waiter->Wait(); |
| 353 | 517 |
| 354 histogram_tester_.ExpectTotalCount( | 518 histogram_tester_.ExpectTotalCount( |
| 355 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | 519 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); |
| 356 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); | 520 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); |
| 357 } | 521 } |
| 358 | 522 |
| 359 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) { | 523 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, DocumentWriteReload) { |
| 360 ASSERT_TRUE(embedded_test_server()->Start()); | 524 ASSERT_TRUE(embedded_test_server()->Start()); |
| 361 | 525 |
| 362 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = | 526 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = |
| 363 CreatePageLoadMetricsWaiter(); | 527 CreatePageLoadMetricsWaiter(); |
| 364 fcp_waiter->AddExpectation(PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | 528 fcp_waiter->AddMainFrameExpectation( |
| 365 std::unique_ptr<PageLoadMetricsWaiter> reload_waiter = | 529 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); |
| 366 CreatePageLoadMetricsWaiter(); | |
| 367 reload_waiter->ExpectDocumentWriteBlockReload(2); | |
| 368 | |
| 369 ui_test_utils::NavigateToURL( | 530 ui_test_utils::NavigateToURL( |
| 370 browser(), embedded_test_server()->GetURL( | 531 browser(), embedded_test_server()->GetURL( |
| 371 "/page_load_metrics/document_write_script_block.html")); | 532 "/page_load_metrics/document_write_script_block.html")); |
| 533 fcp_waiter->Wait(); | |
| 534 | |
| 535 histogram_tester_.ExpectTotalCount( | |
| 536 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | |
| 537 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); | |
| 372 | 538 |
| 373 // Reload should not log the histogram as the script is not blocked. | 539 // Reload should not log the histogram as the script is not blocked. |
| 540 std::unique_ptr<PageLoadMetricsWaiter> reload_waiter = | |
| 541 CreatePageLoadMetricsWaiter(); | |
| 542 reload_waiter->AddMainFrameExpectation( | |
| 543 PageLoadMetricsWaiter::DOCUMENT_WRITE_BLOCK_RELOAD); | |
| 544 reload_waiter->AddMainFrameExpectation( | |
| 545 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 374 ui_test_utils::NavigateToURL( | 546 ui_test_utils::NavigateToURL( |
| 375 browser(), embedded_test_server()->GetURL( | 547 browser(), embedded_test_server()->GetURL( |
| 376 "/page_load_metrics/document_write_script_block.html")); | 548 "/page_load_metrics/document_write_script_block.html")); |
| 549 reload_waiter->Wait(); | |
| 377 | 550 |
| 551 reload_waiter = CreatePageLoadMetricsWaiter(); | |
| 552 reload_waiter->AddMainFrameExpectation( | |
| 553 PageLoadMetricsWaiter::DOCUMENT_WRITE_BLOCK_RELOAD); | |
| 554 reload_waiter->AddMainFrameExpectation( | |
| 555 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 378 ui_test_utils::NavigateToURL( | 556 ui_test_utils::NavigateToURL( |
| 379 browser(), embedded_test_server()->GetURL( | 557 browser(), embedded_test_server()->GetURL( |
| 380 "/page_load_metrics/document_write_script_block.html")); | 558 "/page_load_metrics/document_write_script_block.html")); |
| 381 | |
| 382 histogram_tester_.ExpectTotalCount( | |
| 383 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | |
| 384 | |
| 385 fcp_waiter->Wait(); | |
| 386 reload_waiter->Wait(); | 559 reload_waiter->Wait(); |
| 387 | 560 |
| 388 histogram_tester_.ExpectTotalCount( | 561 histogram_tester_.ExpectTotalCount( |
| 389 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); | 562 internal::kHistogramDocWriteBlockParseStartToFirstContentfulPaint, 1); |
| 390 | 563 |
| 391 histogram_tester_.ExpectTotalCount( | 564 histogram_tester_.ExpectTotalCount( |
| 392 internal::kHistogramDocWriteBlockReloadCount, 2); | 565 internal::kHistogramDocWriteBlockReloadCount, 2); |
| 393 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); | 566 histogram_tester_.ExpectTotalCount(internal::kHistogramDocWriteBlockCount, 1); |
| 394 } | 567 } |
| 395 | 568 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 #if defined(OS_LINUX) && !defined(NDEBUG) | 609 #if defined(OS_LINUX) && !defined(NDEBUG) |
| 437 #define MAYBE_BadXhtml DISABLED_BadXhtml | 610 #define MAYBE_BadXhtml DISABLED_BadXhtml |
| 438 #else | 611 #else |
| 439 #define MAYBE_BadXhtml BadXhtml | 612 #define MAYBE_BadXhtml BadXhtml |
| 440 #endif | 613 #endif |
| 441 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_BadXhtml) { | 614 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, MAYBE_BadXhtml) { |
| 442 ASSERT_TRUE(embedded_test_server()->Start()); | 615 ASSERT_TRUE(embedded_test_server()->Start()); |
| 443 | 616 |
| 444 std::unique_ptr<PageLoadMetricsWaiter> timing_waiter = | 617 std::unique_ptr<PageLoadMetricsWaiter> timing_waiter = |
| 445 CreatePageLoadMetricsWaiter(); | 618 CreatePageLoadMetricsWaiter(); |
| 446 timing_waiter->AddExpectation(PageLoadMetricsWaiter::FIRST_PAINT); | 619 timing_waiter->AddMainFrameExpectation(PageLoadMetricsWaiter::FIRST_PAINT); |
| 447 | 620 |
| 448 // When an XHTML page contains invalid XML, it causes a paint of the error | 621 // When an XHTML page contains invalid XML, it causes a paint of the error |
| 449 // message without a layout. Page load metrics currently treats this as an | 622 // message without a layout. Page load metrics currently treats this as an |
| 450 // error. Eventually, we'll fix this by special casing the handling of | 623 // error. Eventually, we'll fix this by special casing the handling of |
| 451 // documents with non-well-formed XML on the blink side. See crbug.com/627607 | 624 // documents with non-well-formed XML on the blink side. See crbug.com/627607 |
| 452 // for more. | 625 // for more. |
| 453 ui_test_utils::NavigateToURL( | 626 ui_test_utils::NavigateToURL( |
| 454 browser(), | 627 browser(), |
| 455 embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml")); | 628 embedded_test_server()->GetURL("/page_load_metrics/badxml.xhtml")); |
| 456 | 629 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 histogram_tester_.ExpectTotalCount( | 809 histogram_tester_.ExpectTotalCount( |
| 637 internal::kHistogramParseStartToFirstMeaningfulPaint, 1); | 810 internal::kHistogramParseStartToFirstMeaningfulPaint, 1); |
| 638 } | 811 } |
| 639 | 812 |
| 640 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, | 813 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, |
| 641 FirstMeaningfulPaintNotRecorded) { | 814 FirstMeaningfulPaintNotRecorded) { |
| 642 ASSERT_TRUE(embedded_test_server()->Start()); | 815 ASSERT_TRUE(embedded_test_server()->Start()); |
| 643 | 816 |
| 644 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = | 817 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = |
| 645 CreatePageLoadMetricsWaiter(); | 818 CreatePageLoadMetricsWaiter(); |
| 646 fcp_waiter->AddExpectation(PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | 819 fcp_waiter->AddMainFrameExpectation( |
| 820 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 647 | 821 |
| 648 ui_test_utils::NavigateToURL( | 822 ui_test_utils::NavigateToURL( |
| 649 browser(), embedded_test_server()->GetURL( | 823 browser(), embedded_test_server()->GetURL( |
| 650 "/page_load_metrics/page_with_active_connections.html")); | 824 "/page_load_metrics/page_with_active_connections.html")); |
| 651 fcp_waiter->Wait(); | 825 fcp_waiter->Wait(); |
| 652 | 826 |
| 653 // Navigate away before a FMP is reported. | 827 // Navigate away before a FMP is reported. |
| 654 NavigateToUntrackedUrl(); | 828 NavigateToUntrackedUrl(); |
| 655 | 829 |
| 656 histogram_tester_.ExpectUniqueSample( | 830 histogram_tester_.ExpectUniqueSample( |
| 657 internal::kHistogramFirstMeaningfulPaintStatus, | 831 internal::kHistogramFirstMeaningfulPaintStatus, |
| 658 internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE, 1); | 832 internal::FIRST_MEANINGFUL_PAINT_DID_NOT_REACH_NETWORK_STABLE, 1); |
| 659 histogram_tester_.ExpectTotalCount( | 833 histogram_tester_.ExpectTotalCount( |
| 660 internal::kHistogramFirstMeaningfulPaint, 0); | 834 internal::kHistogramFirstMeaningfulPaint, 0); |
| 661 histogram_tester_.ExpectTotalCount( | 835 histogram_tester_.ExpectTotalCount( |
| 662 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); | 836 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); |
| 663 } | 837 } |
| 664 | 838 |
| 665 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, | 839 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, |
| 666 NoStatePrefetchObserverCacheable) { | 840 NoStatePrefetchObserverCacheable) { |
| 667 ASSERT_TRUE(embedded_test_server()->Start()); | 841 ASSERT_TRUE(embedded_test_server()->Start()); |
| 668 | 842 |
| 669 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = | 843 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = |
| 670 CreatePageLoadMetricsWaiter(); | 844 CreatePageLoadMetricsWaiter(); |
| 671 fcp_waiter->AddExpectation(PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | 845 fcp_waiter->AddMainFrameExpectation( |
| 846 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 672 | 847 |
| 673 ui_test_utils::NavigateToURL(browser(), | 848 ui_test_utils::NavigateToURL(browser(), |
| 674 embedded_test_server()->GetURL("/title1.html")); | 849 embedded_test_server()->GetURL("/title1.html")); |
| 675 | 850 |
| 676 fcp_waiter->Wait(); | 851 fcp_waiter->Wait(); |
| 677 | 852 |
| 678 histogram_tester_.ExpectTotalCount( | 853 histogram_tester_.ExpectTotalCount( |
| 679 "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 0); | 854 "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 0); |
| 680 histogram_tester_.ExpectTotalCount( | 855 histogram_tester_.ExpectTotalCount( |
| 681 "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 1); | 856 "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 1); |
| 682 } | 857 } |
| 683 | 858 |
| 684 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, | 859 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, |
| 685 NoStatePrefetchObserverNoStore) { | 860 NoStatePrefetchObserverNoStore) { |
| 686 ASSERT_TRUE(embedded_test_server()->Start()); | 861 ASSERT_TRUE(embedded_test_server()->Start()); |
| 687 | 862 |
| 688 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = | 863 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = |
| 689 CreatePageLoadMetricsWaiter(); | 864 CreatePageLoadMetricsWaiter(); |
| 690 fcp_waiter->AddExpectation(PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | 865 fcp_waiter->AddMainFrameExpectation( |
| 866 PageLoadMetricsWaiter::FIRST_CONTENTFUL_PAINT); | |
| 691 | 867 |
| 692 ui_test_utils::NavigateToURL(browser(), | 868 ui_test_utils::NavigateToURL(browser(), |
| 693 embedded_test_server()->GetURL("/nostore.html")); | 869 embedded_test_server()->GetURL("/nostore.html")); |
| 694 | 870 |
| 695 fcp_waiter->Wait(); | 871 fcp_waiter->Wait(); |
| 696 | 872 |
| 697 histogram_tester_.ExpectTotalCount( | 873 histogram_tester_.ExpectTotalCount( |
| 698 "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 1); | 874 "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible", 1); |
| 699 histogram_tester_.ExpectTotalCount( | 875 histogram_tester_.ExpectTotalCount( |
| 700 "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 0); | 876 "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible", 0); |
| 701 } | 877 } |
| 702 | 878 |
| 703 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, CSSTiming) { | 879 IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTest, CSSTiming) { |
| 704 ASSERT_TRUE(embedded_test_server()->Start()); | 880 ASSERT_TRUE(embedded_test_server()->Start()); |
| 705 | 881 |
| 706 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = | 882 std::unique_ptr<PageLoadMetricsWaiter> fcp_waiter = |
| 707 CreatePageLoadMetricsWaiter(); | 883 CreatePageLoadMetricsWaiter(); |
| 708 fcp_waiter->AddExpectation(PageLoadMetricsWaiter::STYLE_UPDATE_BEFORE_FCP); | 884 fcp_waiter->AddMainFrameExpectation( |
| 885 PageLoadMetricsWaiter::STYLE_UPDATE_BEFORE_FCP); | |
| 709 | 886 |
| 710 // Careful: Blink code clamps timestamps to 5us, so any CSS parsing we do here | 887 // Careful: Blink code clamps timestamps to 5us, so any CSS parsing we do here |
| 711 // must take >> 5us, otherwise we'll log 0 for the value and it will remain | 888 // must take >> 5us, otherwise we'll log 0 for the value and it will remain |
| 712 // unset here. | 889 // unset here. |
| 713 ui_test_utils::NavigateToURL( | 890 ui_test_utils::NavigateToURL( |
| 714 browser(), | 891 browser(), |
| 715 embedded_test_server()->GetURL("/page_load_metrics/page_with_css.html")); | 892 embedded_test_server()->GetURL("/page_load_metrics/page_with_css.html")); |
| 716 NavigateToUntrackedUrl(); | 893 NavigateToUntrackedUrl(); |
| 717 fcp_waiter->Wait(); | 894 fcp_waiter->Wait(); |
| 718 | 895 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 732 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( | 909 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( |
| 733 "/page_load_metrics/large.html")); | 910 "/page_load_metrics/large.html")); |
| 734 NavigateToUntrackedUrl(); | 911 NavigateToUntrackedUrl(); |
| 735 | 912 |
| 736 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); | 913 histogram_tester_.ExpectTotalCount(internal::kHistogramTotalBytes, 1); |
| 737 | 914 |
| 738 // Verify that there is a single sample recorded in the 10kB bucket (the size | 915 // Verify that there is a single sample recorded in the 10kB bucket (the size |
| 739 // of the main HTML response). | 916 // of the main HTML response). |
| 740 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); | 917 histogram_tester_.ExpectBucketCount(internal::kHistogramTotalBytes, 10, 1); |
| 741 } | 918 } |
| OLD | NEW |