Chromium Code Reviews| Index: chrome/browser/extensions/extension_messages_apitest.cc |
| diff --git a/chrome/browser/extensions/extension_messages_apitest.cc b/chrome/browser/extensions/extension_messages_apitest.cc |
| index 2ecbf6644bc77d2284bd71b2e5e854165ac6553a..b3bfdfdd2c9797b4bbbcdc400fc0470c52d28c35 100644 |
| --- a/chrome/browser/extensions/extension_messages_apitest.cc |
| +++ b/chrome/browser/extensions/extension_messages_apitest.cc |
| @@ -347,6 +347,10 @@ class ExternallyConnectableMessagingTest : public ExtensionApiTest { |
| return GetURLForPath("www.chromium.org", "/chromium.org.html"); |
| } |
| + GURL popup_opener_url() { |
| + return GetURLForPath("www.chromium.org", "/popup_opener.html"); |
| + } |
| + |
| GURL google_com_url() { |
| return GetURLForPath("www.google.com", "/google.com.html"); |
| } |
| @@ -1018,6 +1022,40 @@ IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, |
| EXPECT_FALSE(AreAnyNonWebApisDefinedForIFrame()); |
| } |
| +IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, FromPopup) { |
| + base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| + switches::kDisablePopupBlocking); |
| + |
| + InitializeTestServer(); |
| + scoped_refptr<const Extension> extension = LoadChromiumConnectableExtension(); |
| + |
| + // This will let us wait for the chromium.org.html page to load in a popup. |
| + ui_test_utils::UrlLoadObserver url_observer( |
| + chromium_org_url(), content::NotificationService::AllSources()); |
| + |
| + // The page at popup_opener_url() should open chromium_org_url() as a popup. |
| + ui_test_utils::NavigateToURL(browser(), popup_opener_url()); |
| + url_observer.Wait(); |
| + |
| + content::WebContents* popup_contents = nullptr; |
| + for (int i = 0; i < browser()->tab_strip_model()->count(); i++) { |
|
Devlin
2016/08/03 16:16:49
This is a shame, because UrlLoadObserver could alr
asargent_no_longer_on_chrome
2016/08/04 05:47:18
Left a TODO, to try and get this CL in faster.
|
| + content::WebContents* contents = |
| + browser()->tab_strip_model()->GetWebContentsAt(i); |
| + if (contents->GetLastCommittedURL() == chromium_org_url()) { |
| + popup_contents = contents; |
| + break; |
| + } |
| + } |
| + ASSERT_NE(nullptr, popup_contents) << "Could not find WebContents for popup"; |
| + |
| + // Make sure the popup can connect and send messages to the extension. |
| + content::RenderFrameHost* popup_frame = popup_contents->GetMainFrame(); |
| + |
| + EXPECT_EQ(OK, CanConnectAndSendMessagesToFrame(popup_frame, extension.get(), |
| + nullptr)); |
| + EXPECT_FALSE(AreAnyNonWebApisDefinedForFrame(popup_frame)); |
| +} |
| + |
| // Tests externally_connectable between a web page and an extension with a |
| // TLS channel ID created for the origin. |
| class ExternallyConnectableMessagingWithTlsChannelIdTest : |