Chromium Code Reviews| 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 2247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2423 other_controller.GetTransientEntry()->GetUniqueID(); | 2429 other_controller.GetTransientEntry()->GetUniqueID(); |
| 2424 interstitial->TestDidNavigate(1, interstitial_entry_id, true, url3); | 2430 interstitial->TestDidNavigate(1, interstitial_entry_id, true, url3); |
| 2425 EXPECT_TRUE(interstitial->is_showing()); | 2431 EXPECT_TRUE(interstitial->is_showing()); |
| 2426 EXPECT_EQ(2, other_controller.GetEntryCount()); | 2432 EXPECT_EQ(2, other_controller.GetEntryCount()); |
| 2427 | 2433 |
| 2428 // Ensure that we do not allow calling CopyStateFromAndPrune when an | 2434 // Ensure that we do not allow calling CopyStateFromAndPrune when an |
| 2429 // interstitial is showing in the target. | 2435 // interstitial is showing in the target. |
| 2430 EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); | 2436 EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); |
| 2431 } | 2437 } |
| 2432 | 2438 |
| 2439 // Tests if cut/copy/paste IPC messages are sent properly when an interstitial | |
| 2440 // is active. | |
| 2441 TEST_F(WebContentsImplTest, CutCopyPasteInInterstitial) { | |
| 2442 // Show an interstitial. | |
| 2443 TestInterstitialPage::InterstitialState state = | |
| 2444 TestInterstitialPage::INVALID; | |
| 2445 bool deleted = false; | |
| 2446 GURL url2("http://interstitial"); | |
| 2447 TestInterstitialPage* interstitial = | |
| 2448 new TestInterstitialPage(contents(), true, url2, &state, &deleted); | |
| 2449 TestInterstitialPageStateGuard state_guard(interstitial); | |
| 2450 interstitial->Show(); | |
| 2451 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); | |
| 2452 interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); | |
| 2453 EXPECT_TRUE(interstitial->is_showing()); | |
| 2454 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | |
| 2455 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | |
| 2456 | |
| 2457 // Focus the interstitial frame. | |
| 2458 interstitial->FocusRootNode(); | |
| 2459 | |
| 2460 TestRenderFrameHost* rfh = | |
| 2461 static_cast<TestRenderFrameHost*>(interstitial->GetMainFrame()); | |
| 2462 IPC::TestSink& sink = rfh->GetProcess()->sink(); | |
| 2463 RenderWidgetHostImpl* rwh = rfh->GetRenderWidgetHost(); | |
| 2464 RenderWidgetHostDelegate* rwhd = rwh->delegate(); | |
| 2465 | |
| 2466 // Test cut for the interstitial. | |
| 2467 sink.ClearMessages(); | |
| 2468 rwhd->Cut(); | |
| 2469 RunAllPendingInMessageLoop(); | |
| 2470 EXPECT_TRUE(sink.GetUniqueMessageMatching(InputMsg_Cut::ID)); | |
|
nasko
2015/06/15 21:59:45
Let's also verify that the routing id in the messa
| |
| 2471 | |
| 2472 // Test copy for the interstitial. | |
| 2473 sink.ClearMessages(); | |
| 2474 rwhd->Copy(); | |
| 2475 RunAllPendingInMessageLoop(); | |
| 2476 EXPECT_TRUE(sink.GetUniqueMessageMatching(InputMsg_Copy::ID)); | |
| 2477 | |
| 2478 // Test paste for the interstitial. | |
| 2479 sink.ClearMessages(); | |
| 2480 rwhd->Paste(); | |
| 2481 RunAllPendingInMessageLoop(); | |
| 2482 EXPECT_TRUE(sink.GetUniqueMessageMatching(InputMsg_Paste::ID)); | |
| 2483 | |
| 2484 DeleteContents(); | |
| 2485 RunAllPendingInMessageLoop(); | |
| 2486 | |
| 2487 EXPECT_TRUE(deleted); | |
| 2488 } | |
| 2489 | |
| 2433 // Regression test for http://crbug.com/168611 - the URLs passed by the | 2490 // Regression test for http://crbug.com/168611 - the URLs passed by the |
| 2434 // DidFinishLoad and DidFailLoadWithError IPCs should get filtered. | 2491 // DidFinishLoad and DidFailLoadWithError IPCs should get filtered. |
| 2435 TEST_F(WebContentsImplTest, FilterURLs) { | 2492 TEST_F(WebContentsImplTest, FilterURLs) { |
| 2436 TestWebContentsObserver observer(contents()); | 2493 TestWebContentsObserver observer(contents()); |
| 2437 | 2494 |
| 2438 // A navigation to about:whatever should always look like a navigation to | 2495 // A navigation to about:whatever should always look like a navigation to |
| 2439 // about:blank | 2496 // about:blank |
| 2440 GURL url_normalized(url::kAboutBlankURL); | 2497 GURL url_normalized(url::kAboutBlankURL); |
| 2441 GURL url_from_ipc("about:whatever"); | 2498 GURL url_from_ipc("about:whatever"); |
| 2442 | 2499 |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3163 // Additional changes made by the web contents should propagate as well. | 3220 // Additional changes made by the web contents should propagate as well. |
| 3164 RenderViewHostTester::TestOnMessageReceived( | 3221 RenderViewHostTester::TestOnMessageReceived( |
| 3165 test_rvh(), | 3222 test_rvh(), |
| 3166 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN)); | 3223 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN)); |
| 3167 | 3224 |
| 3168 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor()); | 3225 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor()); |
| 3169 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color()); | 3226 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color()); |
| 3170 } | 3227 } |
| 3171 | 3228 |
| 3172 } // namespace content | 3229 } // namespace content |
| OLD | NEW |