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 { | |
472 ui_test_utils::WindowedNotificationObserver observer( | |
473 content::NOTIFICATION_LOAD_STOP, | |
Matt Perry
2011/11/10 22:07:59
This should be unnecessary. NavigateToURL already
Yoyo Zhou
2011/11/10 23:26:30
Removed.
| |
474 content::Source<NavigationController>( | |
475 &browser()->GetSelectedTabContentsWrapper()->controller())); | |
476 ui_test_utils::NavigateToURL( | |
477 browser(), | |
478 GURL("chrome-extension://" + first_extension_id_ + "/background.html")); | |
479 observer.Wait(); | |
480 } | |
481 | |
482 const int tabs_before = tab_strip->count(); | |
483 CrashExtension(size_before); | |
484 | |
485 // Tab should still be open, and extension should be crashed. | |
486 EXPECT_EQ(tabs_before, tab_strip->count()); | |
487 EXPECT_EQ(size_before, GetExtensionService()->extensions()->size()); | |
488 EXPECT_EQ(crash_size_before + 1, | |
489 GetExtensionService()->terminated_extensions()->size()); | |
490 | |
491 { | |
492 ui_test_utils::WindowedNotificationObserver observer( | |
493 content::NOTIFICATION_LOAD_STOP, | |
494 content::Source<NavigationController>( | |
495 &browser()->GetSelectedTabContentsWrapper()->controller())); | |
496 browser()->Reload(CURRENT_TAB); | |
497 observer.Wait(); | |
498 } | |
499 // Extension should now be loaded. | |
500 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); | |
501 ASSERT_EQ(0U, CountBalloons()); | |
502 } | |
OLD | NEW |