OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <deque> | 6 #include <deque> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 3436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3447 GetActiveWebContents()); | 3447 GetActiveWebContents()); |
3448 observer.SetNavigationStartTicksForTesting(clock->NowTicks()); | 3448 observer.SetNavigationStartTicksForTesting(clock->NowTicks()); |
3449 | 3449 |
3450 page_load_metrics::PageLoadTiming timing; | 3450 page_load_metrics::PageLoadTiming timing; |
3451 timing.navigation_start = base::Time::FromDoubleT(1); // Non-null time. | 3451 timing.navigation_start = base::Time::FromDoubleT(1); // Non-null time. |
3452 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(2362); | 3452 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(2362); |
3453 page_load_metrics::PageLoadMetricsObserverTestHarness:: | 3453 page_load_metrics::PageLoadMetricsObserverTestHarness:: |
3454 PopulateRequiredTimingFields(&timing); | 3454 PopulateRequiredTimingFields(&timing); |
3455 observer.OnFirstContentfulPaint(timing, GenericPageLoadExtraInfo(dest_url())); | 3455 observer.OnFirstContentfulPaint(timing, GenericPageLoadExtraInfo(dest_url())); |
3456 | 3456 |
| 3457 // The prerender start will be classified as websame, but the FCP will seen |
| 3458 // but not recored (PerceivedTTFCPRecorded = 0) because the prerender was not |
| 3459 // swapped in. Nothing should be recorded under ORIGIN_NONE because the |
| 3460 // prefetch entry should be created. |
3457 histogram_tester().ExpectTotalCount( | 3461 histogram_tester().ExpectTotalCount( |
3458 "Prerender.none_PrefetchTTFCP.Warm.Cacheable.Visible", 0); | 3462 "Prerender.none_PrefetchTTFCP.Warm.Cacheable.Visible", 0); |
3459 histogram_tester().ExpectTotalCount( | 3463 histogram_tester().ExpectTotalCount( |
3460 "Prerender.none_PerceivedTTFCPRecorded.Visible", 1); | |
3461 | |
3462 // Check that the prerender didn't happen with a defined origin. | |
3463 histogram_tester().ExpectTotalCount( | |
3464 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Visible", 0); | 3464 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Visible", 0); |
3465 histogram_tester().ExpectTotalCount( | 3465 histogram_tester().ExpectTotalCount( |
3466 "Prerender.websame_PerceivedTTFCPRecorded.Visible", 0); | 3466 "Prerender.none_PerceivedTTFCPRecorded.Visible", 0); |
3467 | |
3468 // A FCP is fired by the observer, but as a swap did not occur the perceived | |
3469 // time cannot be calculated, and an unrecorded perceived FCP time histogram | |
3470 // entry is made. | |
3471 histogram_tester().ExpectUniqueSample( | 3467 histogram_tester().ExpectUniqueSample( |
3472 "Prerender.none_PerceivedTTFCPRecorded.Visible", 0, 1); | 3468 "Prerender.websame_PerceivedTTFCPRecorded.Visible", 0, 1); |
3473 } | 3469 } |
3474 | 3470 |
3475 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3471 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3476 FirstContentfulPaintTimingTwoPages) { | 3472 FirstContentfulPaintTimingTwoPages) { |
3477 GetPrerenderManager()->DisablePageLoadMetricsObserverForTesting(); | 3473 GetPrerenderManager()->DisablePageLoadMetricsObserverForTesting(); |
3478 base::SimpleTestTickClock* clock = OverridePrerenderManagerTimeTicks(); | 3474 base::SimpleTestTickClock* clock = OverridePrerenderManagerTimeTicks(); |
3479 | 3475 |
3480 // As this load will be canceled, it is not waited for, and hence no | 3476 // As this load will be canceled, it is not waited for, and hence no |
3481 // javascript is executed. | 3477 // javascript is executed. |
3482 DisableJavascriptCalls(); | 3478 DisableJavascriptCalls(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3571 observer.OnHidden(page_load_metrics::PageLoadTiming(), | 3567 observer.OnHidden(page_load_metrics::PageLoadTiming(), |
3572 GenericPageLoadExtraInfo(dest_url()))); | 3568 GenericPageLoadExtraInfo(dest_url()))); |
3573 | 3569 |
3574 page_load_metrics::PageLoadTiming timing; | 3570 page_load_metrics::PageLoadTiming timing; |
3575 timing.navigation_start = base::Time::FromDoubleT(1); // Non-null time. | 3571 timing.navigation_start = base::Time::FromDoubleT(1); // Non-null time. |
3576 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(2362); | 3572 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(2362); |
3577 page_load_metrics::PageLoadMetricsObserverTestHarness:: | 3573 page_load_metrics::PageLoadMetricsObserverTestHarness:: |
3578 PopulateRequiredTimingFields(&timing); | 3574 PopulateRequiredTimingFields(&timing); |
3579 observer.OnFirstContentfulPaint(timing, GenericPageLoadExtraInfo(dest_url())); | 3575 observer.OnFirstContentfulPaint(timing, GenericPageLoadExtraInfo(dest_url())); |
3580 | 3576 |
| 3577 // The prerender start will be classified as websame, but the FCP will seen |
| 3578 // but not recored (PerceivedTTFCPRecorded = 0) because the prerender was not |
| 3579 // swapped in. Nothing should be recorded under ORIGIN_NONE because the |
| 3580 // prefetch entry should be created. |
3581 histogram_tester().ExpectTotalCount( | 3581 histogram_tester().ExpectTotalCount( |
3582 "Prerender.none_PrefetchTTFCP.Warm.Cacheable.Hidden", 0); | 3582 "Prerender.none_PrefetchTTFCP.Warm.Cacheable.Hidden", 0); |
3583 histogram_tester().ExpectTotalCount( | 3583 histogram_tester().ExpectTotalCount( |
3584 "Prerender.none_PerceivedTTFCPRecorded.Hidden", 1); | |
3585 | |
3586 // Check that the prerender didn't happen with a defined origin. | |
3587 histogram_tester().ExpectTotalCount( | |
3588 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Hidden", 0); | 3584 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Hidden", 0); |
3589 histogram_tester().ExpectTotalCount( | 3585 histogram_tester().ExpectTotalCount( |
3590 "Prerender.websame_PerceivedTTFCPRecorded.Hidden", 0); | 3586 "Prerender.none_PerceivedTTFCPRecorded.Hidden", 0); |
3591 | |
3592 // A FCP is fired by the observer, but the manager should detect that the | |
3593 // perceived time is not set and so update the following histogram. | |
3594 histogram_tester().ExpectUniqueSample( | 3587 histogram_tester().ExpectUniqueSample( |
3595 "Prerender.none_PerceivedTTFCPRecorded.Hidden", 0, 1); | 3588 "Prerender.websame_PerceivedTTFCPRecorded.Hidden", 0, 1); |
3596 } | 3589 } |
3597 | 3590 |
3598 // When instantiated, mocks out the global text-to-speech engine with something | 3591 // When instantiated, mocks out the global text-to-speech engine with something |
3599 // that emulates speaking any phrase for the duration of 0ms. | 3592 // that emulates speaking any phrase for the duration of 0ms. |
3600 class TtsPlatformMock : public TtsPlatformImpl { | 3593 class TtsPlatformMock : public TtsPlatformImpl { |
3601 public: | 3594 public: |
3602 TtsPlatformMock() : speaking_requested_(false) { | 3595 TtsPlatformMock() : speaking_requested_(false) { |
3603 TtsController::GetInstance()->SetPlatformImpl(this); | 3596 TtsController::GetInstance()->SetPlatformImpl(this); |
3604 } | 3597 } |
3605 | 3598 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3804 browser()->tab_strip_model()->GetActiveWebContents(); | 3797 browser()->tab_strip_model()->GetActiveWebContents(); |
3805 bool display_test_result = false; | 3798 bool display_test_result = false; |
3806 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, | 3799 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, |
3807 "DidDisplayReallyPass()", | 3800 "DidDisplayReallyPass()", |
3808 &display_test_result)); | 3801 &display_test_result)); |
3809 ASSERT_TRUE(display_test_result); | 3802 ASSERT_TRUE(display_test_result); |
3810 } | 3803 } |
3811 #endif // !defined(DISABLE_NACL) | 3804 #endif // !defined(DISABLE_NACL) |
3812 | 3805 |
3813 } // namespace prerender | 3806 } // namespace prerender |
OLD | NEW |