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 3044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3055 // Crash the renderer. | 3055 // Crash the renderer. |
3056 contents()->GetMainFrame()->OnMessageReceived( | 3056 contents()->GetMainFrame()->OnMessageReceived( |
3057 FrameHostMsg_RenderProcessGone( | 3057 FrameHostMsg_RenderProcessGone( |
3058 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 3058 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
3059 | 3059 |
3060 // Verify that all the power save blockers have been released. | 3060 // Verify that all the power save blockers have been released. |
3061 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 3061 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
3062 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 3062 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
3063 } | 3063 } |
3064 | 3064 |
3065 // Test that sudden termination status is properly tracked for a frame. | |
3066 TEST_F(WebContentsImplTest, SuddenTerminationForFrame) { | |
3067 const GURL url("http://www.chromium.org"); | |
3068 contents()->NavigateAndCommit(url); | |
3069 | |
3070 TestRenderFrameHost* frame = contents()->GetMainFrame(); | |
3071 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | |
3072 | |
3073 // Register a BeforeUnload handler. | |
3074 frame->SendBeforeUnloadHandlersPresent(true); | |
3075 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | |
3076 | |
3077 // Unregister the BeforeUnload handler. | |
3078 frame->SendBeforeUnloadHandlersPresent(false); | |
3079 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | |
3080 | |
3081 // Register an Unload handler. | |
3082 frame->SendUnloadHandlersPresent(true); | |
3083 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | |
3084 | |
3085 // Unregister the Unload handler. | |
3086 frame->SendUnloadHandlersPresent(false); | |
3087 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | |
3088 | |
3089 // Register a BeforeUnload handler and an Unload handler. | |
3090 frame->SendBeforeUnloadHandlersPresent(true); | |
3091 frame->SendUnloadHandlersPresent(true); | |
3092 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | |
3093 | |
3094 // Override the sudden termination status. | |
3095 frame->set_override_sudden_termination_status(true); | |
3096 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | |
3097 frame->set_override_sudden_termination_status(false); | |
3098 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | |
3099 | |
3100 // Sudden termination should not be allowed unless there are no BeforeUnload | |
3101 // handlers and no Unload handlers in the RenderFrame. | |
3102 frame->SendBeforeUnloadHandlersPresent(false); | |
3103 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | |
3104 frame->SendBeforeUnloadHandlersPresent(true); | |
3105 frame->SendUnloadHandlersPresent(false); | |
3106 EXPECT_FALSE(frame->SuddenTerminationAllowed()); | |
3107 frame->SendBeforeUnloadHandlersPresent(false); | |
3108 EXPECT_TRUE(frame->SuddenTerminationAllowed()); | |
3109 } | |
3110 | |
3111 } // namespace content | 3065 } // namespace content |
OLD | NEW |