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. The sequence to reproduce the issue is as follows: | |
2884 // * StartLoading on a frame. | |
2885 // * Start another navigation before the previous frame has finished loading. | |
2886 // * StopLoading on the previous navigation. | |
2887 // At this point, the WebContentsImpl should still be loading as there is still | |
2888 // one pending navigation. | |
2889 TEST_F(WebContentsImplTest, NoEarlyStop) { | |
2890 const GURL orig_url("http://www.chromium.org"); | |
2891 const GURL new_url("http://www.google.com"); | |
2892 | |
2893 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | |
2894 | |
2895 // Navigate the RenderFrame, simulate the DidStartLoading, and commit. | |
nasko
2015/02/26 23:30:34
nit: RenderFrameHost
Fabrice (no longer in Chrome)
2015/02/27 17:45:25
Acknowledged.
| |
2896 // The frame should still be loading. | |
2897 controller().LoadURL( | |
2898 orig_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
2899 orig_rfh->OnMessageReceived( | |
2900 FrameHostMsg_DidStartLoading(orig_rfh->GetRoutingID(), false)); | |
2901 contents()->TestDidNavigate(orig_rfh, 1, orig_url, ui::PAGE_TRANSITION_TYPED); | |
2902 EXPECT_FALSE(contents()->cross_navigation_pending()); | |
2903 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | |
2904 EXPECT_TRUE(contents()->IsLoading()); | |
2905 | |
2906 // Navigate to new site, simulate the DidStartLoading, and commit. | |
2907 // The frame should still be loading. | |
2908 controller().LoadURL( | |
2909 new_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
2910 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
2911 switches::kEnableBrowserSideNavigation)) { | |
2912 orig_rfh->PrepareForCommit(new_url); | |
nasko
2015/02/26 23:30:33
Should this be in an if statement? I thought Prepa
Fabrice (no longer in Chrome)
2015/02/27 17:45:25
You are correct, fixed.
| |
2913 } | |
2914 EXPECT_TRUE(contents()->cross_navigation_pending()); | |
2915 | |
2916 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); | |
2917 ASSERT_NE(new_rfh, nullptr); | |
2918 EXPECT_NE(orig_rfh, new_rfh); | |
2919 new_rfh->OnMessageReceived( | |
2920 FrameHostMsg_DidStartLoading(new_rfh->GetRoutingID(), false)); | |
2921 contents()->TestDidNavigate(new_rfh, 1, new_url, ui::PAGE_TRANSITION_TYPED); | |
2922 EXPECT_TRUE(contents()->IsLoading()); | |
2923 | |
2924 // Simulate the DidStopLoading on the original navigation. The frame should | |
2925 // still be loading. | |
2926 orig_rfh->OnMessageReceived( | |
2927 FrameHostMsg_DidStopLoading(orig_rfh->GetRoutingID())); | |
2928 EXPECT_TRUE(contents()->IsLoading()); | |
2929 | |
2930 // Simulate the DidStopLoading on the new navigation. The frame should now | |
2931 // have stopped loading. | |
2932 new_rfh->OnMessageReceived( | |
2933 FrameHostMsg_DidStopLoading(new_rfh->GetRoutingID())); | |
2934 EXPECT_FALSE(contents()->IsLoading()); | |
2935 } | |
2936 | |
2882 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { | 2937 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { |
2883 // PlayerIDs are actually pointers cast to int64, so verify that both negative | 2938 // PlayerIDs are actually pointers cast to int64, so verify that both negative |
2884 // and positive player ids don't blow up. | 2939 // and positive player ids don't blow up. |
2885 const int kPlayerAudioVideoId = 15; | 2940 const int kPlayerAudioVideoId = 15; |
2886 const int kPlayerAudioOnlyId = -15; | 2941 const int kPlayerAudioOnlyId = -15; |
2887 const int kPlayerVideoOnlyId = 30; | 2942 const int kPlayerVideoOnlyId = 30; |
2888 const int kPlayerRemoteId = -30; | 2943 const int kPlayerRemoteId = -30; |
2889 | 2944 |
2890 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 2945 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
2891 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 2946 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); | 3091 frame->SendBeforeUnloadHandlersPresent(false); |
3037 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | 3092 EXPECT_FALSE(frame->SuddenTerminationAllowed()); |
3038 frame->SendBeforeUnloadHandlersPresent(true); | 3093 frame->SendBeforeUnloadHandlersPresent(true); |
3039 frame->SendUnloadHandlersPresent(false); | 3094 frame->SendUnloadHandlersPresent(false); |
3040 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | 3095 EXPECT_FALSE(frame->SuddenTerminationAllowed()); |
3041 frame->SendBeforeUnloadHandlersPresent(false); | 3096 frame->SendBeforeUnloadHandlersPresent(false); |
3042 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | 3097 EXPECT_TRUE(frame->SuddenTerminationAllowed()); |
3043 } | 3098 } |
3044 | 3099 |
3045 } // namespace content | 3100 } // namespace content |
OLD | NEW |