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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 183 } |
184 | 184 |
185 void CommandReceived() { | 185 void CommandReceived() { |
186 command_received_count_++; | 186 command_received_count_++; |
187 } | 187 } |
188 | 188 |
189 void set_delegate(Delegate* delegate) { | 189 void set_delegate(Delegate* delegate) { |
190 delegate_ = delegate; | 190 delegate_ = delegate; |
191 } | 191 } |
192 | 192 |
| 193 WebContents* GetWebContents() { |
| 194 return web_contents(); |
| 195 } |
| 196 |
193 protected: | 197 protected: |
194 WebContentsView* CreateWebContentsView() override { return nullptr; } | 198 WebContentsView* CreateWebContentsView() override { return nullptr; } |
195 | 199 |
196 private: | 200 private: |
197 InterstitialState* state_; | 201 InterstitialState* state_; |
198 bool* deleted_; | 202 bool* deleted_; |
199 int command_received_count_; | 203 int command_received_count_; |
200 Delegate* delegate_; | 204 Delegate* delegate_; |
201 }; | 205 }; |
202 | 206 |
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 // While the interstitial is showing, let's simulate the hidden page | 2271 // While the interstitial is showing, let's simulate the hidden page |
2268 // attempting to show a JS message. | 2272 // attempting to show a JS message. |
2269 IPC::Message* dummy_message = new IPC::Message; | 2273 IPC::Message* dummy_message = new IPC::Message; |
2270 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), | 2274 contents()->RunJavaScriptMessage(contents()->GetMainFrame(), |
2271 base::ASCIIToUTF16("This is an informative message"), | 2275 base::ASCIIToUTF16("This is an informative message"), |
2272 base::ASCIIToUTF16("OK"), | 2276 base::ASCIIToUTF16("OK"), |
2273 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); | 2277 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); |
2274 EXPECT_TRUE(contents()->last_dialog_suppressed_); | 2278 EXPECT_TRUE(contents()->last_dialog_suppressed_); |
2275 } | 2279 } |
2276 | 2280 |
| 2281 // Tests that GetFocusedFrame() does not return NULL for an interstitial. |
| 2282 // This is is needed for copying from interstitials on OSX: crbug.com/415784 |
| 2283 TEST_F(WebContentsImplTest, CanGetFocusedFrameInInterstitial) { |
| 2284 // Show an interstitial. |
| 2285 TestInterstitialPage::InterstitialState state = |
| 2286 TestInterstitialPage::INVALID; |
| 2287 bool deleted = false; |
| 2288 GURL interstitial_url("http://interstitial"); |
| 2289 TestInterstitialPage* interstitial = |
| 2290 new TestInterstitialPage(contents(), true, interstitial_url, |
| 2291 &state, &deleted); |
| 2292 TestInterstitialPageStateGuard state_guard(interstitial); |
| 2293 interstitial->Show(); |
| 2294 |
| 2295 // Now let's make the interstitial navigation commit. |
| 2296 interstitial->TestDidNavigate(1, interstitial_url); |
| 2297 |
| 2298 // Test that we can get GetFocusedFrame(). |
| 2299 WebContents* webContents = interstitial->GetWebContents(); |
| 2300 EXPECT_NE(webContents->GetFocusedFrame(), nullptr); |
| 2301 EXPECT_NE(webContents->GetFocusedFrame(), webContents->GetMainFrame()); |
| 2302 |
| 2303 EXPECT_FALSE(deleted); |
| 2304 } |
| 2305 |
2277 // Makes sure that if the source passed to CopyStateFromAndPrune has an | 2306 // Makes sure that if the source passed to CopyStateFromAndPrune has an |
2278 // interstitial it isn't copied over to the destination. | 2307 // interstitial it isn't copied over to the destination. |
2279 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { | 2308 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { |
2280 // Navigate to a page. | 2309 // Navigate to a page. |
2281 GURL url1("http://www.google.com"); | 2310 GURL url1("http://www.google.com"); |
2282 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); | 2311 main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); |
2283 EXPECT_EQ(1, controller().GetEntryCount()); | 2312 EXPECT_EQ(1, controller().GetEntryCount()); |
2284 | 2313 |
2285 // Initiate a browser navigation that will trigger the interstitial | 2314 // Initiate a browser navigation that will trigger the interstitial |
2286 controller().LoadURL(GURL("http://www.evil.com"), Referrer(), | 2315 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( | 3070 contents()->GetMainFrame()->OnMessageReceived( |
3042 FrameHostMsg_RenderProcessGone( | 3071 FrameHostMsg_RenderProcessGone( |
3043 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 3072 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
3044 | 3073 |
3045 // Verify that all the power save blockers have been released. | 3074 // Verify that all the power save blockers have been released. |
3046 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 3075 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
3047 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 3076 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
3048 } | 3077 } |
3049 | 3078 |
3050 } // namespace content | 3079 } // namespace content |
OLD | NEW |