OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions/crashed_extension_infobar.h" | 6 #include "chrome/browser/extensions/crashed_extension_infobar.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/extensions_service.h" | 10 #include "chrome/browser/extensions/extensions_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/renderer_host/render_process_host.h" | 12 #include "chrome/browser/renderer_host/render_process_host.h" |
13 #include "chrome/browser/renderer_host/render_view_host.h" | 13 #include "chrome/browser/renderer_host/render_view_host.h" |
14 #include "chrome/browser/tab_contents/infobar_delegate.h" | 14 #include "chrome/browser/tab_contents/infobar_delegate.h" |
15 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/result_codes.h" |
17 #include "chrome/test/ui_test_utils.h" | 18 #include "chrome/test/ui_test_utils.h" |
18 | 19 |
19 class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { | 20 class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { |
20 protected: | 21 protected: |
21 ExtensionsService* GetExtensionsService() { | 22 ExtensionsService* GetExtensionsService() { |
22 return browser()->profile()->GetExtensionsService(); | 23 return browser()->profile()->GetExtensionsService(); |
23 } | 24 } |
24 | 25 |
25 ExtensionProcessManager* GetExtensionProcessManager() { | 26 ExtensionProcessManager* GetExtensionProcessManager() { |
26 return browser()->profile()->GetExtensionProcessManager(); | 27 return browser()->profile()->GetExtensionProcessManager(); |
(...skipping 27 matching lines...) Expand all Loading... |
54 const Extension* extension = | 55 const Extension* extension = |
55 GetExtensionsService()->extensions()->at(index); | 56 GetExtensionsService()->extensions()->at(index); |
56 ASSERT_TRUE(extension); | 57 ASSERT_TRUE(extension); |
57 std::string extension_id(extension->id()); | 58 std::string extension_id(extension->id()); |
58 ExtensionHost* extension_host = | 59 ExtensionHost* extension_host = |
59 GetExtensionProcessManager()->GetBackgroundHostForExtension(extension); | 60 GetExtensionProcessManager()->GetBackgroundHostForExtension(extension); |
60 ASSERT_TRUE(extension_host); | 61 ASSERT_TRUE(extension_host); |
61 | 62 |
62 RenderProcessHost* extension_rph = | 63 RenderProcessHost* extension_rph = |
63 extension_host->render_view_host()->process(); | 64 extension_host->render_view_host()->process(); |
64 base::KillProcess(extension_rph->GetHandle(), | 65 base::KillProcess(extension_rph->GetHandle(), ResultCodes::KILLED, false); |
65 base::PROCESS_END_KILLED_BY_USER, false); | |
66 ASSERT_TRUE(WaitForExtensionCrash(extension_id)); | 66 ASSERT_TRUE(WaitForExtensionCrash(extension_id)); |
67 ASSERT_FALSE( | 67 ASSERT_FALSE( |
68 GetExtensionProcessManager()->GetBackgroundHostForExtension(extension)); | 68 GetExtensionProcessManager()->GetBackgroundHostForExtension(extension)); |
69 } | 69 } |
70 | 70 |
71 void CheckExtensionConsistency(size_t index) { | 71 void CheckExtensionConsistency(size_t index) { |
72 ASSERT_LT(index, GetExtensionsService()->extensions()->size()); | 72 ASSERT_LT(index, GetExtensionsService()->extensions()->size()); |
73 const Extension* extension = | 73 const Extension* extension = |
74 GetExtensionsService()->extensions()->at(index); | 74 GetExtensionsService()->extensions()->at(index); |
75 ASSERT_TRUE(extension); | 75 ASSERT_TRUE(extension); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 CheckExtensionConsistency(size_before); | 287 CheckExtensionConsistency(size_before); |
288 } | 288 } |
289 | 289 |
290 { | 290 { |
291 SCOPED_TRACE("second: infobar"); | 291 SCOPED_TRACE("second: infobar"); |
292 AcceptCrashedExtensionInfobar(0); | 292 AcceptCrashedExtensionInfobar(0); |
293 CheckExtensionConsistency(size_before); | 293 CheckExtensionConsistency(size_before); |
294 CheckExtensionConsistency(size_before + 1); | 294 CheckExtensionConsistency(size_before + 1); |
295 } | 295 } |
296 } | 296 } |
OLD | NEW |