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 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2871 EXPECT_TRUE(observer.is_loading()); | 2871 EXPECT_TRUE(observer.is_loading()); |
2872 | 2872 |
2873 // Send the DidStopLoading for the main frame and ensure it isn't loading | 2873 // Send the DidStopLoading for the main frame and ensure it isn't loading |
2874 // anymore. | 2874 // anymore. |
2875 orig_rfh->OnMessageReceived( | 2875 orig_rfh->OnMessageReceived( |
2876 FrameHostMsg_DidStopLoading(orig_rfh->GetRoutingID())); | 2876 FrameHostMsg_DidStopLoading(orig_rfh->GetRoutingID())); |
2877 EXPECT_FALSE(contents()->IsLoading()); | 2877 EXPECT_FALSE(contents()->IsLoading()); |
2878 EXPECT_FALSE(observer.is_loading()); | 2878 EXPECT_FALSE(observer.is_loading()); |
2879 } | 2879 } |
2880 | 2880 |
2881 // Ensure that WebContentsImpl does not stop loading too early when there still | |
2882 // is a pending renderer. The sequence to reproduce the issue is as follows: | |
2883 // * StartLoading on a frame. | |
2884 // * Start another navigation before the previous frame has finished loading. | |
2885 // * StopLoading on the previous navigation. | |
2886 // At this point, the WebContentsImpl should still be loading as there is still | |
2887 // one pending navigation. | |
clamy
2015/02/26 16:05:00
I think currently the test is not doing quite what
Fabrice (no longer in Chrome)
2015/02/27 17:45:25
Thanks a lot for the explanation! I think I'm now
| |
2888 TEST_F(WebContentsImplTest, NoEarlyStop) { | |
2889 const GURL orig_url("http://www.chromium.org"); | |
2890 const GURL new_url("http://www.google.com"); | |
2891 | |
2892 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | |
2893 | |
2894 // Navigate the RenderFrame, simulate the DidStartLoading, and commit. | |
2895 // The frame should still be loading. | |
2896 controller().LoadURL( | |
2897 orig_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
2898 orig_rfh->OnMessageReceived( | |
2899 FrameHostMsg_DidStartLoading(orig_rfh->GetRoutingID(), false)); | |
2900 contents()->TestDidNavigate(orig_rfh, 1, orig_url, ui::PAGE_TRANSITION_TYPED); | |
2901 EXPECT_FALSE(contents()->cross_navigation_pending()); | |
2902 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | |
2903 EXPECT_TRUE(contents()->IsLoading()); | |
2904 | |
2905 // Navigate to new site, simulate the DidStartLoading, and commit. | |
2906 // The frame should still be loading. | |
2907 controller().LoadURL( | |
2908 new_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
2909 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
2910 switches::kEnableBrowserSideNavigation)) { | |
2911 orig_rfh->PrepareForCommit(new_url); | |
2912 } | |
2913 EXPECT_TRUE(contents()->cross_navigation_pending()); | |
2914 | |
2915 TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame(); | |
2916 ASSERT_NE(new_rfh, nullptr); | |
2917 EXPECT_NE(orig_rfh, new_rfh); | |
2918 new_rfh->OnMessageReceived( | |
2919 FrameHostMsg_DidStartLoading(new_rfh->GetRoutingID(), false)); | |
2920 contents()->TestDidNavigate(new_rfh, 1, new_url, ui::PAGE_TRANSITION_TYPED); | |
2921 EXPECT_TRUE(contents()->IsLoading()); | |
2922 | |
2923 // Simulate the DidStopLoading on the original navigation. The frame should | |
2924 // still be loading. | |
clamy
2015/02/26 16:05:00
At that point the original RFH is swapped out (it
Fabrice (no longer in Chrome)
2015/02/27 17:45:25
Acknowledged.
| |
2925 orig_rfh->OnMessageReceived( | |
2926 FrameHostMsg_DidStopLoading(orig_rfh->GetRoutingID())); | |
2927 EXPECT_TRUE(contents()->IsLoading()); | |
2928 | |
2929 // Simulate the DidStopLoading on the new navigation. The frame should now | |
2930 // have stopped loading. | |
2931 new_rfh->OnMessageReceived( | |
2932 FrameHostMsg_DidStopLoading(new_rfh->GetRoutingID())); | |
2933 EXPECT_FALSE(contents()->IsLoading()); | |
2934 } | |
2935 | |
2881 // ChromeOS doesn't use WebContents based power save blocking. | 2936 // ChromeOS doesn't use WebContents based power save blocking. |
2882 #if !defined(OS_CHROMEOS) | 2937 #if !defined(OS_CHROMEOS) |
2883 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { | 2938 TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) { |
2884 // PlayerIDs are actually pointers cast to int64, so verify that both negative | 2939 // PlayerIDs are actually pointers cast to int64, so verify that both negative |
2885 // and positive player ids don't blow up. | 2940 // and positive player ids don't blow up. |
2886 const int kPlayerAudioVideoId = 15; | 2941 const int kPlayerAudioVideoId = 15; |
2887 const int kPlayerAudioOnlyId = -15; | 2942 const int kPlayerAudioOnlyId = -15; |
2888 const int kPlayerVideoOnlyId = 30; | 2943 const int kPlayerVideoOnlyId = 30; |
2889 const int kPlayerRemoteId = -30; | 2944 const int kPlayerRemoteId = -30; |
2890 | 2945 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3038 frame->SendBeforeUnloadHandlersPresent(false); | 3093 frame->SendBeforeUnloadHandlersPresent(false); |
3039 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | 3094 EXPECT_FALSE(frame->SuddenTerminationAllowed()); |
3040 frame->SendBeforeUnloadHandlersPresent(true); | 3095 frame->SendBeforeUnloadHandlersPresent(true); |
3041 frame->SendUnloadHandlersPresent(false); | 3096 frame->SendUnloadHandlersPresent(false); |
3042 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | 3097 EXPECT_FALSE(frame->SuddenTerminationAllowed()); |
3043 frame->SendBeforeUnloadHandlersPresent(false); | 3098 frame->SendBeforeUnloadHandlersPresent(false); |
3044 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | 3099 EXPECT_TRUE(frame->SuddenTerminationAllowed()); |
3045 } | 3100 } |
3046 | 3101 |
3047 } // namespace content | 3102 } // namespace content |
OLD | NEW |