[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 5 | #include "chrome/browser/browser_process.h" |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 6 | #include "chrome/browser/extensions/extension_browsertest.h" |
| 7 | #include "chrome/browser/extensions/extension_host.h" |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 8 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | be93bba0 | 2012-10-24 16:44:03 | [diff] [blame] | 9 | #include "chrome/browser/extensions/extension_system.h" |
[email protected] | 1272b1e6 | 2012-04-04 14:42:45 | [diff] [blame] | 10 | #include "chrome/browser/notifications/balloon.h" |
| 11 | #include "chrome/browser/notifications/balloon_collection.h" |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 12 | #include "chrome/browser/notifications/balloon_host.h" |
[email protected] | a93e63f5 | 2012-12-18 04:26:40 | [diff] [blame] | 13 | #include "chrome/browser/notifications/balloon_notification_ui_manager.h" |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 14 | #include "chrome/browser/notifications/notification.h" |
| 15 | #include "chrome/browser/notifications/notification_delegate.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 16 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 7b5dc00 | 2010-11-16 23:08:10 | [diff] [blame] | 17 | #include "chrome/browser/ui/browser.h" |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 18 | #include "chrome/browser/ui/browser_commands.h" |
[email protected] | b56e2e3 | 2012-05-11 21:18:04 | [diff] [blame] | 19 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 20 | #include "chrome/test/base/ui_test_utils.h" |
[email protected] | cdcb1dee | 2012-01-04 00:46:20 | [diff] [blame] | 21 | #include "content/public/browser/navigation_controller.h" |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 22 | #include "content/public/browser/render_process_host.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 23 | #include "content/public/browser/render_view_host.h" |
[email protected] | 4ca1530 | 2012-01-03 05:53:20 | [diff] [blame] | 24 | #include "content/public/browser/web_contents.h" |
[email protected] | b39ef1cb | 2011-10-25 04:46:55 | [diff] [blame] | 25 | #include "content/public/common/result_codes.h" |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 26 | #include "extensions/browser/process_manager.h" |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 27 | #include "ui/message_center/message_center.h" |
[email protected] | aa611d4 | 2013-03-24 00:32:51 | [diff] [blame] | 28 | #include "ui/message_center/message_center_switches.h" |
[email protected] | fb1aac14e | 2013-05-14 05:30:24 | [diff] [blame] | 29 | #include "ui/message_center/message_center_util.h" |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 30 | #include "ui/message_center/notification_list.h" |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 31 | |
[email protected] | c5eed49 | 2012-01-04 17:07:50 | [diff] [blame] | 32 | using content::NavigationController; |
[email protected] | 4ca1530 | 2012-01-03 05:53:20 | [diff] [blame] | 33 | using content::WebContents; |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 34 | using extensions::Extension; |
[email protected] | 4ca1530 | 2012-01-03 05:53:20 | [diff] [blame] | 35 | |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 36 | // Tests are timing out waiting for extension to crash. |
| 37 | // http://crbug.com/174705 |
[email protected] | b144168 | 2013-05-17 23:35:24 | [diff] [blame] | 38 | #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_LINUX) |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 39 | #define MAYBE_ExtensionCrashRecoveryTest DISABLED_ExtensionCrashRecoveryTest |
| 40 | #else |
| 41 | #define MAYBE_ExtensionCrashRecoveryTest ExtensionCrashRecoveryTest |
[email protected] | b144168 | 2013-05-17 23:35:24 | [diff] [blame] | 42 | #endif // defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_LINUX) |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 43 | |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 44 | class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest { |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 45 | protected: |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 46 | virtual void AcceptNotification(size_t index) = 0; |
| 47 | virtual void CancelNotification(size_t index) = 0; |
| 48 | virtual size_t CountBalloons() = 0; |
| 49 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 50 | ExtensionService* GetExtensionService() { |
| 51 | return browser()->profile()->GetExtensionService(); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 52 | } |
| 53 | |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 54 | extensions::ProcessManager* GetProcessManager() { |
[email protected] | be93bba0 | 2012-10-24 16:44:03 | [diff] [blame] | 55 | return extensions::ExtensionSystem::Get(browser()->profile())-> |
| 56 | process_manager(); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 57 | } |
| 58 | |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 59 | void CrashExtension(std::string extension_id) { |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 60 | const Extension* extension = |
[email protected] | 330840c | 2012-08-29 22:21:01 | [diff] [blame] | 61 | GetExtensionService()->GetExtensionById(extension_id, false); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 62 | ASSERT_TRUE(extension); |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 63 | extensions::ExtensionHost* extension_host = GetProcessManager()-> |
[email protected] | 06024c6 | 2011-10-20 20:57:12 | [diff] [blame] | 64 | GetBackgroundHostForExtension(extension_id); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 65 | ASSERT_TRUE(extension_host); |
| 66 | |
[email protected] | 330840c | 2012-08-29 22:21:01 | [diff] [blame] | 67 | base::KillProcess(extension_host->render_process_host()->GetHandle(), |
| 68 | content::RESULT_CODE_KILLED, false); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 69 | ASSERT_TRUE(WaitForExtensionCrash(extension_id)); |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 70 | ASSERT_FALSE(GetProcessManager()-> |
[email protected] | 06024c6 | 2011-10-20 20:57:12 | [diff] [blame] | 71 | GetBackgroundHostForExtension(extension_id)); |
[email protected] | 260122c | 2013-05-22 15:05:55 | [diff] [blame] | 72 | |
| 73 | // Wait for extension crash balloon to appear. |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 74 | base::MessageLoop::current()->RunUntilIdle(); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 75 | } |
| 76 | |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 77 | void CheckExtensionConsistency(std::string extension_id) { |
[email protected] | 9adb969 | 2010-10-29 23:14:02 | [diff] [blame] | 78 | const Extension* extension = |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 79 | GetExtensionService()->extensions()->GetByID(extension_id); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 80 | ASSERT_TRUE(extension); |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 81 | extensions::ExtensionHost* extension_host = GetProcessManager()-> |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 82 | GetBackgroundHostForExtension(extension_id); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 83 | ASSERT_TRUE(extension_host); |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 84 | extensions::ProcessManager::ViewSet all_views = |
| 85 | GetProcessManager()->GetAllViews(); |
| 86 | extensions::ProcessManager::ViewSet::const_iterator it = |
[email protected] | d1fe135 | 2012-04-26 00:47:32 | [diff] [blame] | 87 | all_views.find(extension_host->host_contents()->GetRenderViewHost()); |
| 88 | ASSERT_FALSE(it == all_views.end()); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 89 | ASSERT_TRUE(extension_host->IsRenderViewLive()); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 90 | extensions::ProcessMap* process_map = |
| 91 | browser()->profile()->GetExtensionService()->process_map(); |
| 92 | ASSERT_TRUE(process_map->Contains( |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 93 | extension_id, |
| 94 | extension_host->render_view_host()->GetProcess()->GetID())); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | void LoadTestExtension() { |
| 98 | ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 99 | const Extension* extension = LoadExtension( |
| 100 | test_data_dir_.AppendASCII("common").AppendASCII("background_page")); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 101 | ASSERT_TRUE(extension); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 102 | first_extension_id_ = extension->id(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 103 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 104 | } |
| 105 | |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 106 | void LoadSecondExtension() { |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 107 | const Extension* extension = LoadExtension( |
| 108 | test_data_dir_.AppendASCII("install").AppendASCII("install")); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 109 | ASSERT_TRUE(extension); |
| 110 | second_extension_id_ = extension->id(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 111 | CheckExtensionConsistency(second_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | std::string first_extension_id_; |
| 115 | std::string second_extension_id_; |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 116 | }; |
| 117 | |
[email protected] | fb1aac14e | 2013-05-14 05:30:24 | [diff] [blame] | 118 | class MAYBE_ExtensionCrashRecoveryTest |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 119 | : public ExtensionCrashRecoveryTestBase { |
| 120 | protected: |
[email protected] | aa3174b | 2013-03-15 09:12:48 | [diff] [blame] | 121 | virtual void AcceptNotification(size_t index) OVERRIDE { |
[email protected] | fb1aac14e | 2013-05-14 05:30:24 | [diff] [blame] | 122 | if (message_center::IsRichNotificationEnabled()) { |
| 123 | message_center::MessageCenter* message_center = |
| 124 | message_center::MessageCenter::Get(); |
| 125 | ASSERT_GT(message_center->NotificationCount(), index); |
| 126 | message_center::NotificationList::Notifications::reverse_iterator it = |
[email protected] | ae37e7a | 2013-09-24 06:59:36 | [diff] [blame] | 127 | message_center->GetVisibleNotifications().rbegin(); |
[email protected] | fb1aac14e | 2013-05-14 05:30:24 | [diff] [blame] | 128 | for (size_t i=0; i < index; ++i) |
| 129 | it++; |
| 130 | std::string id = (*it)->id(); |
| 131 | message_center->ClickOnNotification(id); |
| 132 | } else { |
| 133 | Balloon* balloon = GetNotificationDelegate(index); |
| 134 | ASSERT_TRUE(balloon); |
| 135 | balloon->OnClick(); |
| 136 | } |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 137 | WaitForExtensionLoad(); |
| 138 | } |
| 139 | |
[email protected] | aa3174b | 2013-03-15 09:12:48 | [diff] [blame] | 140 | virtual void CancelNotification(size_t index) OVERRIDE { |
[email protected] | fb1aac14e | 2013-05-14 05:30:24 | [diff] [blame] | 141 | if (message_center::IsRichNotificationEnabled()) { |
| 142 | message_center::MessageCenter* message_center = |
| 143 | message_center::MessageCenter::Get(); |
| 144 | ASSERT_GT(message_center->NotificationCount(), index); |
| 145 | message_center::NotificationList::Notifications::reverse_iterator it = |
[email protected] | ae37e7a | 2013-09-24 06:59:36 | [diff] [blame] | 146 | message_center->GetVisibleNotifications().rbegin(); |
[email protected] | fb1aac14e | 2013-05-14 05:30:24 | [diff] [blame] | 147 | for (size_t i=0; i < index; i++) { it++; } |
| 148 | ASSERT_TRUE(g_browser_process->notification_ui_manager()-> |
| 149 | CancelById((*it)->id())); |
| 150 | } else { |
| 151 | Balloon* balloon = GetNotificationDelegate(index); |
| 152 | ASSERT_TRUE(balloon); |
| 153 | std::string id = balloon->notification().notification_id(); |
| 154 | ASSERT_TRUE(g_browser_process->notification_ui_manager()->CancelById(id)); |
| 155 | } |
[email protected] | 6cd63ea | 2013-03-07 18:17:04 | [diff] [blame] | 156 | } |
| 157 | |
[email protected] | aa3174b | 2013-03-15 09:12:48 | [diff] [blame] | 158 | virtual size_t CountBalloons() OVERRIDE { |
[email protected] | fb1aac14e | 2013-05-14 05:30:24 | [diff] [blame] | 159 | if (message_center::IsRichNotificationEnabled()) |
| 160 | return message_center::MessageCenter::Get()->NotificationCount(); |
| 161 | |
| 162 | return BalloonNotificationUIManager::GetInstanceForTesting()-> |
| 163 | balloon_collection()->GetActiveBalloons().size(); |
[email protected] | 9a22457 | 2013-05-12 23:08:56 | [diff] [blame] | 164 | } |
[email protected] | fb1aac14e | 2013-05-14 05:30:24 | [diff] [blame] | 165 | |
| 166 | private: |
| 167 | Balloon* GetNotificationDelegate(size_t index) { |
| 168 | BalloonNotificationUIManager* manager = |
| 169 | BalloonNotificationUIManager::GetInstanceForTesting(); |
| 170 | BalloonCollection::Balloons balloons = |
| 171 | manager->balloon_collection()->GetActiveBalloons(); |
| 172 | return index < balloons.size() ? balloons.at(index) : NULL; |
| 173 | } |
[email protected] | 9a22457 | 2013-05-12 23:08:56 | [diff] [blame] | 174 | }; |
[email protected] | bce52eaa | 2013-05-11 19:23:21 | [diff] [blame] | 175 | |
[email protected] | c890fd4 | 2013-05-20 11:46:44 | [diff] [blame] | 176 | // Flaky: http://crbug.com/242167. |
| 177 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, DISABLED_Basic) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 178 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 179 | const size_t crash_size_before = |
| 180 | GetExtensionService()->terminated_extensions()->size(); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 181 | LoadTestExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 182 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 183 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 184 | ASSERT_EQ(crash_size_before + 1, |
| 185 | GetExtensionService()->terminated_extensions()->size()); |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 186 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 187 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 188 | SCOPED_TRACE("after clicking the balloon"); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 189 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 190 | ASSERT_EQ(crash_size_before, |
| 191 | GetExtensionService()->terminated_extensions()->size()); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 192 | } |
| 193 | |
[email protected] | 6b75d79b0f9 | 2013-05-16 17:37:05 | [diff] [blame] | 194 | // Flaky, http://crbug.com/241191. |
| 195 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
| 196 | DISABLED_CloseAndReload) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 197 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 198 | const size_t crash_size_before = |
| 199 | GetExtensionService()->terminated_extensions()->size(); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 200 | LoadTestExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 201 | CrashExtension(first_extension_id_); |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 202 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 203 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 204 | ASSERT_EQ(crash_size_before + 1, |
| 205 | GetExtensionService()->terminated_extensions()->size()); |
| 206 | |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 207 | ASSERT_NO_FATAL_FAILURE(CancelNotification(0)); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 208 | ReloadExtension(first_extension_id_); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 209 | |
| 210 | SCOPED_TRACE("after reloading"); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 211 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 212 | ASSERT_EQ(crash_size_before, |
| 213 | GetExtensionService()->terminated_extensions()->size()); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 214 | } |
| 215 | |
[email protected] | 4d90d43 | 2013-06-13 01:27:59 | [diff] [blame] | 216 | // Test is timing out on Windows http://crbug.com/174705. |
| 217 | #if defined(OS_WIN) |
| 218 | #define MAYBE_ReloadIndependently DISABLED_ReloadIndependently |
| 219 | #else |
| 220 | #define MAYBE_ReloadIndependently ReloadIndependently |
| 221 | #endif // defined(OS_WIN) |
| 222 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
| 223 | MAYBE_ReloadIndependently) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 224 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 225 | LoadTestExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 226 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 227 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 228 | |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 229 | ReloadExtension(first_extension_id_); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 230 | |
| 231 | SCOPED_TRACE("after reloading"); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 232 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 233 | |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 234 | WebContents* current_tab = |
| 235 | browser()->tab_strip_model()->GetActiveWebContents(); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 236 | ASSERT_TRUE(current_tab); |
| 237 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 238 | // The balloon should automatically hide after the extension is successfully |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 239 | // reloaded. |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 240 | ASSERT_EQ(0U, CountBalloons()); |
[email protected] | 1eb17508 | 2010-02-10 09:26:16 | [diff] [blame] | 241 | } |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 242 | |
[email protected] | 8c85ea8 | 2013-05-23 09:36:42 | [diff] [blame] | 243 | // Test is timing out on Windows http://crbug.com/174705. |
| 244 | #if defined(OS_WIN) |
| 245 | #define MAYBE_ReloadIndependentlyChangeTabs DISABLED_ReloadIndependentlyChangeTabs |
| 246 | #else |
| 247 | #define MAYBE_ReloadIndependentlyChangeTabs ReloadIndependentlyChangeTabs |
| 248 | #endif // defined(OS_WIN) |
| 249 | |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 250 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | 8c85ea8 | 2013-05-23 09:36:42 | [diff] [blame] | 251 | MAYBE_ReloadIndependentlyChangeTabs) { |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 252 | const size_t size_before = GetExtensionService()->extensions()->size(); |
| 253 | LoadTestExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 254 | CrashExtension(first_extension_id_); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 255 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
| 256 | |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 257 | WebContents* original_tab = |
| 258 | browser()->tab_strip_model()->GetActiveWebContents(); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 259 | ASSERT_TRUE(original_tab); |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 260 | ASSERT_EQ(1U, CountBalloons()); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 261 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 262 | // Open a new tab, but the balloon will still be there. |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 263 | chrome::NewTab(browser()); |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 264 | WebContents* new_current_tab = |
| 265 | browser()->tab_strip_model()->GetActiveWebContents(); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 266 | ASSERT_TRUE(new_current_tab); |
| 267 | ASSERT_NE(new_current_tab, original_tab); |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 268 | ASSERT_EQ(1U, CountBalloons()); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 269 | |
| 270 | ReloadExtension(first_extension_id_); |
| 271 | |
| 272 | SCOPED_TRACE("after reloading"); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 273 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 274 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 275 | // The balloon should automatically hide after the extension is successfully |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 276 | // reloaded. |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 277 | ASSERT_EQ(0U, CountBalloons()); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 278 | } |
| 279 | |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 280 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | 4cf6acf | 2013-02-27 02:03:16 | [diff] [blame] | 281 | DISABLED_ReloadIndependentlyNavigatePage) { |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 282 | const size_t size_before = GetExtensionService()->extensions()->size(); |
| 283 | LoadTestExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 284 | CrashExtension(first_extension_id_); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 285 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
| 286 | |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 287 | WebContents* current_tab = |
| 288 | browser()->tab_strip_model()->GetActiveWebContents(); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 289 | ASSERT_TRUE(current_tab); |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 290 | ASSERT_EQ(1U, CountBalloons()); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 291 | |
| 292 | // Navigate to another page. |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 293 | ui_test_utils::NavigateToURL( |
| 294 | browser(), ui_test_utils::GetTestUrl( |
| 295 | base::FilePath(base::FilePath::kCurrentDirectory), |
| 296 | base::FilePath(FILE_PATH_LITERAL("title1.html")))); |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 297 | ASSERT_EQ(1U, CountBalloons()); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 298 | |
| 299 | ReloadExtension(first_extension_id_); |
| 300 | |
| 301 | SCOPED_TRACE("after reloading"); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 302 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 303 | |
[email protected] | 1a6273b7 | 2011-04-23 00:50:55 | [diff] [blame] | 304 | // The balloon should automatically hide after the extension is successfully |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 305 | // reloaded. |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 306 | ASSERT_EQ(0U, CountBalloons()); |
[email protected] | ed56a7a0 | 2010-12-22 21:15:13 | [diff] [blame] | 307 | } |
| 308 | |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 309 | // Make sure that when we don't do anything about the crashed extension |
| 310 | // and close the browser, it doesn't crash. The browser is closed implicitly |
| 311 | // at the end of each browser test. |
[email protected] | 03c7f66c | 2011-06-29 15:41:48 | [diff] [blame] | 312 | // |
| 313 | // http://crbug.com/84719 |
[email protected] | 4ccc8cc | 2011-06-07 21:25:30 | [diff] [blame] | 314 | #if defined(OS_LINUX) |
[email protected] | 5884f160 | 2011-06-29 16:30:57 | [diff] [blame] | 315 | #define MAYBE_ShutdownWhileCrashed DISABLED_ShutdownWhileCrashed |
[email protected] | 4ccc8cc | 2011-06-07 21:25:30 | [diff] [blame] | 316 | #else |
[email protected] | fa69a9a9 | 2011-06-29 16:02:59 | [diff] [blame] | 317 | #define MAYBE_ShutdownWhileCrashed ShutdownWhileCrashed |
[email protected] | 03c7f66c | 2011-06-29 15:41:48 | [diff] [blame] | 318 | #endif // defined(OS_LINUX) |
| 319 | |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 320 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
| 321 | MAYBE_ShutdownWhileCrashed) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 322 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 323 | LoadTestExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 324 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 325 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 326 | } |
| 327 | |
[email protected] | 48566985 | 2013-05-16 11:05:47 | [diff] [blame] | 328 | // Flaky, http://crbug.com/241245. |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 329 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | 48566985 | 2013-05-16 11:05:47 | [diff] [blame] | 330 | DISABLED_TwoExtensionsCrashFirst) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 331 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 332 | LoadTestExtension(); |
| 333 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 334 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 335 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 336 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 337 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 338 | SCOPED_TRACE("after clicking the balloon"); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 339 | CheckExtensionConsistency(first_extension_id_); |
| 340 | CheckExtensionConsistency(second_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 341 | } |
| 342 | |
[email protected] | 55f90489 | 2013-05-20 15:19:01 | [diff] [blame] | 343 | // Flaky: http://crbug.com/242196 |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 344 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | 55f90489 | 2013-05-20 15:19:01 | [diff] [blame] | 345 | DISABLED_TwoExtensionsCrashSecond) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 346 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 347 | LoadTestExtension(); |
| 348 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 349 | CrashExtension(second_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 350 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 351 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 352 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 353 | SCOPED_TRACE("after clicking the balloon"); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 354 | CheckExtensionConsistency(first_extension_id_); |
| 355 | CheckExtensionConsistency(second_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 356 | } |
| 357 | |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 358 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 359 | TwoExtensionsCrashBothAtOnce) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 360 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 361 | const size_t crash_size_before = |
| 362 | GetExtensionService()->terminated_extensions()->size(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 363 | LoadTestExtension(); |
| 364 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 365 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 366 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 367 | ASSERT_EQ(crash_size_before + 1, |
| 368 | GetExtensionService()->terminated_extensions()->size()); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 369 | CrashExtension(second_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 370 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 371 | ASSERT_EQ(crash_size_before + 2, |
| 372 | GetExtensionService()->terminated_extensions()->size()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 373 | |
| 374 | { |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 375 | SCOPED_TRACE("first balloon"); |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 376 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 377 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | { |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 381 | SCOPED_TRACE("second balloon"); |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 382 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 383 | CheckExtensionConsistency(first_extension_id_); |
| 384 | CheckExtensionConsistency(second_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 388 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
| 389 | TwoExtensionsOneByOne) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 390 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 391 | LoadTestExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 392 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 393 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 394 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 395 | CrashExtension(second_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 396 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 397 | |
| 398 | { |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 399 | SCOPED_TRACE("first balloon"); |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 400 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 401 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | { |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 405 | SCOPED_TRACE("second balloon"); |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 406 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 407 | CheckExtensionConsistency(first_extension_id_); |
| 408 | CheckExtensionConsistency(second_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 409 | } |
| 410 | } |
| 411 | |
[email protected] | 4ccc8cc | 2011-06-07 21:25:30 | [diff] [blame] | 412 | // http://crbug.com/84719 |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 413 | #if defined(OS_LINUX) |
[email protected] | 4ccc8cc | 2011-06-07 21:25:30 | [diff] [blame] | 414 | #define MAYBE_TwoExtensionsShutdownWhileCrashed \ |
| 415 | DISABLED_TwoExtensionsShutdownWhileCrashed |
| 416 | #else |
| 417 | #define MAYBE_TwoExtensionsShutdownWhileCrashed \ |
| 418 | TwoExtensionsShutdownWhileCrashed |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 419 | #endif // defined(OS_LINUX) |
[email protected] | 4ccc8cc | 2011-06-07 21:25:30 | [diff] [blame] | 420 | |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 421 | // Make sure that when we don't do anything about the crashed extensions |
| 422 | // and close the browser, it doesn't crash. The browser is closed implicitly |
| 423 | // at the end of each browser test. |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 424 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | 4ccc8cc | 2011-06-07 21:25:30 | [diff] [blame] | 425 | MAYBE_TwoExtensionsShutdownWhileCrashed) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 426 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 427 | LoadTestExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 428 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 429 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 430 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 431 | CrashExtension(second_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 432 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 433 | } |
| 434 | |
[email protected] | bd09941 | 2013-05-17 04:20:16 | [diff] [blame] | 435 | // Flaky, http://crbug.com/241573. |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 436 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | bd09941 | 2013-05-17 04:20:16 | [diff] [blame] | 437 | DISABLED_TwoExtensionsIgnoreFirst) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 438 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 439 | LoadTestExtension(); |
| 440 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 441 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 442 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 443 | CrashExtension(second_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 444 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 445 | |
[email protected] | ede5e61a | 2011-12-03 01:05:31 | [diff] [blame] | 446 | // Accept notification 1 before canceling notification 0. |
| 447 | // Otherwise, on Linux and Windows, there is a race here, in which |
| 448 | // canceled notifications do not immediately go away. |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 449 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(1)); |
| 450 | ASSERT_NO_FATAL_FAILURE(CancelNotification(0)); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 451 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 452 | SCOPED_TRACE("balloons done"); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 453 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 454 | CheckExtensionConsistency(second_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 455 | } |
| 456 | |
[email protected] | f7d966a | 2013-05-16 00:03:43 | [diff] [blame] | 457 | // Flaky, http://crbug.com/241164. |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 458 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | f7d966a | 2013-05-16 00:03:43 | [diff] [blame] | 459 | DISABLED_TwoExtensionsReloadIndependently) { |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 460 | const size_t size_before = GetExtensionService()->extensions()->size(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 461 | LoadTestExtension(); |
| 462 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 463 | CrashExtension(first_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 464 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 465 | CrashExtension(second_extension_id_); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 466 | ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 467 | |
| 468 | { |
| 469 | SCOPED_TRACE("first: reload"); |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 470 | WebContents* current_tab = |
| 471 | browser()->tab_strip_model()->GetActiveWebContents(); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 472 | ASSERT_TRUE(current_tab); |
[email protected] | 1a6273b7 | 2011-04-23 00:50:55 | [diff] [blame] | 473 | // At the beginning we should have one balloon displayed for each extension. |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 474 | ASSERT_EQ(2U, CountBalloons()); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 475 | ReloadExtension(first_extension_id_); |
[email protected] | 1a6273b7 | 2011-04-23 00:50:55 | [diff] [blame] | 476 | // One of the balloons should hide after the extension is reloaded. |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 477 | ASSERT_EQ(1U, CountBalloons()); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 478 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | { |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 482 | SCOPED_TRACE("second: balloon"); |
[email protected] | e3dfc74 | 2012-11-29 22:42:02 | [diff] [blame] | 483 | ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 484 | CheckExtensionConsistency(first_extension_id_); |
| 485 | CheckExtensionConsistency(second_extension_id_); |
[email protected] | ee8abdeb | 2010-03-10 11:02:32 | [diff] [blame] | 486 | } |
| 487 | } |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 488 | |
[email protected] | 5d2b0cd | 2013-05-24 07:47:12 | [diff] [blame] | 489 | // http://crbug.com/243648 |
| 490 | #if defined(OS_WIN) |
| 491 | #define MAYBE_CrashAndUninstall DISABLED_CrashAndUninstall |
| 492 | #else |
| 493 | #define MAYBE_CrashAndUninstall CrashAndUninstall |
| 494 | #endif |
| 495 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
| 496 | MAYBE_CrashAndUninstall) { |
[email protected] | 0dfe05c | 2011-02-23 23:03:36 | [diff] [blame] | 497 | const size_t size_before = GetExtensionService()->extensions()->size(); |
| 498 | const size_t crash_size_before = |
| 499 | GetExtensionService()->terminated_extensions()->size(); |
| 500 | LoadTestExtension(); |
| 501 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 502 | CrashExtension(first_extension_id_); |
[email protected] | 0dfe05c | 2011-02-23 23:03:36 | [diff] [blame] | 503 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
| 504 | ASSERT_EQ(crash_size_before + 1, |
| 505 | GetExtensionService()->terminated_extensions()->size()); |
| 506 | |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 507 | ASSERT_EQ(1U, CountBalloons()); |
[email protected] | 0dfe05c | 2011-02-23 23:03:36 | [diff] [blame] | 508 | UninstallExtension(first_extension_id_); |
[email protected] | b3a2509 | 2013-05-28 22:08:16 | [diff] [blame] | 509 | base::MessageLoop::current()->RunUntilIdle(); |
[email protected] | 0dfe05c | 2011-02-23 23:03:36 | [diff] [blame] | 510 | |
| 511 | SCOPED_TRACE("after uninstalling"); |
| 512 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
| 513 | ASSERT_EQ(crash_size_before, |
| 514 | GetExtensionService()->terminated_extensions()->size()); |
[email protected] | 2c4fb7b | 2011-04-02 06:33:29 | [diff] [blame] | 515 | ASSERT_EQ(0U, CountBalloons()); |
[email protected] | 0dfe05c | 2011-02-23 23:03:36 | [diff] [blame] | 516 | } |
| 517 | |
[email protected] | 4ccc8cc | 2011-06-07 21:25:30 | [diff] [blame] | 518 | // http://crbug.com/84719 |
| 519 | #if defined(OS_LINUX) |
| 520 | #define MAYBE_CrashAndUnloadAll DISABLED_CrashAndUnloadAll |
| 521 | #else |
| 522 | #define MAYBE_CrashAndUnloadAll CrashAndUnloadAll |
| 523 | #endif // defined(OS_LINUX) |
| 524 | |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 525 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
| 526 | MAYBE_CrashAndUnloadAll) { |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 527 | const size_t size_before = GetExtensionService()->extensions()->size(); |
| 528 | const size_t crash_size_before = |
| 529 | GetExtensionService()->terminated_extensions()->size(); |
| 530 | LoadTestExtension(); |
| 531 | LoadSecondExtension(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 532 | CrashExtension(first_extension_id_); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 533 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
| 534 | ASSERT_EQ(crash_size_before + 1, |
| 535 | GetExtensionService()->terminated_extensions()->size()); |
| 536 | |
[email protected] | bb1bc9b3 | 2013-12-21 03:09:14 | [diff] [blame^] | 537 | GetExtensionService()->UnloadAllExtensionsForTest(); |
[email protected] | bb7f4095 | 2011-01-13 00:21:20 | [diff] [blame] | 538 | ASSERT_EQ(crash_size_before, |
| 539 | GetExtensionService()->terminated_extensions()->size()); |
| 540 | } |
[email protected] | b3f7fe2 | 2011-11-11 19:27:56 | [diff] [blame] | 541 | |
[email protected] | 260122c | 2013-05-22 15:05:55 | [diff] [blame] | 542 | // Fails a DCHECK on Aura and Linux: http://crbug.com/169622 |
| 543 | // Failing on Windows: http://crbug.com/232340 |
| 544 | #if defined(USE_AURA) || defined(OS_WIN) || defined(OS_LINUX) |
[email protected] | 60c3e91 | 2013-01-12 20:16:28 | [diff] [blame] | 545 | #define MAYBE_ReloadTabsWithBackgroundPage DISABLED_ReloadTabsWithBackgroundPage |
| 546 | #else |
| 547 | #define MAYBE_ReloadTabsWithBackgroundPage ReloadTabsWithBackgroundPage |
[email protected] | 3e902a8 | 2013-04-17 11:42:42 | [diff] [blame] | 548 | #endif |
[email protected] | 60c3e91 | 2013-01-12 20:16:28 | [diff] [blame] | 549 | |
[email protected] | b3f7fe2 | 2011-11-11 19:27:56 | [diff] [blame] | 550 | // Test that when an extension with a background page that has a tab open |
| 551 | // crashes, the tab stays open, and reloading it reloads the extension. |
| 552 | // Regression test for issue 71629. |
[email protected] | 5a95d77 | 2013-02-06 21:16:28 | [diff] [blame] | 553 | IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, |
[email protected] | 60c3e91 | 2013-01-12 20:16:28 | [diff] [blame] | 554 | MAYBE_ReloadTabsWithBackgroundPage) { |
[email protected] | c084925 | 2012-05-12 13:51:27 | [diff] [blame] | 555 | TabStripModel* tab_strip = browser()->tab_strip_model(); |
[email protected] | b3f7fe2 | 2011-11-11 19:27:56 | [diff] [blame] | 556 | const size_t size_before = GetExtensionService()->extensions()->size(); |
| 557 | const size_t crash_size_before = |
| 558 | GetExtensionService()->terminated_extensions()->size(); |
| 559 | LoadTestExtension(); |
| 560 | |
| 561 | // Open a tab extension. |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 562 | chrome::NewTab(browser()); |
[email protected] | b3f7fe2 | 2011-11-11 19:27:56 | [diff] [blame] | 563 | ui_test_utils::NavigateToURL( |
| 564 | browser(), |
| 565 | GURL("chrome-extension://" + first_extension_id_ + "/background.html")); |
| 566 | |
| 567 | const int tabs_before = tab_strip->count(); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 568 | CrashExtension(first_extension_id_); |
[email protected] | b3f7fe2 | 2011-11-11 19:27:56 | [diff] [blame] | 569 | |
| 570 | // Tab should still be open, and extension should be crashed. |
| 571 | EXPECT_EQ(tabs_before, tab_strip->count()); |
| 572 | EXPECT_EQ(size_before, GetExtensionService()->extensions()->size()); |
| 573 | EXPECT_EQ(crash_size_before + 1, |
| 574 | GetExtensionService()->terminated_extensions()->size()); |
| 575 | |
| 576 | { |
[email protected] | a7fe911 | 2012-07-20 02:34:45 | [diff] [blame] | 577 | content::WindowedNotificationObserver observer( |
[email protected] | b3f7fe2 | 2011-11-11 19:27:56 | [diff] [blame] | 578 | content::NOTIFICATION_LOAD_STOP, |
[email protected] | c5eed49 | 2012-01-04 17:07:50 | [diff] [blame] | 579 | content::Source<NavigationController>( |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 580 | &browser()->tab_strip_model()->GetActiveWebContents()-> |
| 581 | GetController())); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 582 | chrome::Reload(browser(), CURRENT_TAB); |
[email protected] | b3f7fe2 | 2011-11-11 19:27:56 | [diff] [blame] | 583 | observer.Wait(); |
| 584 | } |
| 585 | // Extension should now be loaded. |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 586 | SCOPED_TRACE("after reloading the tab"); |
| 587 | CheckExtensionConsistency(first_extension_id_); |
[email protected] | b3f7fe2 | 2011-11-11 19:27:56 | [diff] [blame] | 588 | ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
| 589 | ASSERT_EQ(0U, CountBalloons()); |
| 590 | } |