OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 6672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6683 // Navigate to a page, and check if metrics are initialized correctly. | 6683 // Navigate to a page, and check if metrics are initialized correctly. |
6684 EXPECT_TRUE(NavigateToURL( | 6684 EXPECT_TRUE(NavigateToURL( |
6685 shell(), embedded_test_server()->GetURL( | 6685 shell(), embedded_test_server()->GetURL( |
6686 "/navigation_controller/page_with_links.html"))); | 6686 "/navigation_controller/page_with_links.html"))); |
6687 histogram.ExpectTotalCount(kReloadToReloadMetricName, 0); | 6687 histogram.ExpectTotalCount(kReloadToReloadMetricName, 0); |
6688 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 0); | 6688 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 0); |
6689 | 6689 |
6690 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( | 6690 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( |
6691 shell()->web_contents()->GetController()); | 6691 shell()->web_contents()->GetController()); |
6692 | 6692 |
6693 // Reload triggers a reload of ReloadType::MAIN_RESOURCE. The first reload | 6693 // Reload triggers a reload of ReloadType::NORMAL. The first reload should |
6694 // should not be counted. | 6694 // not be counted. |
6695 controller.Reload(false); | 6695 controller.Reload(false); |
6696 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 6696 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
6697 histogram.ExpectTotalCount(kReloadToReloadMetricName, 0); | 6697 histogram.ExpectTotalCount(kReloadToReloadMetricName, 0); |
6698 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 0); | 6698 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 0); |
6699 | 6699 |
6700 // ReloadBypassingCache triggers a reload of ReloadType::BYPASSING_CACHE. | 6700 // ReloadBypassingCache triggers a reload of ReloadType::BYPASSING_CACHE. |
6701 // Both metrics should count the consecutive reloads. | 6701 // Both metrics should count the consecutive reloads. |
6702 controller.ReloadBypassingCache(false); | 6702 controller.ReloadBypassingCache(false); |
6703 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 6703 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
6704 histogram.ExpectTotalCount(kReloadToReloadMetricName, 1); | 6704 histogram.ExpectTotalCount(kReloadToReloadMetricName, 1); |
(...skipping 14 matching lines...) Expand all Loading... |
6719 histogram.ExpectTotalCount(kReloadToReloadMetricName, 2); | 6719 histogram.ExpectTotalCount(kReloadToReloadMetricName, 2); |
6720 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 1); | 6720 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 1); |
6721 | 6721 |
6722 // Then, the next reload should be assumed as the first reload. Metrics | 6722 // Then, the next reload should be assumed as the first reload. Metrics |
6723 // should not be changed for the first reload. | 6723 // should not be changed for the first reload. |
6724 controller.Reload(false); | 6724 controller.Reload(false); |
6725 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 6725 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
6726 histogram.ExpectTotalCount(kReloadToReloadMetricName, 2); | 6726 histogram.ExpectTotalCount(kReloadToReloadMetricName, 2); |
6727 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 1); | 6727 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 1); |
6728 | 6728 |
6729 // Another reload of ReloadType::MAIN_RESOURCE should be counted by both | 6729 // Another reload of ReloadType::NORMAL should be counted by both metrics |
6730 // metrics again. | 6730 // again. |
6731 controller.Reload(false); | 6731 controller.Reload(false); |
6732 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 6732 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
6733 histogram.ExpectTotalCount(kReloadToReloadMetricName, 3); | 6733 histogram.ExpectTotalCount(kReloadToReloadMetricName, 3); |
6734 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 2); | 6734 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 2); |
6735 | 6735 |
6736 // A renderer-initiated navigations with no user gesture don't reset reload | 6736 // A renderer-initiated navigations with no user gesture don't reset reload |
6737 // tracking information, and the following reload will be counted by metrics. | 6737 // tracking information, and the following reload will be counted by metrics. |
6738 ExecuteJavaScriptAndWaitForLoadStop( | 6738 ExecuteJavaScriptAndWaitForLoadStop( |
6739 shell()->web_contents(), | 6739 shell()->web_contents(), |
6740 "history.pushState({}, 'page 1', 'simple_page_1.html')"); | 6740 "history.pushState({}, 'page 1', 'simple_page_1.html')"); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7022 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), | 7022 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), |
7023 kFragmentURL); | 7023 kFragmentURL); |
7024 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); | 7024 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); |
7025 | 7025 |
7026 EXPECT_TRUE(handle_observer.has_committed()); | 7026 EXPECT_TRUE(handle_observer.has_committed()); |
7027 EXPECT_TRUE(handle_observer.was_same_page()); | 7027 EXPECT_TRUE(handle_observer.was_same_page()); |
7028 EXPECT_FALSE(handle_observer.was_renderer_initiated()); | 7028 EXPECT_FALSE(handle_observer.was_renderer_initiated()); |
7029 } | 7029 } |
7030 | 7030 |
7031 } // namespace content | 7031 } // namespace content |
OLD | NEW |