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); | |
carlosk
2015/03/03 15:29:12
In the lines of what was mentioned earlier this sh
Fabrice (no longer in Chrome)
2015/03/04 18:17:58
In this specific case I prefer it for readability
clamy
2015/03/04 18:28:49
We use ASSERT_FALSE(ptr) everywhere in the unit te
Fabrice (no longer in Chrome)
2015/03/05 12:37:42
We actually want ASSERT_TRUE here.
Done.
| |
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 still be | |
carlosk
2015/03/03 15:29:13
nit: ... WebContents *should* still...
Fabrice (no longer in Chrome)
2015/03/04 18:17:58
I accidentally the verb.
Done.
| |
2907 // loading. | |
2908 current_rfh->OnMessageReceived( | |
2909 FrameHostMsg_DidStartLoading(current_rfh->GetRoutingID(), false)); | |
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); | |
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 current RenderFrameHost DidStopLoading. There should still be | |
2921 // a pending RenderFrameHost and the WebContents should still be loading. | |
2922 current_rfh->SendNavigate(1, kUrl3); | |
carlosk
2015/03/03 15:29:12
I think the comments are a bit out of place. This
clamy
2015/03/03 17:01:09
On the renderer side it started when we received t
Fabrice (no longer in Chrome)
2015/03/04 18:17:58
Done.
| |
2923 current_rfh->OnMessageReceived( | |
2924 FrameHostMsg_DidStopLoading(current_rfh->GetRoutingID())); | |
2925 EXPECT_EQ(contents()->GetPendingMainFrame(), pending_rfh); | |
2926 EXPECT_TRUE(contents()->IsLoading()); | |
2927 | |
2928 // Commit the navigation, the formerly pending RenderFrameHost should now be | |
2929 // the current RenderFrameHost and the WebContents should still be loading. | |
2930 contents()->TestDidNavigate(pending_rfh, 1, kUrl2, | |
2931 ui::PAGE_TRANSITION_TYPED); | |
2932 EXPECT_EQ(contents()->GetPendingMainFrame(), nullptr); | |
carlosk
2015/03/03 15:29:13
Replace with: EXPECT_FALSE(contents()->GetPendingM
Fabrice (no longer in Chrome)
2015/03/04 18:17:58
Same as above.
clamy
2015/03/04 18:28:49
Same here, please do the change asked by carlosk@
Fabrice (no longer in Chrome)
2015/03/05 12:37:42
Done.
| |
2933 TestRenderFrameHost* new_current_rfh = contents()->GetMainFrame(); | |
2934 ASSERT_EQ(new_current_rfh, pending_rfh); | |
2935 EXPECT_TRUE(contents()->IsLoading()); | |
2936 | |
2937 // Simulate the new current RenderFrameHost DidStopLoading. The WebContents | |
2938 // should now have stopped loading. | |
2939 new_current_rfh->OnMessageReceived( | |
2940 FrameHostMsg_DidStopLoading(new_current_rfh->GetRoutingID())); | |
2941 EXPECT_EQ(contents()->GetMainFrame(), new_current_rfh); | |
2942 EXPECT_FALSE(contents()->IsLoading()); | |
2943 } | |
2944 | |
2882 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { | 2945 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { |
2883 // PlayerIDs are actually pointers cast to int64, so verify that both negative | 2946 // PlayerIDs are actually pointers cast to int64, so verify that both negative |
2884 // and positive player ids don't blow up. | 2947 // and positive player ids don't blow up. |
2885 const int kPlayerAudioVideoId = 15; | 2948 const int kPlayerAudioVideoId = 15; |
2886 const int kPlayerAudioOnlyId = -15; | 2949 const int kPlayerAudioOnlyId = -15; |
2887 const int kPlayerVideoOnlyId = 30; | 2950 const int kPlayerVideoOnlyId = 30; |
2888 const int kPlayerRemoteId = -30; | 2951 const int kPlayerRemoteId = -30; |
2889 | 2952 |
2890 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 2953 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
2891 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 2954 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); | 3099 frame->SendBeforeUnloadHandlersPresent(false); |
3037 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | 3100 EXPECT_FALSE(frame->SuddenTerminationAllowed()); |
3038 frame->SendBeforeUnloadHandlersPresent(true); | 3101 frame->SendBeforeUnloadHandlersPresent(true); |
3039 frame->SendUnloadHandlersPresent(false); | 3102 frame->SendUnloadHandlersPresent(false); |
3040 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | 3103 EXPECT_FALSE(frame->SuddenTerminationAllowed()); |
3041 frame->SendBeforeUnloadHandlersPresent(false); | 3104 frame->SendBeforeUnloadHandlersPresent(false); |
3042 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | 3105 EXPECT_TRUE(frame->SuddenTerminationAllowed()); |
3043 } | 3106 } |
3044 | 3107 |
3045 } // namespace content | 3108 } // namespace content |
OLD | NEW |