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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/frame_host/cross_site_transferring_request.h" | 8 #include "content/browser/frame_host/cross_site_transferring_request.h" |
9 #include "content/browser/frame_host/interstitial_page_impl.h" | 9 #include "content/browser/frame_host/interstitial_page_impl.h" |
10 #include "content/browser/frame_host/navigation_entry_impl.h" | 10 #include "content/browser/frame_host/navigation_entry_impl.h" |
(...skipping 2861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2872 EXPECT_TRUE(observer.is_loading()); | 2872 EXPECT_TRUE(observer.is_loading()); |
2873 | 2873 |
2874 // Send the DidStopLoading for the main frame and ensure it isn't loading | 2874 // Send the DidStopLoading for the main frame and ensure it isn't loading |
2875 // anymore. | 2875 // anymore. |
2876 orig_rfh->OnMessageReceived( | 2876 orig_rfh->OnMessageReceived( |
2877 FrameHostMsg_DidStopLoading(orig_rfh->GetRoutingID())); | 2877 FrameHostMsg_DidStopLoading(orig_rfh->GetRoutingID())); |
2878 EXPECT_FALSE(contents()->IsLoading()); | 2878 EXPECT_FALSE(contents()->IsLoading()); |
2879 EXPECT_FALSE(observer.is_loading()); | 2879 EXPECT_FALSE(observer.is_loading()); |
2880 } | 2880 } |
2881 | 2881 |
2882 // Ensure that WebContentsImpl does not stop loading too early when there still | |
2883 // is a pending renderer. This can happen if a same-process non user-initiated | |
2884 // navigation completes while there is an ongoing cross-process navigation. | |
2885 // TODO(fdegans): Rewrite the test for PlzNavigate when DidStartLoading and | |
2886 // DidStopLoading are properly called. | |
2887 TEST_F(WebContentsImplTest, NoEarlyStop) { | |
2888 const GURL kUrl1("http://www.chromium.org"); | |
2889 const GURL kUrl2("http://www.google.com"); | |
2890 const GURL kUrl3("http://www.wikipedia.org"); | |
2891 | |
2892 contents()->NavigateAndCommit(kUrl1); | |
2893 | |
2894 TestRenderFrameHost* current_rfh = contents()->GetMainFrame(); | |
2895 | |
2896 // Start a browser-initiated cross-process navigation to |kUrl2|. There should | |
2897 // be a pending RenderFrameHost and the WebContents should be loading. | |
2898 controller().LoadURL( | |
2899 kUrl2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
2900 EXPECT_TRUE(contents()->cross_navigation_pending()); | |
2901 TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); | |
2902 ASSERT_NE(pending_rfh, nullptr); | |
2903 EXPECT_TRUE(contents()->IsLoading()); | |
2904 | |
2905 // The current RenderFrameHost starts a non user-initiated render-initiated | |
2906 // navigation and sends a DidStartLoading IPC. The WebContents should still be | |
2907 // loading. | |
2908 current_rfh->OnMessageReceived( | |
2909 FrameHostMsg_DidStartLoading(current_rfh->GetRoutingID(), false)); | |
Charlie Reis
2015/03/05 04:46:18
nit: Wrong indent.
Fabrice (no longer in Chrome)
2015/03/05 12:37:43
Done.
| |
2910 EXPECT_TRUE(contents()->IsLoading()); | |
2911 | |
2912 // Simulate the pending RenderFrameHost DidStartLoading. There should still be | |
2913 // a pending RenderFrameHost and the WebContents should still be loading. | |
2914 pending_rfh->PrepareForCommit(kUrl2); | |
Charlie Reis
2015/03/05 04:46:18
Compile error here?
Fabrice (no longer in Chrome)
2015/03/05 12:37:43
I needed to rebase locally.
Done.
| |
2915 pending_rfh->OnMessageReceived( | |
2916 FrameHostMsg_DidStartLoading(pending_rfh->GetRoutingID(), false)); | |
2917 EXPECT_EQ(contents()->GetPendingMainFrame(), pending_rfh); | |
2918 EXPECT_TRUE(contents()->IsLoading()); | |
2919 | |
2920 // Simulate the commit and DidStopLoading from the renderer-initiated | |
2921 // navigation in the current RenderFrameHost. There should still be a pending | |
2922 // RenderFrameHost and the WebContents should still be loading. | |
2923 current_rfh->SendNavigate(1, kUrl3); | |
2924 current_rfh->OnMessageReceived( | |
2925 FrameHostMsg_DidStopLoading(current_rfh->GetRoutingID())); | |
2926 EXPECT_EQ(contents()->GetPendingMainFrame(), pending_rfh); | |
2927 EXPECT_TRUE(contents()->IsLoading()); | |
2928 | |
2929 // Commit the navigation, the formerly pending RenderFrameHost should now be | |
Charlie Reis
2015/03/05 04:46:18
Run-on sentence. Use either a period or a semicol
Fabrice (no longer in Chrome)
2015/03/05 12:37:43
Done.
| |
2930 // the current RenderFrameHost and the WebContents should still be loading. | |
2931 contents()->TestDidNavigate(pending_rfh, 1, kUrl2, | |
2932 ui::PAGE_TRANSITION_TYPED); | |
2933 EXPECT_EQ(contents()->GetPendingMainFrame(), nullptr); | |
2934 TestRenderFrameHost* new_current_rfh = contents()->GetMainFrame(); | |
2935 ASSERT_EQ(new_current_rfh, pending_rfh); | |
Charlie Reis
2015/03/05 04:46:19
EXPECT_EQ
(Save ASSERT_* for things that prevent
Fabrice (no longer in Chrome)
2015/03/05 12:37:43
Done.
| |
2936 EXPECT_TRUE(contents()->IsLoading()); | |
2937 | |
2938 // Simulate the new current RenderFrameHost DidStopLoading. The WebContents | |
2939 // should now have stopped loading. | |
2940 new_current_rfh->OnMessageReceived( | |
2941 FrameHostMsg_DidStopLoading(new_current_rfh->GetRoutingID())); | |
2942 EXPECT_EQ(contents()->GetMainFrame(), new_current_rfh); | |
2943 EXPECT_FALSE(contents()->IsLoading()); | |
2944 } | |
2945 | |
2882 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { | 2946 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { |
2883 // PlayerIDs are actually pointers cast to int64, so verify that both negative | 2947 // PlayerIDs are actually pointers cast to int64, so verify that both negative |
2884 // and positive player ids don't blow up. | 2948 // and positive player ids don't blow up. |
2885 const int kPlayerAudioVideoId = 15; | 2949 const int kPlayerAudioVideoId = 15; |
2886 const int kPlayerAudioOnlyId = -15; | 2950 const int kPlayerAudioOnlyId = -15; |
2887 const int kPlayerVideoOnlyId = 30; | 2951 const int kPlayerVideoOnlyId = 30; |
2888 const int kPlayerRemoteId = -30; | 2952 const int kPlayerRemoteId = -30; |
2889 | 2953 |
2890 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 2954 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
2891 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 2955 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3036 frame->SendBeforeUnloadHandlersPresent(false); | 3100 frame->SendBeforeUnloadHandlersPresent(false); |
3037 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | 3101 EXPECT_FALSE(frame->SuddenTerminationAllowed()); |
3038 frame->SendBeforeUnloadHandlersPresent(true); | 3102 frame->SendBeforeUnloadHandlersPresent(true); |
3039 frame->SendUnloadHandlersPresent(false); | 3103 frame->SendUnloadHandlersPresent(false); |
3040 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | 3104 EXPECT_FALSE(frame->SuddenTerminationAllowed()); |
3041 frame->SendBeforeUnloadHandlersPresent(false); | 3105 frame->SendBeforeUnloadHandlersPresent(false); |
3042 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | 3106 EXPECT_TRUE(frame->SuddenTerminationAllowed()); |
3043 } | 3107 } |
3044 | 3108 |
3045 } // namespace content | 3109 } // namespace content |
OLD | NEW |