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

Side by Side Diff: chrome/browser/extensions/process_manager_browsertest.cc

Issue 671763002: Extract ProcessManager from ExtensionSystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 1 month 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
OLDNEW
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 "extensions/browser/process_manager.h" 5 #include "extensions/browser/process_manager.h"
6 6
7 #include "chrome/browser/extensions/browser_action_test_util.h" 7 #include "chrome/browser/extensions/browser_action_test_util.h"
8 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
16 #include "extensions/browser/extension_system.h"
17 #include "net/dns/mock_host_resolver.h" 16 #include "net/dns/mock_host_resolver.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h" 17 #include "net/test/embedded_test_server/embedded_test_server.h"
19 18
20 namespace extensions { 19 namespace extensions {
21 20
22 // Exists as a browser test because ExtensionHosts are hard to create without 21 // Exists as a browser test because ExtensionHosts are hard to create without
23 // a real browser. 22 // a real browser.
24 typedef ExtensionBrowserTest ProcessManagerBrowserTest; 23 typedef ExtensionBrowserTest ProcessManagerBrowserTest;
25 24
26 // Test that basic extension loading creates the appropriate ExtensionHosts 25 // Test that basic extension loading creates the appropriate ExtensionHosts
27 // and background pages. 26 // and background pages.
28 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, 27 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
29 ExtensionHostCreation) { 28 ExtensionHostCreation) {
30 ProcessManager* pm = ExtensionSystem::Get(profile())->process_manager(); 29 ProcessManager* pm = ProcessManager::Get(profile());
31 30
32 // We start with no background hosts. 31 // We start with no background hosts.
33 ASSERT_EQ(0u, pm->background_hosts().size()); 32 ASSERT_EQ(0u, pm->background_hosts().size());
34 ASSERT_EQ(0u, pm->GetAllViews().size()); 33 ASSERT_EQ(0u, pm->GetAllViews().size());
35 34
36 // Load an extension with a background page. 35 // Load an extension with a background page.
37 scoped_refptr<const Extension> extension = 36 scoped_refptr<const Extension> extension =
38 LoadExtension(test_data_dir_.AppendASCII("api_test") 37 LoadExtension(test_data_dir_.AppendASCII("api_test")
39 .AppendASCII("browser_action") 38 .AppendASCII("browser_action")
40 .AppendASCII("none")); 39 .AppendASCII("none"));
(...skipping 20 matching lines...) Expand all
61 EXPECT_FALSE(pm->IsBackgroundHostClosing(extension->id())); 60 EXPECT_FALSE(pm->IsBackgroundHostClosing(extension->id()));
62 EXPECT_EQ(0, pm->GetLazyKeepaliveCount(extension.get())); 61 EXPECT_EQ(0, pm->GetLazyKeepaliveCount(extension.get()));
63 } 62 }
64 63
65 // Test that loading an extension with a browser action does not create a 64 // Test that loading an extension with a browser action does not create a
66 // background page and that clicking on the action creates the appropriate 65 // background page and that clicking on the action creates the appropriate
67 // ExtensionHost. 66 // ExtensionHost.
68 // Disabled due to flake, see http://crbug.com/315242 67 // Disabled due to flake, see http://crbug.com/315242
69 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, 68 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
70 DISABLED_PopupHostCreation) { 69 DISABLED_PopupHostCreation) {
71 ProcessManager* pm = ExtensionSystem::Get(profile())->process_manager(); 70 ProcessManager* pm = ProcessManager::Get(profile());
72 71
73 // Load an extension with the ability to open a popup but no background 72 // Load an extension with the ability to open a popup but no background
74 // page. 73 // page.
75 scoped_refptr<const Extension> popup = 74 scoped_refptr<const Extension> popup =
76 LoadExtension(test_data_dir_.AppendASCII("api_test") 75 LoadExtension(test_data_dir_.AppendASCII("api_test")
77 .AppendASCII("browser_action") 76 .AppendASCII("browser_action")
78 .AppendASCII("popup")); 77 .AppendASCII("popup"));
79 ASSERT_TRUE(popup.get()); 78 ASSERT_TRUE(popup.get());
80 79
81 // No background host was added. 80 // No background host was added.
(...skipping 22 matching lines...) Expand all
104 EXPECT_EQ(1u, pm->GetRenderViewHostsForExtension(popup->id()).size()); 103 EXPECT_EQ(1u, pm->GetRenderViewHostsForExtension(popup->id()).size());
105 EXPECT_TRUE(pm->GetSiteInstanceForURL(popup->url())); 104 EXPECT_TRUE(pm->GetSiteInstanceForURL(popup->url()));
106 EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id())); 105 EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id()));
107 EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get())); 106 EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get()));
108 } 107 }
109 108
110 // Content loaded from http://hlogonemlfkgpejgnedahbkiabcdhnnn should not 109 // Content loaded from http://hlogonemlfkgpejgnedahbkiabcdhnnn should not
111 // interact with an installed extension with that ID. Regression test 110 // interact with an installed extension with that ID. Regression test
112 // for bug 357382. 111 // for bug 357382.
113 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, HttpHostMatchingExtensionId) { 112 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, HttpHostMatchingExtensionId) {
114 ProcessManager* pm = ExtensionSystem::Get(profile())->process_manager(); 113 ProcessManager* pm = ProcessManager::Get(profile());
115 114
116 // We start with no background hosts. 115 // We start with no background hosts.
117 ASSERT_EQ(0u, pm->background_hosts().size()); 116 ASSERT_EQ(0u, pm->background_hosts().size());
118 ASSERT_EQ(0u, pm->GetAllViews().size()); 117 ASSERT_EQ(0u, pm->GetAllViews().size());
119 118
120 // Load an extension with a background page. 119 // Load an extension with a background page.
121 scoped_refptr<const Extension> extension = 120 scoped_refptr<const Extension> extension =
122 LoadExtension(test_data_dir_.AppendASCII("api_test") 121 LoadExtension(test_data_dir_.AppendASCII("api_test")
123 .AppendASCII("browser_action") 122 .AppendASCII("browser_action")
124 .AppendASCII("none")); 123 .AppendASCII("none"));
(...skipping 28 matching lines...) Expand all
153 content::WebContents::FromRenderViewHost( 152 content::WebContents::FromRenderViewHost(
154 *pm->GetRenderViewHostsForExtension(extension->id()).begin()); 153 *pm->GetRenderViewHostsForExtension(extension->id()).begin());
155 EXPECT_TRUE(extension_web_contents->GetSiteInstance() != 154 EXPECT_TRUE(extension_web_contents->GetSiteInstance() !=
156 tab_web_contents->GetSiteInstance()); 155 tab_web_contents->GetSiteInstance());
157 EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url()) != 156 EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url()) !=
158 tab_web_contents->GetSiteInstance()); 157 tab_web_contents->GetSiteInstance());
159 EXPECT_TRUE(pm->GetBackgroundHostForExtension(extension->id())); 158 EXPECT_TRUE(pm->GetBackgroundHostForExtension(extension->id()));
160 } 159 }
161 160
162 } // namespace extensions 161 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/process_management_browsertest.cc ('k') | chrome/browser/extensions/test_extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698