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" |
11 #include "content/browser/frame_host/render_frame_host_impl.h" | 11 #include "content/browser/frame_host/render_frame_host_impl.h" |
12 #include "content/browser/media/audio_state_provider.h" | 12 #include "content/browser/media/audio_state_provider.h" |
13 #include "content/browser/renderer_host/render_view_host_impl.h" | 13 #include "content/browser/renderer_host/render_view_host_impl.h" |
14 #include "content/browser/site_instance_impl.h" | 14 #include "content/browser/site_instance_impl.h" |
15 #include "content/browser/webui/content_web_ui_controller_factory.h" | 15 #include "content/browser/webui/content_web_ui_controller_factory.h" |
16 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 16 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
17 #include "content/common/frame_messages.h" | 17 #include "content/common/frame_messages.h" |
18 #include "content/common/input/synthetic_web_input_event_builders.h" | 18 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 19 #include "content/common/input_messages.h" |
19 #include "content/common/view_messages.h" | 20 #include "content/common/view_messages.h" |
20 #include "content/public/browser/global_request_id.h" | 21 #include "content/public/browser/global_request_id.h" |
21 #include "content/public/browser/interstitial_page_delegate.h" | 22 #include "content/public/browser/interstitial_page_delegate.h" |
22 #include "content/public/browser/navigation_details.h" | 23 #include "content/public/browser/navigation_details.h" |
23 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
25 #include "content/public/browser/render_widget_host_view.h" | 26 #include "content/public/browser/render_widget_host_view.h" |
26 #include "content/public/browser/web_contents_delegate.h" | 27 #include "content/public/browser/web_contents_delegate.h" |
27 #include "content/public/browser/web_contents_observer.h" | 28 #include "content/public/browser/web_contents_observer.h" |
28 #include "content/public/browser/web_ui_controller.h" | 29 #include "content/public/browser/web_ui_controller.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 157 } |
157 | 158 |
158 void CommandReceived() { | 159 void CommandReceived() { |
159 command_received_count_++; | 160 command_received_count_++; |
160 } | 161 } |
161 | 162 |
162 void set_delegate(Delegate* delegate) { | 163 void set_delegate(Delegate* delegate) { |
163 delegate_ = delegate; | 164 delegate_ = delegate; |
164 } | 165 } |
165 | 166 |
| 167 void FocusRootNode() { |
| 168 FrameTree* tree = GetFrameTree(); |
| 169 tree->SetFocusedFrame(tree->root()); |
| 170 } |
| 171 |
166 protected: | 172 protected: |
167 WebContentsView* CreateWebContentsView() override { return nullptr; } | 173 WebContentsView* CreateWebContentsView() override { return nullptr; } |
168 | 174 |
169 private: | 175 private: |
170 InterstitialState* state_; | 176 InterstitialState* state_; |
171 bool* deleted_; | 177 bool* deleted_; |
172 int command_received_count_; | 178 int command_received_count_; |
173 Delegate* delegate_; | 179 Delegate* delegate_; |
174 }; | 180 }; |
175 | 181 |
(...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 other_controller.GetTransientEntry()->GetUniqueID(); | 2445 other_controller.GetTransientEntry()->GetUniqueID(); |
2440 interstitial->TestDidNavigate(1, interstitial_entry_id, true, url3); | 2446 interstitial->TestDidNavigate(1, interstitial_entry_id, true, url3); |
2441 EXPECT_TRUE(interstitial->is_showing()); | 2447 EXPECT_TRUE(interstitial->is_showing()); |
2442 EXPECT_EQ(2, other_controller.GetEntryCount()); | 2448 EXPECT_EQ(2, other_controller.GetEntryCount()); |
2443 | 2449 |
2444 // Ensure that we do not allow calling CopyStateFromAndPrune when an | 2450 // Ensure that we do not allow calling CopyStateFromAndPrune when an |
2445 // interstitial is showing in the target. | 2451 // interstitial is showing in the target. |
2446 EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); | 2452 EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); |
2447 } | 2453 } |
2448 | 2454 |
| 2455 // Tests if cut/copy/paste IPC messages are sent properly when an interstitial |
| 2456 // is active. |
| 2457 TEST_F(WebContentsImplTest, CutCopyPasteInInterstitial) { |
| 2458 // Show an interstitial. |
| 2459 TestInterstitialPage::InterstitialState state = |
| 2460 TestInterstitialPage::INVALID; |
| 2461 bool deleted = false; |
| 2462 GURL url2("http://interstitial"); |
| 2463 TestInterstitialPage* interstitial = |
| 2464 new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
| 2465 TestInterstitialPageStateGuard state_guard(interstitial); |
| 2466 interstitial->Show(); |
| 2467 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); |
| 2468 interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); |
| 2469 EXPECT_TRUE(interstitial->is_showing()); |
| 2470 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
| 2471 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
| 2472 |
| 2473 // Focus the interstitial frame. |
| 2474 interstitial->FocusRootNode(); |
| 2475 |
| 2476 TestRenderFrameHost* rfh = |
| 2477 static_cast<TestRenderFrameHost*>(interstitial->GetMainFrame()); |
| 2478 IPC::TestSink& sink = rfh->GetProcess()->sink(); |
| 2479 RenderWidgetHostImpl* rwh = rfh->GetRenderWidgetHost(); |
| 2480 RenderWidgetHostDelegate* rwhd = rwh->delegate(); |
| 2481 |
| 2482 // Test cut for the interstitial. |
| 2483 sink.ClearMessages(); |
| 2484 rwhd->Cut(); |
| 2485 RunAllPendingInMessageLoop(); |
| 2486 EXPECT_TRUE(sink.GetUniqueMessageMatching(InputMsg_Cut::ID)); |
| 2487 |
| 2488 // Test copy for the interstitial. |
| 2489 sink.ClearMessages(); |
| 2490 rwhd->Copy(); |
| 2491 RunAllPendingInMessageLoop(); |
| 2492 EXPECT_TRUE(sink.GetUniqueMessageMatching(InputMsg_Copy::ID)); |
| 2493 |
| 2494 // Test paste for the interstitial. |
| 2495 sink.ClearMessages(); |
| 2496 rwhd->Paste(); |
| 2497 RunAllPendingInMessageLoop(); |
| 2498 EXPECT_TRUE(sink.GetUniqueMessageMatching(InputMsg_Paste::ID)); |
| 2499 |
| 2500 DeleteContents(); |
| 2501 RunAllPendingInMessageLoop(); |
| 2502 |
| 2503 EXPECT_TRUE(deleted); |
| 2504 } |
| 2505 |
2449 // Regression test for http://crbug.com/168611 - the URLs passed by the | 2506 // Regression test for http://crbug.com/168611 - the URLs passed by the |
2450 // DidFinishLoad and DidFailLoadWithError IPCs should get filtered. | 2507 // DidFinishLoad and DidFailLoadWithError IPCs should get filtered. |
2451 TEST_F(WebContentsImplTest, FilterURLs) { | 2508 TEST_F(WebContentsImplTest, FilterURLs) { |
2452 TestWebContentsObserver observer(contents()); | 2509 TestWebContentsObserver observer(contents()); |
2453 | 2510 |
2454 // A navigation to about:whatever should always look like a navigation to | 2511 // A navigation to about:whatever should always look like a navigation to |
2455 // about:blank | 2512 // about:blank |
2456 GURL url_normalized(url::kAboutBlankURL); | 2513 GURL url_normalized(url::kAboutBlankURL); |
2457 GURL url_from_ipc("about:whatever"); | 2514 GURL url_from_ipc("about:whatever"); |
2458 | 2515 |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3183 // Additional changes made by the web contents should propagate as well. | 3240 // Additional changes made by the web contents should propagate as well. |
3184 RenderViewHostTester::TestOnMessageReceived( | 3241 RenderViewHostTester::TestOnMessageReceived( |
3185 test_rvh(), | 3242 test_rvh(), |
3186 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN)); | 3243 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN)); |
3187 | 3244 |
3188 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor()); | 3245 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor()); |
3189 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color()); | 3246 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color()); |
3190 } | 3247 } |
3191 | 3248 |
3192 } // namespace content | 3249 } // namespace content |
OLD | NEW |