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 "chrome/browser/extensions/extension_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/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
13 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
14 | 14 |
15 using extensions::Extension; | 15 namespace extensions { |
16 using extensions::ExtensionSystem; | |
17 | 16 |
18 // Exists as a browser test because ExtensionHosts are hard to create without | 17 // Exists as a browser test because ExtensionHosts are hard to create without |
19 // a real browser. | 18 // a real browser. |
20 typedef ExtensionBrowserTest ExtensionProcessManagerBrowserTest; | 19 typedef ExtensionBrowserTest ProcessManagerBrowserTest; |
21 | 20 |
22 // Test that basic extension loading creates the appropriate ExtensionHosts | 21 // Test that basic extension loading creates the appropriate ExtensionHosts |
23 // and background pages. | 22 // and background pages. |
24 IN_PROC_BROWSER_TEST_F(ExtensionProcessManagerBrowserTest, | 23 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, |
25 ExtensionHostCreation) { | 24 ExtensionHostCreation) { |
26 ExtensionProcessManager* pm = | 25 ProcessManager* pm = ExtensionSystem::Get(profile())->process_manager(); |
27 ExtensionSystem::Get(profile())->process_manager(); | |
28 | 26 |
29 // We start with no background hosts. | 27 // We start with no background hosts. |
30 ASSERT_EQ(0u, pm->background_hosts().size()); | 28 ASSERT_EQ(0u, pm->background_hosts().size()); |
31 ASSERT_EQ(0u, pm->GetAllViews().size()); | 29 ASSERT_EQ(0u, pm->GetAllViews().size()); |
32 | 30 |
33 // Load an extension with a background page. | 31 // Load an extension with a background page. |
34 scoped_refptr<const Extension> extension = | 32 scoped_refptr<const Extension> extension = |
35 LoadExtension(test_data_dir_.AppendASCII("api_test") | 33 LoadExtension(test_data_dir_.AppendASCII("api_test") |
36 .AppendASCII("browser_action") | 34 .AppendASCII("browser_action") |
37 .AppendASCII("none")); | 35 .AppendASCII("none")); |
(...skipping 18 matching lines...) Expand all Loading... |
56 EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url())); | 54 EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url())); |
57 EXPECT_EQ(0u, pm->GetRenderViewHostsForExtension(extension->id()).size()); | 55 EXPECT_EQ(0u, pm->GetRenderViewHostsForExtension(extension->id()).size()); |
58 EXPECT_FALSE(pm->IsBackgroundHostClosing(extension->id())); | 56 EXPECT_FALSE(pm->IsBackgroundHostClosing(extension->id())); |
59 EXPECT_EQ(0, pm->GetLazyKeepaliveCount(extension.get())); | 57 EXPECT_EQ(0, pm->GetLazyKeepaliveCount(extension.get())); |
60 } | 58 } |
61 | 59 |
62 // Test that loading an extension with a browser action does not create a | 60 // Test that loading an extension with a browser action does not create a |
63 // background page and that clicking on the action creates the appropriate | 61 // background page and that clicking on the action creates the appropriate |
64 // ExtensionHost. | 62 // ExtensionHost. |
65 // Disabled due to flake, see http://crbug.com/315242 | 63 // Disabled due to flake, see http://crbug.com/315242 |
66 IN_PROC_BROWSER_TEST_F(ExtensionProcessManagerBrowserTest, | 64 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, |
67 DISABLED_PopupHostCreation) { | 65 DISABLED_PopupHostCreation) { |
68 ExtensionProcessManager* pm = | 66 ProcessManager* pm = ExtensionSystem::Get(profile())->process_manager(); |
69 ExtensionSystem::Get(profile())->process_manager(); | |
70 | 67 |
71 // Load an extension with the ability to open a popup but no background | 68 // Load an extension with the ability to open a popup but no background |
72 // page. | 69 // page. |
73 scoped_refptr<const Extension> popup = | 70 scoped_refptr<const Extension> popup = |
74 LoadExtension(test_data_dir_.AppendASCII("api_test") | 71 LoadExtension(test_data_dir_.AppendASCII("api_test") |
75 .AppendASCII("browser_action") | 72 .AppendASCII("browser_action") |
76 .AppendASCII("popup")); | 73 .AppendASCII("popup")); |
77 ASSERT_TRUE(popup); | 74 ASSERT_TRUE(popup); |
78 | 75 |
79 // No background host was added. | 76 // No background host was added. |
(...skipping 17 matching lines...) Expand all Loading... |
97 | 94 |
98 // We now have a view, but still no background hosts. | 95 // We now have a view, but still no background hosts. |
99 EXPECT_EQ(0u, pm->background_hosts().size()); | 96 EXPECT_EQ(0u, pm->background_hosts().size()); |
100 EXPECT_EQ(1u, pm->GetAllViews().size()); | 97 EXPECT_EQ(1u, pm->GetAllViews().size()); |
101 EXPECT_FALSE(pm->GetBackgroundHostForExtension(popup->id())); | 98 EXPECT_FALSE(pm->GetBackgroundHostForExtension(popup->id())); |
102 EXPECT_EQ(1u, pm->GetRenderViewHostsForExtension(popup->id()).size()); | 99 EXPECT_EQ(1u, pm->GetRenderViewHostsForExtension(popup->id()).size()); |
103 EXPECT_TRUE(pm->GetSiteInstanceForURL(popup->url())); | 100 EXPECT_TRUE(pm->GetSiteInstanceForURL(popup->url())); |
104 EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id())); | 101 EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id())); |
105 EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get())); | 102 EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get())); |
106 } | 103 } |
| 104 |
| 105 } // namespace extensions |
OLD | NEW |