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 2256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2267 // While the interstitial is showing, let's simulate the hidden page | 2267 // While the interstitial is showing, let's simulate the hidden page |
2268 // attempting to show a JS message. | 2268 // attempting to show a JS message. |
2269 IPC::Message* dummy_message = new IPC::Message; | 2269 IPC::Message* dummy_message = new IPC::Message; |
2270 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), | 2270 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), |
2271 base::ASCIIToUTF16("This is an informative message"), | 2271 base::ASCIIToUTF16("This is an informative message"), |
2272 base::ASCIIToUTF16("OK"), | 2272 base::ASCIIToUTF16("OK"), |
2273 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); | 2273 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); |
2274 EXPECT_TRUE(contents()->last_dialog_suppressed_); | 2274 EXPECT_TRUE(contents()->last_dialog_suppressed_); |
2275 } | 2275 } |
2276 | 2276 |
2277 // Tests that GetFocusedFrame() does not return NULL for an interstitial. | |
2278 // This is is needed for copying from interstitials on OSX: crbug.com/415784 | |
2279 TEST_F(WebContentsImplTest, CanGetFocusedFrameInInterstitial) { | |
2280 // Show an interstitial. | |
2281 TestInterstitialPage::InterstitialState state = | |
2282 TestInterstitialPage::INVALID; | |
2283 bool deleted = false; | |
2284 GURL interstitial_url("http://interstitial"); | |
2285 TestInterstitialPage* interstitial = | |
2286 new TestInterstitialPage(contents(), true, interstitial_url, | |
2287 &state, &deleted); | |
2288 TestInterstitialPageStateGuard state_guard(interstitial); | |
2289 interstitial->Show(); | |
2290 | |
2291 // Now let's make the interstitial navigation commit. | |
2292 interstitial->TestDidNavigate(1, interstitial_url); | |
2293 | |
2294 // Test that we can get GetFocusedFrame(). | |
2295 EXPECT_NE(nullptr, interstitial->GetAsWebContents()->GetFocusedFrame()); | |
nasko
2015/04/22 05:07:45
Let's add accessor that exposes the associated Web
lgarron
2015/04/22 07:19:54
As of a week ago, InterstitialPageImpl has a prote
| |
2296 | |
nasko
2015/04/22 05:07:45
I think we can another expectation here. The Rende
lgarron
2015/04/22 07:19:54
Done.
| |
2297 EXPECT_FALSE(deleted); | |
2298 } | |
2299 | |
2277 // Makes sure that if the source passed to CopyStateFromAndPrune has an | 2300 // Makes sure that if the source passed to CopyStateFromAndPrune has an |
2278 // interstitial it isn't copied over to the destination. | 2301 // interstitial it isn't copied over to the destination. |
2279 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { | 2302 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { |
2280 // Navigate to a page. | 2303 // Navigate to a page. |
2281 GURL url1("http://www.google.com"); | 2304 GURL url1("http://www.google.com"); |
2282 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); | 2305 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
2283 EXPECT_EQ(1, controller().GetEntryCount()); | 2306 EXPECT_EQ(1, controller().GetEntryCount()); |
2284 | 2307 |
2285 // Initiate a browser navigation that will trigger the interstitial | 2308 // Initiate a browser navigation that will trigger the interstitial |
2286 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), | 2309 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3041 contents()->GetMainFrame()->OnMessageReceived( | 3064 contents()->GetMainFrame()->OnMessageReceived( |
3042 FrameHostMsg_RenderProcessGone( | 3065 FrameHostMsg_RenderProcessGone( |
3043 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 3066 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
3044 | 3067 |
3045 // Verify that all the power save blockers have been released. | 3068 // Verify that all the power save blockers have been released. |
3046 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 3069 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
3047 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 3070 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
3048 } | 3071 } |
3049 | 3072 |
3050 } // namespace content | 3073 } // namespace content |
OLD | NEW |