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

Unified Diff: chrome/browser/extensions/extension_functional_browsertest.cc

Issue 2873503002: NOT YET READY: Improve granularity of window namespaces in Blink.
Patch Set: Rebasing... Created 3 years, 6 months 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
« no previous file with comments | « no previous file | chrome/browser/extensions/process_management_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_functional_browsertest.cc
diff --git a/chrome/browser/extensions/extension_functional_browsertest.cc b/chrome/browser/extensions/extension_functional_browsertest.cc
index 6e83ce5b5b0400eebc8d7450928e42249198b3cf..9e6b5ba6cd418e91294e17282ff20128af44beba 100644
--- a/chrome/browser/extensions/extension_functional_browsertest.cc
+++ b/chrome/browser/extensions/extension_functional_browsertest.cc
@@ -10,8 +10,13 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.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/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
@@ -107,4 +112,60 @@ IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest, MAYBE_TestSetExtensionsState) {
EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
}
+IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest,
+ FindingUnrelatedExtensionFramesFromAboutBlank) {
+ // Load an extension before adding tabs.
+ const extensions::Extension* extension =
+ LoadExtension(test_data_dir_.AppendASCII("simple_with_file"));
+ ASSERT_TRUE(extension);
+ GURL extension_url = extension->GetResourceURL("file.html");
+
+ // Load the extension in two unrelated tabs.
+ ui_test_utils::NavigateToURL(browser(), extension_url);
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), extension_url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ // Sanity-check test setup: 2 frames share a renderer process, but are not in
+ // a related browsing instance.
+ content::RenderFrameHost* tab1 =
+ browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame();
+ content::RenderFrameHost* tab2 =
+ browser()->tab_strip_model()->GetWebContentsAt(1)->GetMainFrame();
+ EXPECT_EQ(tab1->GetProcess(), tab2->GetProcess());
+ EXPECT_FALSE(
+ tab1->GetSiteInstance()->IsRelatedSiteInstance(tab2->GetSiteInstance()));
+
+ // Name the 2 frames.
+ EXPECT_TRUE(content::ExecuteScript(tab1, "window.name = 'tab1';"));
+ EXPECT_TRUE(content::ExecuteScript(tab2, "window.name = 'tab2';"));
+
+ // Open a new window from tab1 and store it in tab1_popup.
+ content::RenderFrameHost* tab1_popup = nullptr;
+ {
+ content::WebContentsAddedObserver new_window_observer;
+ bool did_create_popup = false;
+ ASSERT_TRUE(ExecuteScriptAndExtractBool(
+ tab1,
+ "window.domAutomationController.send("
+ " !!window.open('about:blank', 'new_popup'));",
+ &did_create_popup));
+ ASSERT_TRUE(did_create_popup);
+ content::WebContents* popup_window = new_window_observer.GetWebContents();
+ WaitForLoadStop(popup_window);
+ tab1_popup = popup_window->GetMainFrame();
+ }
+ EXPECT_EQ(GURL(url::kAboutBlankURL), tab1_popup->GetLastCommittedURL());
+
+ // Verify that |tab1_popup| can find unrelated frames from the same extension
+ // (i.e. that it can find |tab2|.
+ std::string location_of_opened_window;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ tab1_popup,
+ "var w = window.open('', 'tab2');\n"
+ "window.domAutomationController.send(w.location.href);",
+ &location_of_opened_window));
+ EXPECT_EQ(tab2->GetLastCommittedURL(), location_of_opened_window);
+}
+
} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/extensions/process_management_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698