OLD | NEW |
1 // Copyright (c) 2011 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 "base/process_util.h" | 5 #include "base/process_util.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/extensions/extension_browsertest.h" | 7 #include "chrome/browser/extensions/extension_browsertest.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/extensions/extension_process_manager.h" | 9 #include "chrome/browser/extensions/extension_process_manager.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/notifications/balloon_host.h" | 11 #include "chrome/browser/notifications/balloon_host.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 void CrashExtension(std::string extension_id) { | 69 void CrashExtension(std::string extension_id) { |
70 const Extension* extension = | 70 const Extension* extension = |
71 GetExtensionService()->extensions()->GetByID(extension_id); | 71 GetExtensionService()->extensions()->GetByID(extension_id); |
72 ASSERT_TRUE(extension); | 72 ASSERT_TRUE(extension); |
73 ExtensionHost* extension_host = GetExtensionProcessManager()-> | 73 ExtensionHost* extension_host = GetExtensionProcessManager()-> |
74 GetBackgroundHostForExtension(extension_id); | 74 GetBackgroundHostForExtension(extension_id); |
75 ASSERT_TRUE(extension_host); | 75 ASSERT_TRUE(extension_host); |
76 | 76 |
77 content::RenderProcessHost* extension_rph = | 77 content::RenderProcessHost* extension_rph = |
78 extension_host->render_view_host()->process(); | 78 extension_host->render_view_host()->GetProcess(); |
79 base::KillProcess(extension_rph->GetHandle(), content::RESULT_CODE_KILLED, | 79 base::KillProcess(extension_rph->GetHandle(), content::RESULT_CODE_KILLED, |
80 false); | 80 false); |
81 ASSERT_TRUE(WaitForExtensionCrash(extension_id)); | 81 ASSERT_TRUE(WaitForExtensionCrash(extension_id)); |
82 ASSERT_FALSE(GetExtensionProcessManager()-> | 82 ASSERT_FALSE(GetExtensionProcessManager()-> |
83 GetBackgroundHostForExtension(extension_id)); | 83 GetBackgroundHostForExtension(extension_id)); |
84 } | 84 } |
85 | 85 |
86 void CheckExtensionConsistency(std::string extension_id) { | 86 void CheckExtensionConsistency(std::string extension_id) { |
87 const Extension* extension = | 87 const Extension* extension = |
88 GetExtensionService()->extensions()->GetByID(extension_id); | 88 GetExtensionService()->extensions()->GetByID(extension_id); |
89 ASSERT_TRUE(extension); | 89 ASSERT_TRUE(extension); |
90 ExtensionHost* extension_host = GetExtensionProcessManager()-> | 90 ExtensionHost* extension_host = GetExtensionProcessManager()-> |
91 GetBackgroundHostForExtension(extension_id); | 91 GetBackgroundHostForExtension(extension_id); |
92 ASSERT_TRUE(extension_host); | 92 ASSERT_TRUE(extension_host); |
93 ASSERT_TRUE(GetExtensionProcessManager()->HasExtensionHost(extension_host)); | 93 ASSERT_TRUE(GetExtensionProcessManager()->HasExtensionHost(extension_host)); |
94 ASSERT_TRUE(extension_host->IsRenderViewLive()); | 94 ASSERT_TRUE(extension_host->IsRenderViewLive()); |
95 extensions::ProcessMap* process_map = | 95 extensions::ProcessMap* process_map = |
96 browser()->profile()->GetExtensionService()->process_map(); | 96 browser()->profile()->GetExtensionService()->process_map(); |
97 ASSERT_TRUE(process_map->Contains( | 97 ASSERT_TRUE(process_map->Contains( |
98 extension_id, extension_host->render_view_host()->process()->GetID())); | 98 extension_id, |
| 99 extension_host->render_view_host()->GetProcess()->GetID())); |
99 } | 100 } |
100 | 101 |
101 void LoadTestExtension() { | 102 void LoadTestExtension() { |
102 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); | 103 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); |
103 const Extension* extension = LoadExtension( | 104 const Extension* extension = LoadExtension( |
104 test_data_dir_.AppendASCII("common").AppendASCII("background_page")); | 105 test_data_dir_.AppendASCII("common").AppendASCII("background_page")); |
105 ASSERT_TRUE(extension); | 106 ASSERT_TRUE(extension); |
106 first_extension_id_ = extension->id(); | 107 first_extension_id_ = extension->id(); |
107 CheckExtensionConsistency(first_extension_id_); | 108 CheckExtensionConsistency(first_extension_id_); |
108 } | 109 } |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 GetController())); | 481 GetController())); |
481 browser()->Reload(CURRENT_TAB); | 482 browser()->Reload(CURRENT_TAB); |
482 observer.Wait(); | 483 observer.Wait(); |
483 } | 484 } |
484 // Extension should now be loaded. | 485 // Extension should now be loaded. |
485 SCOPED_TRACE("after reloading the tab"); | 486 SCOPED_TRACE("after reloading the tab"); |
486 CheckExtensionConsistency(first_extension_id_); | 487 CheckExtensionConsistency(first_extension_id_); |
487 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); | 488 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
488 ASSERT_EQ(0U, CountBalloons()); | 489 ASSERT_EQ(0U, CountBalloons()); |
489 } | 490 } |
OLD | NEW |