| 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" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 ui_test_utils::NavigateToURL(browser(), | 218 ui_test_utils::NavigateToURL(browser(), |
| 219 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 219 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 220 FilePath(FILE_PATH_LITERAL("title1.html")))); | 220 FilePath(FILE_PATH_LITERAL("title1.html")))); |
| 221 ASSERT_EQ(1U, CountBalloons()); | 221 ASSERT_EQ(1U, CountBalloons()); |
| 222 | 222 |
| 223 ReloadExtension(first_extension_id_); | 223 ReloadExtension(first_extension_id_); |
| 224 | 224 |
| 225 SCOPED_TRACE("after reloading"); | 225 SCOPED_TRACE("after reloading"); |
| 226 CheckExtensionConsistency(size_before); | 226 CheckExtensionConsistency(size_before); |
| 227 | 227 |
| 228 // The infobar should automatically hide after the extension is successfully | 228 // The balloon should automatically hide after the extension is successfully |
| 229 // reloaded. | 229 // reloaded. |
| 230 ASSERT_EQ(0U, CountBalloons()); | 230 ASSERT_EQ(0U, CountBalloons()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, | |
| 234 ReloadIndependentlyTwoInfoBars) { | |
| 235 const size_t size_before = GetExtensionService()->extensions()->size(); | |
| 236 LoadTestExtension(); | |
| 237 | |
| 238 // Open a new window so that there will be an info bar in each. | |
| 239 Browser* browser2 = CreateBrowser(browser()->profile()); | |
| 240 | |
| 241 CrashExtension(size_before); | |
| 242 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); | |
| 243 | |
| 244 TabContents* current_tab = browser()->GetSelectedTabContents(); | |
| 245 ASSERT_TRUE(current_tab); | |
| 246 ASSERT_EQ(1U, CountBalloons()); | |
| 247 | |
| 248 TabContents* current_tab2 = browser2->GetSelectedTabContents(); | |
| 249 ASSERT_TRUE(current_tab2); | |
| 250 ASSERT_EQ(1U, CountBalloons()); | |
| 251 | |
| 252 ReloadExtension(first_extension_id_); | |
| 253 | |
| 254 SCOPED_TRACE("after reloading"); | |
| 255 CheckExtensionConsistency(size_before); | |
| 256 | |
| 257 // Both infobars should automatically hide after the extension is successfully | |
| 258 // reloaded. | |
| 259 ASSERT_EQ(0U, CountBalloons()); | |
| 260 ASSERT_EQ(0U, CountBalloons()); | |
| 261 } | |
| 262 | |
| 263 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, | |
| 264 ReloadIndependentlyTwoInfoBarsSameBrowser) { | |
| 265 const size_t size_before = GetExtensionService()->extensions()->size(); | |
| 266 LoadTestExtension(); | |
| 267 | |
| 268 // Open a new window so that there will be an info bar in each. | |
| 269 Browser* browser2 = CreateBrowser(browser()->profile()); | |
| 270 | |
| 271 CrashExtension(size_before); | |
| 272 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); | |
| 273 | |
| 274 TabContents* current_tab = browser()->GetSelectedTabContents(); | |
| 275 ASSERT_TRUE(current_tab); | |
| 276 ASSERT_EQ(1U, CountBalloons()); | |
| 277 | |
| 278 TabContents* current_tab2 = browser2->GetSelectedTabContents(); | |
| 279 ASSERT_TRUE(current_tab2); | |
| 280 ASSERT_EQ(1U, CountBalloons()); | |
| 281 | |
| 282 // Move second window into first browser so there will be multiple tabs | |
| 283 // with the info bar for the same extension in one browser. | |
| 284 TabContentsWrapper* contents = | |
| 285 browser2->tabstrip_model()->DetachTabContentsAt(0); | |
| 286 browser()->tabstrip_model()->AppendTabContents(contents, true); | |
| 287 current_tab2 = browser()->GetSelectedTabContents(); | |
| 288 ASSERT_EQ(1U, CountBalloons()); | |
| 289 ASSERT_NE(current_tab2, current_tab); | |
| 290 | |
| 291 ReloadExtension(first_extension_id_); | |
| 292 | |
| 293 SCOPED_TRACE("after reloading"); | |
| 294 CheckExtensionConsistency(size_before); | |
| 295 | |
| 296 // Both infobars should automatically hide after the extension is successfully | |
| 297 // reloaded. | |
| 298 ASSERT_EQ(0U, CountBalloons()); | |
| 299 browser()->SelectPreviousTab(); | |
| 300 ASSERT_EQ(current_tab, browser()->GetSelectedTabContents()); | |
| 301 ASSERT_EQ(0U, CountBalloons()); | |
| 302 } | |
| 303 | |
| 304 // Make sure that when we don't do anything about the crashed extension | 233 // Make sure that when we don't do anything about the crashed extension |
| 305 // and close the browser, it doesn't crash. The browser is closed implicitly | 234 // and close the browser, it doesn't crash. The browser is closed implicitly |
| 306 // at the end of each browser test. | 235 // at the end of each browser test. |
| 307 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, ShutdownWhileCrashed) { | 236 IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, ShutdownWhileCrashed) { |
| 308 const size_t size_before = GetExtensionService()->extensions()->size(); | 237 const size_t size_before = GetExtensionService()->extensions()->size(); |
| 309 LoadTestExtension(); | 238 LoadTestExtension(); |
| 310 CrashExtension(size_before); | 239 CrashExtension(size_before); |
| 311 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); | 240 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
| 312 } | 241 } |
| 313 | 242 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 LoadSecondExtension(); | 359 LoadSecondExtension(); |
| 431 CrashExtension(size_before); | 360 CrashExtension(size_before); |
| 432 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); | 361 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
| 433 CrashExtension(size_before); | 362 CrashExtension(size_before); |
| 434 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); | 363 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
| 435 | 364 |
| 436 { | 365 { |
| 437 SCOPED_TRACE("first: reload"); | 366 SCOPED_TRACE("first: reload"); |
| 438 TabContents* current_tab = browser()->GetSelectedTabContents(); | 367 TabContents* current_tab = browser()->GetSelectedTabContents(); |
| 439 ASSERT_TRUE(current_tab); | 368 ASSERT_TRUE(current_tab); |
| 440 // At the beginning we should have one infobar displayed for each extension. | 369 // At the beginning we should have one balloon displayed for each extension. |
| 441 ASSERT_EQ(2U, CountBalloons()); | 370 ASSERT_EQ(2U, CountBalloons()); |
| 442 ReloadExtension(first_extension_id_); | 371 ReloadExtension(first_extension_id_); |
| 443 // One of the infobars should hide after the extension is reloaded. | 372 // One of the balloons should hide after the extension is reloaded. |
| 444 ASSERT_EQ(1U, CountBalloons()); | 373 ASSERT_EQ(1U, CountBalloons()); |
| 445 CheckExtensionConsistency(size_before); | 374 CheckExtensionConsistency(size_before); |
| 446 } | 375 } |
| 447 | 376 |
| 448 { | 377 { |
| 449 SCOPED_TRACE("second: balloon"); | 378 SCOPED_TRACE("second: balloon"); |
| 450 AcceptNotification(0); | 379 AcceptNotification(0); |
| 451 CheckExtensionConsistency(size_before); | 380 CheckExtensionConsistency(size_before); |
| 452 CheckExtensionConsistency(size_before + 1); | 381 CheckExtensionConsistency(size_before + 1); |
| 453 } | 382 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 483 LoadSecondExtension(); | 412 LoadSecondExtension(); |
| 484 CrashExtension(size_before); | 413 CrashExtension(size_before); |
| 485 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); | 414 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); |
| 486 ASSERT_EQ(crash_size_before + 1, | 415 ASSERT_EQ(crash_size_before + 1, |
| 487 GetExtensionService()->terminated_extensions()->size()); | 416 GetExtensionService()->terminated_extensions()->size()); |
| 488 | 417 |
| 489 GetExtensionService()->UnloadAllExtensions(); | 418 GetExtensionService()->UnloadAllExtensions(); |
| 490 ASSERT_EQ(crash_size_before, | 419 ASSERT_EQ(crash_size_before, |
| 491 GetExtensionService()->terminated_extensions()->size()); | 420 GetExtensionService()->terminated_extensions()->size()); |
| 492 } | 421 } |
| OLD | NEW |