OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
12 #include "chrome/browser/notifications/notification.h" | 12 #include "chrome/browser/notifications/notification.h" |
13 #include "chrome/browser/notifications/notification_delegate.h" | 13 #include "chrome/browser/notifications/notification_delegate.h" |
14 #include "chrome/browser/notifications/notification_ui_manager.h" | 14 #include "chrome/browser/notifications/notification_ui_manager.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/tabs/tab_strip_model.h" | 16 #include "chrome/browser/tabs/tab_strip_model.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/browser/renderer_host/render_process_host.h" | 20 #include "content/browser/renderer_host/render_process_host.h" |
20 #include "content/browser/renderer_host/render_view_host.h" | 21 #include "content/browser/renderer_host/render_view_host.h" |
21 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
22 #include "content/public/common/result_codes.h" | 23 #include "content/public/common/result_codes.h" |
23 | 24 |
24 class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { | 25 class ExtensionCrashRecoveryTest : public ExtensionBrowserTest { |
25 protected: | 26 protected: |
26 ExtensionService* GetExtensionService() { | 27 ExtensionService* GetExtensionService() { |
27 return browser()->profile()->GetExtensionService(); | 28 return browser()->profile()->GetExtensionService(); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 LoadSecondExtension(); | 447 LoadSecondExtension(); |
447 CrashExtension(size_before); | 448 CrashExtension(size_before); |
448 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); | 449 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
449 ASSERT_EQ(crash_size_before + 1, | 450 ASSERT_EQ(crash_size_before + 1, |
450 GetExtensionService()->terminated_extensions()->size()); | 451 GetExtensionService()->terminated_extensions()->size()); |
451 | 452 |
452 GetExtensionService()->UnloadAllExtensions(); | 453 GetExtensionService()->UnloadAllExtensions(); |
453 ASSERT_EQ(crash_size_before, | 454 ASSERT_EQ(crash_size_before, |
454 GetExtensionService()->terminated_extensions()->size()); | 455 GetExtensionService()->terminated_extensions()->size()); |
455 } | 456 } |
| 457 |
| 458 // Test that when an extension with a background page that has a tab open |
| 459 // crashes, the tab stays open, and reloading it reloads the extension. |
| 460 // Regression test for issue 71629. |
| 461 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, |
| 462 ReloadTabsWithBackgroundPage) { |
| 463 TabStripModel* tab_strip = browser()->tabstrip_model(); |
| 464 const size_t size_before = GetExtensionService()->extensions()->size(); |
| 465 const size_t crash_size_before = |
| 466 GetExtensionService()->terminated_extensions()->size(); |
| 467 LoadTestExtension(); |
| 468 |
| 469 // Open a tab extension. |
| 470 browser()->NewTab(); |
| 471 ui_test_utils::NavigateToURL( |
| 472 browser(), |
| 473 GURL("chrome-extension://" + first_extension_id_ + "/background.html")); |
| 474 |
| 475 const int tabs_before = tab_strip->count(); |
| 476 CrashExtension(size_before); |
| 477 |
| 478 // Tab should still be open, and extension should be crashed. |
| 479 EXPECT_EQ(tabs_before, tab_strip->count()); |
| 480 EXPECT_EQ(size_before, GetExtensionService()->extensions()->size()); |
| 481 EXPECT_EQ(crash_size_before + 1, |
| 482 GetExtensionService()->terminated_extensions()->size()); |
| 483 |
| 484 { |
| 485 ui_test_utils::WindowedNotificationObserver observer( |
| 486 content::NOTIFICATION_LOAD_STOP, |
| 487 content::Source<NavigationController>( |
| 488 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 489 browser()->Reload(CURRENT_TAB); |
| 490 observer.Wait(); |
| 491 } |
| 492 // Extension should now be loaded. |
| 493 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
| 494 ASSERT_EQ(0U, CountBalloons()); |
| 495 } |
OLD | NEW |