Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5045)

Unified Diff: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc

Issue 1478863002: Handle cross-process transfers properly in ExtensionViewHost::OpenURLFromTab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@isolate-extensions-OpenURLFromTab
Patch Set: Add test Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
diff --git a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
index c971ea6fe8ab3fc5d342e1c591d8a29304140a34..f2be1aed57fa1b6378b097bac4bd4c1791b4a772 100644
--- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
+++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
@@ -19,6 +19,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/extension_registry.h"
@@ -29,6 +30,7 @@
#include "extensions/common/feature_switch.h"
#include "extensions/test/result_catcher.h"
#include "grit/theme_resources.h"
+#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/rect.h"
@@ -684,5 +686,54 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, TestTriggerBrowserAction) {
EXPECT_EQ(result, "red");
}
+// Test that a browser action popup with a web iframe works correctly. This
+// primarily targets --isolate-extensions and --site-per-process modes, where
+// the iframe runs in a separate process. See https://crbug.com/546267.
+IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, BrowserActionPopupWithIframe) {
+ host_resolver()->AddRule("*", "127.0.0.1");
+ ASSERT_TRUE(embedded_test_server()->Start());
+
+ ASSERT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("browser_action/popup_with_iframe")));
+ BrowserActionTestUtil* actions_bar = GetBrowserActionsBar();
+ const Extension* extension = GetSingleLoadedExtension();
+ ASSERT_TRUE(extension) << message_;
+
+ // Simulate a click on the browser action to open the popup.
+ ASSERT_TRUE(OpenPopup(0));
+
+ // Find the RenderFrameHost associated with the iframe in the popup.
+ content::RenderFrameHost* frame_host = nullptr;
+ extensions::ProcessManager* manager =
+ extensions::ProcessManager::Get(browser()->profile());
+ std::set<content::RenderFrameHost*> frame_hosts =
+ manager->GetRenderFrameHostsForExtension(extension->id());
+ for (auto host : frame_hosts) {
+ if (host->GetFrameName() == "child_frame") {
+ frame_host = host;
+ break;
+ }
+ }
+
+ ASSERT_TRUE(frame_host);
+ EXPECT_EQ(extension->GetResourceURL("frame.html"),
+ frame_host->GetLastCommittedURL());
+ EXPECT_TRUE(frame_host->GetParent());
+
+ // Navigate the popup's iframe to a (cross-site) web page, and wait for that
+ // page to send a message, which will ensure that the page has loaded.
+ content::DOMMessageQueue msg_queue;
+ GURL foo_url(embedded_test_server()->GetURL("foo.com", "/popup_iframe.html"));
+ std::string script = "location.href = '" + foo_url.spec() + "'";
+ EXPECT_TRUE(content::ExecuteScript(frame_host, script));
+ std::string status;
+ while (msg_queue.WaitForMessage(&status)) {
Devlin 2015/12/01 17:40:17 Is this voodoo different than just using content::
alexmos 2015/12/01 18:09:56 Done - changed to use ExecuteScriptAndExtractStrin
+ if (status == "\"DONE\"")
+ break;
+ }
+
+ EXPECT_TRUE(actions_bar->HidePopup());
+}
+
} // namespace
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698