Chromium Code Reviews| Index: content/browser/web_contents/web_contents_impl_unittest.cc |
| diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc |
| index 309a91c31820ca14b1e4ab873b6347ddeefaf1a2..f67837026b2b6bdaa887c653cefd563bdb3c25f0 100644 |
| --- a/content/browser/web_contents/web_contents_impl_unittest.cc |
| +++ b/content/browser/web_contents/web_contents_impl_unittest.cc |
| @@ -16,6 +16,7 @@ |
| #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| #include "content/common/frame_messages.h" |
| #include "content/common/input/synthetic_web_input_event_builders.h" |
| +#include "content/common/input_messages.h" |
| #include "content/common/view_messages.h" |
| #include "content/public/browser/global_request_id.h" |
| #include "content/public/browser/interstitial_page_delegate.h" |
| @@ -163,6 +164,11 @@ class TestInterstitialPage : public InterstitialPageImpl { |
| delegate_ = delegate; |
| } |
| + void FocusRootNode() { |
| + FrameTree* tree = GetFrameTree(); |
| + tree->SetFocusedFrame(tree->root()); |
| + } |
| + |
| protected: |
| WebContentsView* CreateWebContentsView() override { return nullptr; } |
| @@ -2430,6 +2436,57 @@ TEST_F(WebContentsImplTest, CopyStateFromAndPruneTargetInterstitial) { |
| EXPECT_FALSE(other_controller.CanPruneAllButLastCommitted()); |
| } |
| +// Tests if cut/copy/paste IPC messages are sent properly when an interstitial |
| +// is active. |
| +TEST_F(WebContentsImplTest, CutCopyPasteInInterstitial) { |
| + // Show an interstitial. |
| + TestInterstitialPage::InterstitialState state = |
| + TestInterstitialPage::INVALID; |
| + bool deleted = false; |
| + GURL url2("http://interstitial"); |
| + TestInterstitialPage* interstitial = |
| + new TestInterstitialPage(contents(), true, url2, &state, &deleted); |
| + TestInterstitialPageStateGuard state_guard(interstitial); |
| + interstitial->Show(); |
| + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); |
| + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); |
| + EXPECT_TRUE(interstitial->is_showing()); |
| + EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
| + EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
| + |
| + // Focus the interstitial frame. |
| + interstitial->FocusRootNode(); |
| + |
| + TestRenderFrameHost* rfh = |
| + static_cast<TestRenderFrameHost*>(interstitial->GetMainFrame()); |
| + IPC::TestSink& sink = rfh->GetProcess()->sink(); |
| + RenderWidgetHostImpl* rwh = rfh->GetRenderWidgetHost(); |
| + RenderWidgetHostDelegate* rwhd = rwh->delegate(); |
| + |
| + // Test cut for the interstitial. |
| + sink.ClearMessages(); |
| + rwhd->Cut(); |
| + RunAllPendingInMessageLoop(); |
| + 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
|
| + |
| + // Test copy for the interstitial. |
| + sink.ClearMessages(); |
| + rwhd->Copy(); |
| + RunAllPendingInMessageLoop(); |
| + EXPECT_TRUE(sink.GetUniqueMessageMatching(InputMsg_Copy::ID)); |
| + |
| + // Test paste for the interstitial. |
| + sink.ClearMessages(); |
| + rwhd->Paste(); |
| + RunAllPendingInMessageLoop(); |
| + EXPECT_TRUE(sink.GetUniqueMessageMatching(InputMsg_Paste::ID)); |
| + |
| + DeleteContents(); |
| + RunAllPendingInMessageLoop(); |
| + |
| + EXPECT_TRUE(deleted); |
| +} |
| + |
| // Regression test for http://crbug.com/168611 - the URLs passed by the |
| // DidFinishLoad and DidFailLoadWithError IPCs should get filtered. |
| TEST_F(WebContentsImplTest, FilterURLs) { |