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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 2738783002: Prerender: Remove PerceivedPLT histograms (Closed)
Patch Set: remove PrerenderManager::RecordPerceivedPageLoadTime as well Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_histograms.h » ('j') | 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) 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 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 1035
1036 // Checks that a page is correctly prerendered in the case of a 1036 // Checks that a page is correctly prerendered in the case of a
1037 // <link rel=prerender> tag and then loaded into a tab in response to a 1037 // <link rel=prerender> tag and then loaded into a tab in response to a
1038 // navigation. 1038 // navigation.
1039 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) { 1039 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPage) {
1040 test_utils::FirstContentfulPaintManagerWaiter* fcp_waiter = 1040 test_utils::FirstContentfulPaintManagerWaiter* fcp_waiter =
1041 test_utils::FirstContentfulPaintManagerWaiter::Create( 1041 test_utils::FirstContentfulPaintManagerWaiter::Create(
1042 GetPrerenderManager()); 1042 GetPrerenderManager());
1043 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 1043 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
1044 EXPECT_EQ(1, GetPrerenderDomContentLoadedEventCountForLinkNumber(0)); 1044 EXPECT_EQ(1, GetPrerenderDomContentLoadedEventCountForLinkNumber(0));
1045 histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1);
1046 histogram_tester().ExpectTotalCount(
1047 "Prerender.websame_PrerenderNotSwappedInPLT", 1);
1048 1045
1049 ChannelDestructionWatcher channel_close_watcher; 1046 ChannelDestructionWatcher channel_close_watcher;
1050 channel_close_watcher.WatchChannel( 1047 channel_close_watcher.WatchChannel(
1051 GetActiveWebContents()->GetRenderProcessHost()); 1048 GetActiveWebContents()->GetRenderProcessHost());
1052 NavigateToDestURL(); 1049 NavigateToDestURL();
1053 channel_close_watcher.WaitForChannelClose(); 1050 channel_close_watcher.WaitForChannelClose();
1054 fcp_waiter->Wait(); 1051 fcp_waiter->Wait();
1055 1052
1056 histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLT", 1);
1057 histogram_tester().ExpectTotalCount( 1053 histogram_tester().ExpectTotalCount(
1058 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Visible", 1); 1054 "Prerender.websame_PrefetchTTFCP.Warm.Cacheable.Visible", 1);
1059 histogram_tester().ExpectTotalCount( 1055 histogram_tester().ExpectTotalCount(
1060 "Prerender.websame_PerceivedTTFCPRecorded.Visible", 1); 1056 "Prerender.websame_PerceivedTTFCPRecorded.Visible", 1);
1061 1057
1062 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); 1058 ASSERT_TRUE(IsEmptyPrerenderLinkManager());
1063 } 1059 }
1064 1060
1065 // Checks that the correct page load metrics observers are produced without a 1061 // Checks that the correct page load metrics observers are produced without a
1066 // prerender. 1062 // prerender.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 "PageLoad.PaintTiming.NavigationToFirstContentfulPaint", 0); 1108 "PageLoad.PaintTiming.NavigationToFirstContentfulPaint", 0);
1113 } 1109 }
1114 1110
1115 // Checks that cross-domain prerenders emit the correct histograms. 1111 // Checks that cross-domain prerenders emit the correct histograms.
1116 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageCrossDomain) { 1112 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPageCrossDomain) {
1117 test_utils::FirstContentfulPaintManagerWaiter* fcp_waiter = 1113 test_utils::FirstContentfulPaintManagerWaiter* fcp_waiter =
1118 test_utils::FirstContentfulPaintManagerWaiter::Create( 1114 test_utils::FirstContentfulPaintManagerWaiter::Create(
1119 GetPrerenderManager()); 1115 GetPrerenderManager());
1120 PrerenderTestURL(GetCrossDomainTestUrl("prerender/prerender_page.html"), 1116 PrerenderTestURL(GetCrossDomainTestUrl("prerender/prerender_page.html"),
1121 FINAL_STATUS_USED, 1); 1117 FINAL_STATUS_USED, 1);
1122 histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1);
1123 histogram_tester().ExpectTotalCount(
1124 "Prerender.webcross_PrerenderNotSwappedInPLT", 1);
mattcary 2017/03/09 09:02:35 I guess we're losing verification here of not bein
pasko 2017/03/23 13:33:24 We actually perform a swap here in NavigateToDestU
mattcary 2017/03/23 13:49:26 sgtm, thx for digging.
1125 1118
1126 NavigateToDestURL(); 1119 NavigateToDestURL();
1127 fcp_waiter->Wait(); 1120 fcp_waiter->Wait();
1128 1121
1129 histogram_tester().ExpectTotalCount("Prerender.webcross_PerceivedPLT", 1);
1130 histogram_tester().ExpectTotalCount( 1122 histogram_tester().ExpectTotalCount(
1131 "Prerender.webcross_PrefetchTTFCP.Warm.Cacheable.Visible", 1); 1123 "Prerender.webcross_PrefetchTTFCP.Warm.Cacheable.Visible", 1);
1132 } 1124 }
1133 1125
1134 // Checks that pending prerenders launch and receive proper event treatment. 1126 // Checks that pending prerenders launch and receive proper event treatment.
1135 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPagePending) { 1127 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPagePending) {
1136 std::unique_ptr<TestPrerender> prerender = PrerenderTestURL( 1128 std::unique_ptr<TestPrerender> prerender = PrerenderTestURL(
1137 "/prerender/prerender_page_pending.html", FINAL_STATUS_USED, 1); 1129 "/prerender/prerender_page_pending.html", FINAL_STATUS_USED, 1);
1138 1130
1139 // Navigate to the prerender. 1131 // Navigate to the prerender.
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 1487
1496 // Checks that redirects with location.replace do not cancel a prerender and 1488 // Checks that redirects with location.replace do not cancel a prerender and
1497 // and swap when navigating to the second. 1489 // and swap when navigating to the second.
1498 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 1490 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
1499 PrerenderLocationReplaceNavigateToSecond) { 1491 PrerenderLocationReplaceNavigateToSecond) {
1500 PrerenderTestURL("/prerender/prerender_location_replace.html", 1492 PrerenderTestURL("/prerender/prerender_location_replace.html",
1501 FINAL_STATUS_USED, 2); 1493 FINAL_STATUS_USED, 2);
1502 NavigateToURL("/prerender/prerender_page.html"); 1494 NavigateToURL("/prerender/prerender_page.html");
1503 } 1495 }
1504 1496
1505 // Checks that we get the right PPLT histograms for client redirect prerenders
1506 // and navigations when the referring page is Google.
1507 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
1508 PrerenderLocationReplaceGWSHistograms) {
1509 DisableJavascriptCalls();
1510
1511 // The loader page should look like Google.
1512 static const char kGoogleDotCom[] = "www.google.com";
1513 SetLoaderHostOverride(kGoogleDotCom);
1514 set_loader_path("/prerender/prerender_loader_with_replace_state.html");
mattcary 2017/03/09 09:02:35 I think you can remove this file from chrome/test/
pasko 2017/03/23 13:33:25 Let me think more about this test case (gws preren
mattcary 2017/03/23 13:49:26 Hmmm. Redirects. We use extras.start_url in the PL
1515
1516 GURL dest_url =
1517 GetCrossDomainTestUrl("prerender/prerender_deferred_image.html");
1518
1519 GURL prerender_url = embedded_test_server()->GetURL(
1520 "/prerender/prerender_location_replace.html?" +
1521 net::EscapeQueryParamValue(dest_url.spec(), false) + "#prerender");
1522 GURL::Replacements replacements;
1523 replacements.SetHostStr(kGoogleDotCom);
1524 prerender_url = prerender_url.ReplaceComponents(replacements);
1525
1526 // The prerender will not completely load until after the swap, so wait for a
1527 // title change before calling DidPrerenderPass.
1528 std::unique_ptr<TestPrerender> prerender =
1529 PrerenderTestURL(prerender_url, FINAL_STATUS_USED, 1);
1530 WaitForASCIITitle(prerender->contents()->prerender_contents(), kReadyTitle);
1531 EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents()));
1532 EXPECT_EQ(1, prerender->number_of_loads());
1533
1534 histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1);
1535 // Although there is a client redirect, it is dropped from histograms because
1536 // it is a Google URL. The target page itself does not load until after the
1537 // swap.
1538 histogram_tester().ExpectTotalCount("Prerender.gws_PrerenderNotSwappedInPLT",
1539 0);
1540
1541 GURL navigate_url = embedded_test_server()->GetURL(
1542 "/prerender/prerender_location_replace.html?" +
1543 net::EscapeQueryParamValue(dest_url.spec(), false) + "#navigate");
1544 navigate_url = navigate_url.ReplaceComponents(replacements);
1545
1546 NavigationOrSwapObserver swap_observer(
1547 current_browser()->tab_strip_model(),
1548 GetActiveWebContents(), 2);
1549 current_browser()->OpenURL(OpenURLParams(navigate_url, Referrer(),
1550 WindowOpenDisposition::CURRENT_TAB,
1551 ui::PAGE_TRANSITION_TYPED, false));
1552 swap_observer.Wait();
1553
1554 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents()));
1555
1556 histogram_tester().ExpectTotalCount("Prerender.gws_PrerenderNotSwappedInPLT",
1557 0);
1558 histogram_tester().ExpectTotalCount("Prerender.gws_PerceivedPLT", 1);
1559
1560 // The client redirect does /not/ count as a miss because it's a Google URL.
1561 histogram_tester().ExpectTotalCount("Prerender.PerceivedPLTFirstAfterMiss",
1562 0);
1563 }
1564
1565 // Checks that client-issued redirects work with prerendering. 1497 // Checks that client-issued redirects work with prerendering.
1566 // This version navigates to the final destination page, rather than the 1498 // This version navigates to the final destination page, rather than the
1567 // page which does the redirection via a mouse click. 1499 // page which does the redirection via a mouse click.
1568 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 1500 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
1569 PrerenderClientRedirectNavigateToSecondViaClick) { 1501 PrerenderClientRedirectNavigateToSecondViaClick) {
1570 GURL prerender_url = embedded_test_server()->GetURL( 1502 GURL prerender_url = embedded_test_server()->GetURL(
1571 CreateClientRedirect("/prerender/prerender_page.html")); 1503 CreateClientRedirect("/prerender/prerender_page.html"));
1572 GURL destination_url = 1504 GURL destination_url =
1573 embedded_test_server()->GetURL("/prerender/prerender_page.html"); 1505 embedded_test_server()->GetURL("/prerender/prerender_page.html");
1574 PrerenderTestURL(prerender_url, FINAL_STATUS_USED, 2); 1506 PrerenderTestURL(prerender_url, FINAL_STATUS_USED, 2);
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
3020 DisableJavascriptCalls(); 2952 DisableJavascriptCalls();
3021 2953
3022 // The prerender will not completely load until after the swap, so wait for a 2954 // The prerender will not completely load until after the swap, so wait for a
3023 // title change before calling DidPrerenderPass. 2955 // title change before calling DidPrerenderPass.
3024 std::unique_ptr<TestPrerender> prerender = PrerenderTestURL( 2956 std::unique_ptr<TestPrerender> prerender = PrerenderTestURL(
3025 "/prerender/prerender_deferred_image.html", FINAL_STATUS_USED, 0); 2957 "/prerender/prerender_deferred_image.html", FINAL_STATUS_USED, 0);
3026 WaitForASCIITitle(prerender->contents()->prerender_contents(), kReadyTitle); 2958 WaitForASCIITitle(prerender->contents()->prerender_contents(), kReadyTitle);
3027 EXPECT_EQ(1, GetPrerenderDomContentLoadedEventCountForLinkNumber(0)); 2959 EXPECT_EQ(1, GetPrerenderDomContentLoadedEventCountForLinkNumber(0));
3028 EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents())); 2960 EXPECT_TRUE(DidPrerenderPass(prerender->contents()->prerender_contents()));
3029 EXPECT_EQ(0, prerender->number_of_loads()); 2961 EXPECT_EQ(0, prerender->number_of_loads());
3030 histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1);
3031 histogram_tester().ExpectTotalCount(
3032 "Prerender.websame_PrerenderNotSwappedInPLT", 0);
3033 2962
3034 // Swap. 2963 // Swap.
3035 NavigationOrSwapObserver swap_observer(current_browser()->tab_strip_model(), 2964 NavigationOrSwapObserver swap_observer(current_browser()->tab_strip_model(),
3036 GetActiveWebContents()); 2965 GetActiveWebContents());
3037 ui_test_utils::NavigateToURLWithDisposition( 2966 ui_test_utils::NavigateToURLWithDisposition(
3038 current_browser(), dest_url(), WindowOpenDisposition::CURRENT_TAB, 2967 current_browser(), dest_url(), WindowOpenDisposition::CURRENT_TAB,
3039 ui_test_utils::BROWSER_TEST_NONE); 2968 ui_test_utils::BROWSER_TEST_NONE);
3040 swap_observer.Wait(); 2969 swap_observer.Wait();
3041 2970
3042 // The prerender never observes the final load. 2971 // The prerender never observes the final load.
3043 EXPECT_EQ(0, prerender->number_of_loads()); 2972 EXPECT_EQ(0, prerender->number_of_loads());
3044 2973
3045 // Now check DidDisplayPass. 2974 // Now check DidDisplayPass.
3046 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents())); 2975 EXPECT_TRUE(DidDisplayPass(GetActiveWebContents()));
3047
3048 histogram_tester().ExpectTotalCount(
3049 "Prerender.websame_PrerenderNotSwappedInPLT", 0);
3050 histogram_tester().ExpectTotalCount("Prerender.websame_PerceivedPLT", 1);
3051 } 2976 }
3052 2977
3053 // Checks that a deferred redirect to an image is not loaded until the 2978 // Checks that a deferred redirect to an image is not loaded until the
3054 // page is visible, even after another redirect. 2979 // page is visible, even after another redirect.
3055 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 2980 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
3056 PrerenderDeferredImageAfterRedirect) { 2981 PrerenderDeferredImageAfterRedirect) {
3057 DisableJavascriptCalls(); 2982 DisableJavascriptCalls();
3058 2983
3059 // The prerender will not completely load until after the swap, so wait for a 2984 // The prerender will not completely load until after the swap, so wait for a
3060 // title change before calling DidPrerenderPass. 2985 // title change before calling DidPrerenderPass.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3210 BrowserThread::IO, FROM_HERE, 3135 BrowserThread::IO, FROM_HERE,
3211 base::Bind(&CreateCountingInterceptorOnIO, 3136 base::Bind(&CreateCountingInterceptorOnIO,
3212 kPingURL, empty_file, ping_counter.AsWeakPtr())); 3137 kPingURL, empty_file, ping_counter.AsWeakPtr()));
3213 3138
3214 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1); 3139 PrerenderTestURL("/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
3215 OpenDestURLViaClickPing(kPingURL); 3140 OpenDestURLViaClickPing(kPingURL);
3216 3141
3217 ping_counter.WaitForCount(1); 3142 ping_counter.WaitForCount(1);
3218 } 3143 }
3219 3144
3220 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPPLTNormalNavigation) {
3221 GURL url = embedded_test_server()->GetURL("/prerender/prerender_page.html");
3222 ui_test_utils::NavigateToURL(current_browser(), url);
3223 histogram_tester().ExpectTotalCount("Prerender.none_PerceivedPLT", 1);
3224 }
3225
3226 // Checks that a prerender which calls window.close() on itself is aborted. 3145 // Checks that a prerender which calls window.close() on itself is aborted.
3227 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowClose) { 3146 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowClose) {
3228 DisableLoadEventCheck(); 3147 DisableLoadEventCheck();
3229 PrerenderTestURL("/prerender/prerender_window_close.html", 3148 PrerenderTestURL("/prerender/prerender_window_close.html",
3230 FINAL_STATUS_CLOSED, 0); 3149 FINAL_STATUS_CLOSED, 0);
3231 } 3150 }
3232 3151
3233 // Tests interaction between prerender and POST (i.e. POST request should still 3152 // Tests interaction between prerender and POST (i.e. POST request should still
3234 // be made and POST data should not be dropped when the POST target is the same 3153 // be made and POST data should not be dropped when the POST target is the same
3235 // as a prerender link). 3154 // as a prerender link).
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
3811 browser()->tab_strip_model()->GetActiveWebContents(); 3730 browser()->tab_strip_model()->GetActiveWebContents();
3812 bool display_test_result = false; 3731 bool display_test_result = false;
3813 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, 3732 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents,
3814 "DidDisplayReallyPass()", 3733 "DidDisplayReallyPass()",
3815 &display_test_result)); 3734 &display_test_result));
3816 ASSERT_TRUE(display_test_result); 3735 ASSERT_TRUE(display_test_result);
3817 } 3736 }
3818 #endif // !defined(DISABLE_NACL) 3737 #endif // !defined(DISABLE_NACL)
3819 3738
3820 } // namespace prerender 3739 } // namespace prerender
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_histograms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698