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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/process_management_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "chrome/browser/extensions/crx_installer.h" 8 #include "chrome/browser/extensions/crx_installer.h"
9 #include "chrome/browser/extensions/extension_browsertest.h" 9 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_util.h" 11 #include "chrome/browser/extensions/extension_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_commands.h" 14 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/test/base/ui_test_utils.h"
14 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/test_utils.h" 20 #include "content/public/test/test_utils.h"
16 #include "extensions/browser/extension_registry.h" 21 #include "extensions/browser/extension_registry.h"
17 #include "extensions/browser/extension_system.h" 22 #include "extensions/browser/extension_system.h"
18 #include "extensions/browser/extension_util.h" 23 #include "extensions/browser/extension_util.h"
19 #include "extensions/browser/notification_types.h" 24 #include "extensions/browser/notification_types.h"
20 #include "extensions/browser/test_extension_registry_observer.h" 25 #include "extensions/browser/test_extension_registry_observer.h"
21 26
22 namespace extensions { 27 namespace extensions {
23 28
24 class ExtensionFunctionalTest : public ExtensionBrowserTest { 29 class ExtensionFunctionalTest : public ExtensionBrowserTest {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 service->EnableExtension(last_loaded_extension_id()); 105 service->EnableExtension(last_loaded_extension_id());
101 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), true); 106 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), true);
102 EXPECT_TRUE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile())); 107 EXPECT_TRUE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
103 108
104 // Disallow extension in incognito mode and verify. 109 // Disallow extension in incognito mode and verify.
105 service->EnableExtension(last_loaded_extension_id()); 110 service->EnableExtension(last_loaded_extension_id());
106 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false); 111 util::SetIsIncognitoEnabled(last_loaded_extension_id(), profile(), false);
107 EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile())); 112 EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension_id(), profile()));
108 } 113 }
109 114
115 IN_PROC_BROWSER_TEST_F(ExtensionFunctionalTest,
116 FindingUnrelatedExtensionFramesFromAboutBlank) {
117 // Load an extension before adding tabs.
118 const extensions::Extension* extension =
119 LoadExtension(test_data_dir_.AppendASCII("simple_with_file"));
120 ASSERT_TRUE(extension);
121 GURL extension_url = extension->GetResourceURL("file.html");
122
123 // Load the extension in two unrelated tabs.
124 ui_test_utils::NavigateToURL(browser(), extension_url);
125 ui_test_utils::NavigateToURLWithDisposition(
126 browser(), extension_url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
127 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
128
129 // Sanity-check test setup: 2 frames share a renderer process, but are not in
130 // a related browsing instance.
131 content::RenderFrameHost* tab1 =
132 browser()->tab_strip_model()->GetWebContentsAt(0)->GetMainFrame();
133 content::RenderFrameHost* tab2 =
134 browser()->tab_strip_model()->GetWebContentsAt(1)->GetMainFrame();
135 EXPECT_EQ(tab1->GetProcess(), tab2->GetProcess());
136 EXPECT_FALSE(
137 tab1->GetSiteInstance()->IsRelatedSiteInstance(tab2->GetSiteInstance()));
138
139 // Name the 2 frames.
140 EXPECT_TRUE(content::ExecuteScript(tab1, "window.name = 'tab1';"));
141 EXPECT_TRUE(content::ExecuteScript(tab2, "window.name = 'tab2';"));
142
143 // Open a new window from tab1 and store it in tab1_popup.
144 content::RenderFrameHost* tab1_popup = nullptr;
145 {
146 content::WebContentsAddedObserver new_window_observer;
147 bool did_create_popup = false;
148 ASSERT_TRUE(ExecuteScriptAndExtractBool(
149 tab1,
150 "window.domAutomationController.send("
151 " !!window.open('about:blank', 'new_popup'));",
152 &did_create_popup));
153 ASSERT_TRUE(did_create_popup);
154 content::WebContents* popup_window = new_window_observer.GetWebContents();
155 WaitForLoadStop(popup_window);
156 tab1_popup = popup_window->GetMainFrame();
157 }
158 EXPECT_EQ(GURL(url::kAboutBlankURL), tab1_popup->GetLastCommittedURL());
159
160 // Verify that |tab1_popup| can find unrelated frames from the same extension
161 // (i.e. that it can find |tab2|.
162 std::string location_of_opened_window;
163 EXPECT_TRUE(ExecuteScriptAndExtractString(
164 tab1_popup,
165 "var w = window.open('', 'tab2');\n"
166 "window.domAutomationController.send(w.location.href);",
167 &location_of_opened_window));
168 EXPECT_EQ(tab2->GetLastCommittedURL(), location_of_opened_window);
169 }
170
110 } // namespace extensions 171 } // namespace extensions
OLDNEW
« 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