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 946cae8331386b9b77d58161533a0de4fb8539ca..6c9f05ea93bf517b8bea381e5763a7abd0323ecf 100644 |
--- a/content/browser/web_contents/web_contents_impl_unittest.cc |
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc |
@@ -190,6 +190,10 @@ class TestInterstitialPage : public InterstitialPageImpl { |
delegate_ = delegate; |
} |
+ WebContents* GetWebContents() { |
+ return web_contents(); |
+ } |
+ |
protected: |
WebContentsView* CreateWebContentsView() override { return nullptr; } |
@@ -2274,6 +2278,31 @@ TEST_F(WebContentsImplTest, NoJSMessageOnInterstitials) { |
EXPECT_TRUE(contents()->last_dialog_suppressed_); |
} |
+// Tests that GetFocusedFrame() does not return NULL for an interstitial. |
+// This is is needed for copying from interstitials on OSX: crbug.com/415784 |
+TEST_F(WebContentsImplTest, CanGetFocusedFrameInInterstitial) { |
+ // Show an interstitial. |
+ TestInterstitialPage::InterstitialState state = |
+ TestInterstitialPage::INVALID; |
+ bool deleted = false; |
+ GURL interstitial_url("http://interstitial"); |
+ TestInterstitialPage* interstitial = |
+ new TestInterstitialPage(contents(), true, interstitial_url, |
+ &state, &deleted); |
+ TestInterstitialPageStateGuard state_guard(interstitial); |
+ interstitial->Show(); |
+ |
+ // Now let's make the interstitial navigation commit. |
+ interstitial->TestDidNavigate(1, interstitial_url); |
+ |
+ // Test that we can get GetFocusedFrame(). |
+ WebContents* webContents = interstitial->GetWebContents(); |
+ EXPECT_NE(webContents->GetFocusedFrame(), nullptr); |
+ EXPECT_NE(webContents->GetFocusedFrame(), webContents->GetMainFrame()); |
+ |
+ EXPECT_FALSE(deleted); |
+} |
+ |
// Makes sure that if the source passed to CopyStateFromAndPrune has an |
// interstitial it isn't copied over to the destination. |
TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { |