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 d056e6ddfd6902bfd982d40b288436386f038e91..a0f5becc86451d4fff6ac5ade39429d1bd9fa9aa 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; } |
@@ -2446,6 +2452,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)); |
+ |
+ // 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) { |