OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 DISALLOW_COPY_AND_ASSIGN(NavigationCompletedObserver); | 174 DISALLOW_COPY_AND_ASSIGN(NavigationCompletedObserver); |
175 }; | 175 }; |
176 | 176 |
177 // Exists as a browser test because ExtensionHosts are hard to create without | 177 // Exists as a browser test because ExtensionHosts are hard to create without |
178 // a real browser. | 178 // a real browser. |
179 class ProcessManagerBrowserTest : public ExtensionBrowserTest { | 179 class ProcessManagerBrowserTest : public ExtensionBrowserTest { |
180 public: | 180 public: |
181 ProcessManagerBrowserTest() { | 181 ProcessManagerBrowserTest() { |
182 guest_view::GuestViewManager::set_factory_for_testing(&factory_); | 182 guest_view::GuestViewManager::set_factory_for_testing(&factory_); |
183 } | 183 } |
| 184 |
| 185 void SetUpOnMainThread() override { |
| 186 ExtensionBrowserTest::SetUpOnMainThread(); |
| 187 host_resolver()->AddRule("*", "127.0.0.1"); |
| 188 } |
| 189 |
184 // Create an extension with web-accessible frames and an optional background | 190 // Create an extension with web-accessible frames and an optional background |
185 // page. | 191 // page. |
186 const Extension* CreateExtension(const std::string& name, | 192 const Extension* CreateExtension(const std::string& name, |
187 bool has_background_process) { | 193 bool has_background_process) { |
188 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir()); | 194 std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir()); |
189 | 195 |
190 DictionaryBuilder manifest; | 196 DictionaryBuilder manifest; |
191 manifest.Set("name", name) | 197 manifest.Set("name", name) |
192 .Set("version", "1") | 198 .Set("version", "1") |
193 .Set("manifest_version", 2) | 199 .Set("manifest_version", 2) |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 423 |
418 // Load an extension with a background page. | 424 // Load an extension with a background page. |
419 scoped_refptr<const Extension> extension = | 425 scoped_refptr<const Extension> extension = |
420 LoadExtension(test_data_dir_.AppendASCII("api_test") | 426 LoadExtension(test_data_dir_.AppendASCII("api_test") |
421 .AppendASCII("browser_action") | 427 .AppendASCII("browser_action") |
422 .AppendASCII("none")); | 428 .AppendASCII("none")); |
423 | 429 |
424 // Set up a test server running at http://[extension-id] | 430 // Set up a test server running at http://[extension-id] |
425 ASSERT_TRUE(extension.get()); | 431 ASSERT_TRUE(extension.get()); |
426 const std::string& aliased_host = extension->id(); | 432 const std::string& aliased_host = extension->id(); |
427 host_resolver()->AddRule(aliased_host, "127.0.0.1"); | |
428 ASSERT_TRUE(embedded_test_server()->Start()); | 433 ASSERT_TRUE(embedded_test_server()->Start()); |
429 GURL url = | 434 GURL url = |
430 embedded_test_server()->GetURL("/extensions/test_file_with_body.html"); | 435 embedded_test_server()->GetURL("/extensions/test_file_with_body.html"); |
431 GURL::Replacements replace_host; | 436 GURL::Replacements replace_host; |
432 replace_host.SetHostStr(aliased_host); | 437 replace_host.SetHostStr(aliased_host); |
433 url = url.ReplaceComponents(replace_host); | 438 url = url.ReplaceComponents(replace_host); |
434 | 439 |
435 // Load a page from the test host in a new tab. | 440 // Load a page from the test host in a new tab. |
436 ui_test_utils::NavigateToURLWithDisposition( | 441 ui_test_utils::NavigateToURLWithDisposition( |
437 browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, | 442 browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 | 1227 |
1223 // Test that when a web site has an extension iframe, navigating that iframe to | 1228 // Test that when a web site has an extension iframe, navigating that iframe to |
1224 // a different web site without --site-per-process will place it in the parent | 1229 // a different web site without --site-per-process will place it in the parent |
1225 // frame's process. See https://crbug.com/711006. | 1230 // frame's process. See https://crbug.com/711006. |
1226 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, | 1231 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, |
1227 ExtensionFrameNavigatesToParentSiteInstance) { | 1232 ExtensionFrameNavigatesToParentSiteInstance) { |
1228 // This test matters only *without* --site-per-process. | 1233 // This test matters only *without* --site-per-process. |
1229 if (content::AreAllSitesIsolatedForTesting()) | 1234 if (content::AreAllSitesIsolatedForTesting()) |
1230 return; | 1235 return; |
1231 | 1236 |
1232 host_resolver()->AddRule("*", "127.0.0.1"); | |
1233 | |
1234 // Create a simple extension without a background page. | 1237 // Create a simple extension without a background page. |
1235 const Extension* extension = CreateExtension("Extension", false); | 1238 const Extension* extension = CreateExtension("Extension", false); |
1236 embedded_test_server()->ServeFilesFromDirectory(extension->path()); | 1239 embedded_test_server()->ServeFilesFromDirectory(extension->path()); |
1237 ASSERT_TRUE(embedded_test_server()->Start()); | 1240 ASSERT_TRUE(embedded_test_server()->Start()); |
1238 | 1241 |
1239 // Navigate main tab to a web page with a blank iframe. There should be no | 1242 // Navigate main tab to a web page with a blank iframe. There should be no |
1240 // extension frames yet. | 1243 // extension frames yet. |
1241 NavigateToURL(embedded_test_server()->GetURL("a.com", "/blank_iframe.html")); | 1244 NavigateToURL(embedded_test_server()->GetURL("a.com", "/blank_iframe.html")); |
1242 ProcessManager* pm = ProcessManager::Get(profile()); | 1245 ProcessManager* pm = ProcessManager::Get(profile()); |
1243 EXPECT_EQ(0u, pm->GetAllFrames().size()); | 1246 EXPECT_EQ(0u, pm->GetAllFrames().size()); |
(...skipping 21 matching lines...) Expand all Loading... |
1265 GURL b_url(embedded_test_server()->GetURL("b.com", "/empty.html")); | 1268 GURL b_url(embedded_test_server()->GetURL("b.com", "/empty.html")); |
1266 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", b_url)); | 1269 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", b_url)); |
1267 { | 1270 { |
1268 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0); | 1271 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0); |
1269 EXPECT_EQ(subframe->GetProcess(), main_frame->GetProcess()); | 1272 EXPECT_EQ(subframe->GetProcess(), main_frame->GetProcess()); |
1270 EXPECT_EQ(subframe->GetSiteInstance(), main_frame->GetSiteInstance()); | 1273 EXPECT_EQ(subframe->GetSiteInstance(), main_frame->GetSiteInstance()); |
1271 } | 1274 } |
1272 } | 1275 } |
1273 | 1276 |
1274 } // namespace extensions | 1277 } // namespace extensions |
OLD | NEW |