OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 #include "chrome/browser/extensions/pending_extension_info.h" | 51 #include "chrome/browser/extensions/pending_extension_info.h" |
52 #include "chrome/browser/extensions/pending_extension_manager.h" | 52 #include "chrome/browser/extensions/pending_extension_manager.h" |
53 #include "chrome/browser/extensions/test_extension_system.h" | 53 #include "chrome/browser/extensions/test_extension_system.h" |
54 #include "chrome/browser/extensions/test_management_policy.h" | 54 #include "chrome/browser/extensions/test_management_policy.h" |
55 #include "chrome/browser/extensions/unpacked_installer.h" | 55 #include "chrome/browser/extensions/unpacked_installer.h" |
56 #include "chrome/browser/extensions/updater/extension_updater.h" | 56 #include "chrome/browser/extensions/updater/extension_updater.h" |
57 #include "chrome/browser/prefs/browser_prefs.h" | 57 #include "chrome/browser/prefs/browser_prefs.h" |
58 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 58 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
59 #include "chrome/browser/prefs/pref_service_syncable.h" | 59 #include "chrome/browser/prefs/pref_service_syncable.h" |
60 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 60 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
61 #include "chrome/browser/profiles/profile_manager.h" | |
61 #include "chrome/common/chrome_constants.h" | 62 #include "chrome/common/chrome_constants.h" |
62 #include "chrome/common/chrome_notification_types.h" | 63 #include "chrome/common/chrome_notification_types.h" |
63 #include "chrome/common/chrome_paths.h" | 64 #include "chrome/common/chrome_paths.h" |
64 #include "chrome/common/chrome_switches.h" | 65 #include "chrome/common/chrome_switches.h" |
65 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 66 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
66 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 67 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
67 #include "chrome/common/extensions/background_info.h" | 68 #include "chrome/common/extensions/background_info.h" |
68 #include "chrome/common/extensions/extension.h" | 69 #include "chrome/common/extensions/extension.h" |
69 #include "chrome/common/extensions/extension_l10n_util.h" | 70 #include "chrome/common/extensions/extension_l10n_util.h" |
70 #include "chrome/common/extensions/extension_manifest_constants.h" | 71 #include "chrome/common/extensions/extension_manifest_constants.h" |
72 #include "chrome/common/extensions/extension_messages.h" | |
71 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 73 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
72 #include "chrome/common/extensions/manifest_handlers/requirements_handler.h" | 74 #include "chrome/common/extensions/manifest_handlers/requirements_handler.h" |
73 #include "chrome/common/extensions/manifest_url_handler.h" | 75 #include "chrome/common/extensions/manifest_url_handler.h" |
74 #include "chrome/common/extensions/permissions/permission_set.h" | 76 #include "chrome/common/extensions/permissions/permission_set.h" |
75 #include "chrome/common/pref_names.h" | 77 #include "chrome/common/pref_names.h" |
76 #include "chrome/common/url_constants.h" | 78 #include "chrome/common/url_constants.h" |
79 #include "chrome/test/base/testing_browser_process.h" | |
77 #include "chrome/test/base/testing_profile.h" | 80 #include "chrome/test/base/testing_profile.h" |
78 #include "components/user_prefs/pref_registry_syncable.h" | 81 #include "components/user_prefs/pref_registry_syncable.h" |
79 #include "content/public/browser/dom_storage_context.h" | 82 #include "content/public/browser/dom_storage_context.h" |
80 #include "content/public/browser/gpu_data_manager.h" | 83 #include "content/public/browser/gpu_data_manager.h" |
81 #include "content/public/browser/indexed_db_context.h" | 84 #include "content/public/browser/indexed_db_context.h" |
82 #include "content/public/browser/notification_registrar.h" | 85 #include "content/public/browser/notification_registrar.h" |
83 #include "content/public/browser/notification_service.h" | 86 #include "content/public/browser/notification_service.h" |
84 #include "content/public/browser/plugin_service.h" | 87 #include "content/public/browser/plugin_service.h" |
88 #include "content/public/browser/site_instance.h" | |
85 #include "content/public/browser/storage_partition.h" | 89 #include "content/public/browser/storage_partition.h" |
86 #include "content/public/common/content_constants.h" | 90 #include "content/public/common/content_constants.h" |
87 #include "content/public/common/gpu_info.h" | 91 #include "content/public/common/gpu_info.h" |
88 #include "content/public/test/test_browser_thread.h" | 92 #include "content/public/test/test_browser_thread.h" |
93 #include "content/public/test/test_notification_tracker.h" | |
89 #include "extensions/common/constants.h" | 94 #include "extensions/common/constants.h" |
90 #include "extensions/common/extension_resource.h" | 95 #include "extensions/common/extension_resource.h" |
91 #include "extensions/common/url_pattern.h" | 96 #include "extensions/common/url_pattern.h" |
92 #include "googleurl/src/gurl.h" | 97 #include "googleurl/src/gurl.h" |
93 #include "grit/browser_resources.h" | 98 #include "grit/browser_resources.h" |
94 #include "net/cookies/canonical_cookie.h" | 99 #include "net/cookies/canonical_cookie.h" |
95 #include "net/cookies/cookie_monster.h" | 100 #include "net/cookies/cookie_monster.h" |
96 #include "net/cookies/cookie_options.h" | 101 #include "net/cookies/cookie_options.h" |
97 #include "net/url_request/url_request_context.h" | 102 #include "net/url_request/url_request_context.h" |
98 #include "net/url_request/url_request_context_getter.h" | 103 #include "net/url_request/url_request_context_getter.h" |
99 #include "sync/api/string_ordinal.h" | 104 #include "sync/api/string_ordinal.h" |
100 #include "sync/api/sync_error_factory.h" | 105 #include "sync/api/sync_error_factory.h" |
101 #include "sync/api/sync_error_factory_mock.h" | 106 #include "sync/api/sync_error_factory_mock.h" |
102 #include "sync/protocol/app_specifics.pb.h" | 107 #include "sync/protocol/app_specifics.pb.h" |
103 #include "sync/protocol/extension_specifics.pb.h" | 108 #include "sync/protocol/extension_specifics.pb.h" |
104 #include "sync/protocol/sync.pb.h" | 109 #include "sync/protocol/sync.pb.h" |
110 #include "testing/gmock/include/gmock/gmock.h" | |
105 #include "testing/gtest/include/gtest/gtest.h" | 111 #include "testing/gtest/include/gtest/gtest.h" |
106 #include "testing/platform_test.h" | 112 #include "testing/platform_test.h" |
107 #include "webkit/database/database_tracker.h" | 113 #include "webkit/database/database_tracker.h" |
108 #include "webkit/database/database_util.h" | 114 #include "webkit/database/database_util.h" |
109 #include "webkit/plugins/npapi/mock_plugin_list.h" | 115 #include "webkit/plugins/npapi/mock_plugin_list.h" |
110 #include "webkit/quota/quota_manager.h" | 116 #include "webkit/quota/quota_manager.h" |
111 | 117 |
112 #if defined(OS_CHROMEOS) | 118 #if defined(OS_CHROMEOS) |
113 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 119 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
114 #endif | 120 #endif |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 int expected_creation_flags_; | 410 int expected_creation_flags_; |
405 scoped_ptr<extensions::ExternalProviderImpl> provider_; | 411 scoped_ptr<extensions::ExternalProviderImpl> provider_; |
406 scoped_ptr<DictionaryValue> prefs_; | 412 scoped_ptr<DictionaryValue> prefs_; |
407 | 413 |
408 DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor); | 414 DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor); |
409 }; | 415 }; |
410 | 416 |
411 // Our message loop may be used in tests which require it to be an IO loop. | 417 // Our message loop may be used in tests which require it to be an IO loop. |
412 ExtensionServiceTestBase::ExtensionServiceTestBase() | 418 ExtensionServiceTestBase::ExtensionServiceTestBase() |
413 : loop_(MessageLoop::TYPE_IO), | 419 : loop_(MessageLoop::TYPE_IO), |
420 local_state_(TestingBrowserProcess::GetGlobal()), | |
414 service_(NULL), | 421 service_(NULL), |
415 management_policy_(NULL), | 422 management_policy_(NULL), |
416 expected_extensions_count_(0), | 423 expected_extensions_count_(0), |
417 ui_thread_(BrowserThread::UI, &loop_), | 424 ui_thread_(BrowserThread::UI, &loop_), |
418 db_thread_(BrowserThread::DB, &loop_), | 425 db_thread_(BrowserThread::DB, &loop_), |
419 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &loop_), | 426 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &loop_), |
420 file_thread_(BrowserThread::FILE, &loop_), | 427 file_thread_(BrowserThread::FILE, &loop_), |
421 file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING, &loop_), | 428 file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING, &loop_), |
422 io_thread_(BrowserThread::IO, &loop_), | 429 io_thread_(BrowserThread::IO, &loop_), |
423 override_sideload_wipeout_( | 430 override_sideload_wipeout_( |
424 FeatureSwitch::sideload_wipeout(), false) { | 431 FeatureSwitch::sideload_wipeout(), false) { |
425 base::FilePath test_data_dir; | 432 base::FilePath test_data_dir; |
426 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)) { | 433 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)) { |
427 ADD_FAILURE(); | 434 ADD_FAILURE(); |
428 return; | 435 return; |
429 } | 436 } |
430 data_dir_ = test_data_dir.AppendASCII("extensions"); | 437 data_dir_ = test_data_dir.AppendASCII("extensions"); |
431 } | 438 } |
432 | 439 |
433 ExtensionServiceTestBase::~ExtensionServiceTestBase() { | 440 ExtensionServiceTestBase::~ExtensionServiceTestBase() { |
434 // Drop our reference to ExtensionService and TestingProfile, so that they | 441 // Drop our reference to ExtensionService and TestingProfile, so that they |
435 // can be destroyed while BrowserThreads and MessageLoop are still around | 442 // can be destroyed while BrowserThreads and MessageLoop are still around |
436 // (they are used in the destruction process). | 443 // (they are used in the destruction process). |
437 service_ = NULL; | 444 service_ = NULL; |
438 MessageLoop::current()->RunUntilIdle(); | 445 MessageLoop::current()->RunUntilIdle(); |
439 profile_.reset(NULL); | 446 profile_.reset(NULL); |
440 MessageLoop::current()->RunUntilIdle(); | 447 MessageLoop::current()->RunUntilIdle(); |
448 | |
449 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); | |
441 } | 450 } |
442 | 451 |
443 void ExtensionServiceTestBase::InitializeExtensionService( | 452 void ExtensionServiceTestBase::InitializeExtensionService( |
444 const base::FilePath& profile_path, | 453 const base::FilePath& profile_path, |
445 const base::FilePath& pref_file, | 454 const base::FilePath& pref_file, |
446 const base::FilePath& extensions_install_dir, | 455 const base::FilePath& extensions_install_dir, |
447 bool autoupdate_enabled) { | 456 bool autoupdate_enabled) { |
448 TestingProfile::Builder profile_builder; | 457 TestingProfile::Builder profile_builder; |
449 // Create a PrefService that only contains user defined preference values. | 458 // Create a PrefService that only contains user defined preference values. |
450 PrefServiceMockBuilder builder; | 459 PrefServiceMockBuilder builder; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 file_util::CopyDirectory(source_install_dir, extensions_install_dir_, true); | 509 file_util::CopyDirectory(source_install_dir, extensions_install_dir_, true); |
501 | 510 |
502 InitializeExtensionService(path, temp_prefs, extensions_install_dir_, false); | 511 InitializeExtensionService(path, temp_prefs, extensions_install_dir_, false); |
503 } | 512 } |
504 | 513 |
505 void ExtensionServiceTestBase::InitializeEmptyExtensionService() { | 514 void ExtensionServiceTestBase::InitializeEmptyExtensionService() { |
506 InitializeExtensionServiceHelper(false); | 515 InitializeExtensionServiceHelper(false); |
507 } | 516 } |
508 | 517 |
509 void ExtensionServiceTestBase::InitializeExtensionProcessManager() { | 518 void ExtensionServiceTestBase::InitializeExtensionProcessManager() { |
510 static_cast<extensions::TestExtensionSystem*>( | 519 // Needed in order to look up RenderProcessHosts. |
511 ExtensionSystem::Get(profile_.get()))-> | 520 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
512 CreateExtensionProcessManager(); | 521 new ProfileManagerWithoutInit(temp_dir_.path())); |
522 | |
523 extensions::TestExtensionSystem* system = | |
524 static_cast<extensions::TestExtensionSystem*>( | |
525 ExtensionSystem::Get(profile_.get())); | |
526 system->CreateExtensionProcessManager(); | |
527 system->process_manager()->site_instance_for_test()-> | |
528 SetRenderProcessHostFactory(&rph_factory_); | |
513 } | 529 } |
514 | 530 |
515 void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() { | 531 void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() { |
516 InitializeExtensionServiceHelper(true); | 532 InitializeExtensionServiceHelper(true); |
517 service_->updater()->Start(); | 533 service_->updater()->Start(); |
518 } | 534 } |
519 | 535 |
520 void ExtensionServiceTestBase::InitializeExtensionServiceHelper( | 536 void ExtensionServiceTestBase::InitializeExtensionServiceHelper( |
521 bool autoupdate_enabled) { | 537 bool autoupdate_enabled) { |
522 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 538 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
(...skipping 3077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3600 // EnableExtension() call above inserted into it and | 3616 // EnableExtension() call above inserted into it and |
3601 // UnloadAllExtensions() doesn't send out notifications. | 3617 // UnloadAllExtensions() doesn't send out notifications. |
3602 loaded_.clear(); | 3618 loaded_.clear(); |
3603 service_->ReloadExtensions(); | 3619 service_->ReloadExtensions(); |
3604 | 3620 |
3605 // Extension counts shouldn't change. | 3621 // Extension counts shouldn't change. |
3606 EXPECT_EQ(1u, service_->extensions()->size()); | 3622 EXPECT_EQ(1u, service_->extensions()->size()); |
3607 EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 3623 EXPECT_EQ(0u, service_->disabled_extensions()->size()); |
3608 } | 3624 } |
3609 | 3625 |
3626 namespace { | |
3627 std::vector<uint32> ExtensionMessageTypes(const IPC::TestSink& sink) { | |
3628 std::vector<uint32> message_types; | |
3629 for (size_t i = 0; i < sink.message_count(); ++i) { | |
3630 uint32 type = sink.GetMessageAt(i)->type(); | |
3631 if (IPC_MESSAGE_ID_CLASS(type) == ExtensionMsgStart) | |
3632 message_types.push_back(type); | |
3633 } | |
3634 return message_types; | |
3635 } | |
3636 | |
3637 struct ProcessObserver | |
3638 : public content::MockRenderProcessHostFactory::Observer { | |
3639 explicit ProcessObserver(content::MockRenderProcessHostFactory* factory) | |
3640 : Observer(factory) {} | |
3641 | |
3642 ~ProcessObserver() { | |
3643 for (size_t i = 0; i < hosts.size(); ++i) { | |
3644 if (destroyed_processes.count(process_ids[i]) == 0) | |
3645 hosts[i]->sink().RemoveFilter(process_messages[i]); | |
3646 delete process_messages[i]; | |
3647 } | |
3648 } | |
3649 | |
3650 virtual void OnRenderProcessHostCreated( | |
3651 content::MockRenderProcessHost* host) { | |
3652 IPC::TestSink* sink = new IPC::TestSink; | |
3653 hosts.push_back(host); | |
3654 process_ids.push_back(host->GetID()); | |
3655 process_messages.push_back(sink); | |
3656 host->sink().AddFilter(sink); | |
3657 } | |
3658 virtual void OnRenderProcessHostDestroyed( | |
3659 content::MockRenderProcessHost* host) { | |
3660 destroyed_processes.insert(host->GetID()); | |
3661 } | |
3662 | |
3663 std::vector<content::MockRenderProcessHost*> hosts; | |
3664 std::vector<int> process_ids; | |
3665 std::vector<IPC::TestSink*> process_messages; | |
3666 std::set<int> destroyed_processes; | |
3667 }; | |
3668 } // namespace | |
3669 | |
3610 // Tests reloading an extension. | 3670 // Tests reloading an extension. |
3611 TEST_F(ExtensionServiceTest, ReloadExtension) { | 3671 TEST_F(ExtensionServiceTest, ReloadExtension) { |
3672 ProcessObserver observer(&rph_factory_); | |
3673 | |
3674 content::TestNotificationTracker notifications; | |
3675 notifications.ListenForAll(chrome::NOTIFICATION_EXTENSIONS_READY); | |
3676 notifications.ListenForAll(chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED); | |
3677 notifications.ListenForAll(chrome::NOTIFICATION_EXTENSION_LOADED); | |
3678 notifications.ListenForAll(chrome::NOTIFICATION_EXTENSION_UNLOADED); | |
3679 notifications.ListenForAll(content::NOTIFICATION_RENDERER_PROCESS_CLOSING); | |
3680 notifications.ListenForAll(content::NOTIFICATION_RENDERER_PROCESS_CREATED); | |
3681 notifications.ListenForAll(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); | |
3682 notifications.ListenForAll( | |
3683 content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW); | |
3684 | |
3612 InitializeEmptyExtensionService(); | 3685 InitializeEmptyExtensionService(); |
3613 InitializeExtensionProcessManager(); | 3686 InitializeExtensionProcessManager(); |
3687 service_->Init(); | |
3688 EXPECT_THAT(notifications.GetTypesAndReset(), | |
3689 testing::ElementsAre(chrome::NOTIFICATION_EXTENSIONS_READY)); | |
3614 | 3690 |
3615 // Simple extension that should install without error. | 3691 // Simple extension that should install without error. |
3616 const char* extension_id = "behllobkkfkfnphdnhnkndlbkcpglgmj"; | 3692 const char* extension_id = "behllobkkfkfnphdnhnkndlbkcpglgmj"; |
3617 base::FilePath ext = data_dir_ | 3693 base::FilePath ext = data_dir_ |
3618 .AppendASCII("good") | 3694 .AppendASCII("good") |
3619 .AppendASCII("Extensions") | 3695 .AppendASCII("Extensions") |
3620 .AppendASCII(extension_id) | 3696 .AppendASCII(extension_id) |
3621 .AppendASCII("1.0.0.0"); | 3697 .AppendASCII("1.0.0.0"); |
3622 extensions::UnpackedInstaller::Create(service_)->Load(ext); | 3698 extensions::UnpackedInstaller::Create(service_)->Load(ext); |
3623 loop_.RunUntilIdle(); | 3699 loop_.RunUntilIdle(); |
3624 | 3700 |
3701 EXPECT_THAT(notifications.GetTypesAndReset(), | |
3702 testing::ElementsAre(chrome::NOTIFICATION_EXTENSION_LOADED)); | |
3703 ASSERT_EQ(1u, observer.process_messages.size()); | |
3704 EXPECT_THAT(ExtensionMessageTypes(*observer.process_messages[0]), | |
3705 testing::ElementsAre(ExtensionMsg_Loaded::ID, | |
3706 ExtensionMsg_ActivateExtension::ID, | |
3707 ExtensionMsg_Loaded::ID, | |
3708 ExtensionMsg_ActivateExtension::ID, | |
3709 ExtensionMsg_Loaded::ID, | |
Jeffrey Yasskin
2013/04/09 17:58:32
Why does this extra Loaded/ActivateExtension pair
Matt Perry
2013/04/09 20:20:03
Your experience with gdb makes me wonder if the ty
Jeffrey Yasskin
2013/04/10 16:18:57
Right, a live chrome has some other non-extension
| |
3710 ExtensionMsg_ActivateExtension::ID, | |
3711 ExtensionMsg_NotifyRenderViewType::ID)); | |
3712 observer.process_messages[0]->ClearMessages(); | |
3713 | |
3625 EXPECT_EQ(1u, service_->extensions()->size()); | 3714 EXPECT_EQ(1u, service_->extensions()->size()); |
3626 EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 3715 EXPECT_EQ(0u, service_->disabled_extensions()->size()); |
3627 | 3716 |
3628 service_->ReloadExtension(extension_id); | 3717 service_->ReloadExtension(extension_id); |
3629 | 3718 |
3719 EXPECT_THAT(notifications.GetTypesAndReset(), | |
3720 testing::ElementsAre( | |
3721 chrome::NOTIFICATION_EXTENSION_UNLOADED, | |
3722 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | |
3723 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | |
3724 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED)); | |
3725 | |
3726 ASSERT_EQ(1u, observer.process_messages.size()); | |
3727 EXPECT_THAT(ExtensionMessageTypes(*observer.process_messages[0]), | |
3728 testing::ElementsAre()); | |
3729 observer.process_messages[0]->ClearMessages(); | |
3730 | |
3630 // Extension should be disabled now, waiting to be reloaded. | 3731 // Extension should be disabled now, waiting to be reloaded. |
3631 EXPECT_EQ(0u, service_->extensions()->size()); | 3732 EXPECT_EQ(0u, service_->extensions()->size()); |
3632 EXPECT_EQ(1u, service_->disabled_extensions()->size()); | 3733 EXPECT_EQ(1u, service_->disabled_extensions()->size()); |
3633 EXPECT_EQ(Extension::DISABLE_RELOAD, | 3734 EXPECT_EQ(Extension::DISABLE_RELOAD, |
3634 service_->extension_prefs()->GetDisableReasons(extension_id)); | 3735 service_->extension_prefs()->GetDisableReasons(extension_id)); |
3635 | 3736 |
3636 // Reloading again should not crash. | 3737 // Reloading again before iterating the MessageLoop should not crash and |
3738 // shouldn't cause an extra reload. | |
3637 service_->ReloadExtension(extension_id); | 3739 service_->ReloadExtension(extension_id); |
3740 EXPECT_THAT(notifications.GetTypesAndReset(), | |
3741 testing::ElementsAre()); | |
3742 ASSERT_EQ(1u, observer.process_messages.size()); | |
3743 EXPECT_THAT(ExtensionMessageTypes(*observer.process_messages[0]), | |
3744 testing::ElementsAre()); | |
3745 observer.process_messages[0]->ClearMessages(); | |
3638 | 3746 |
3639 // Finish reloading | 3747 // Finish reloading |
3640 loop_.RunUntilIdle(); | 3748 loop_.RunUntilIdle(); |
3641 | 3749 |
3750 EXPECT_THAT(notifications.GetTypesAndReset(), | |
3751 testing::ElementsAre( | |
3752 chrome::NOTIFICATION_EXTENSION_LOADED, | |
3753 chrome::NOTIFICATION_EXTENSION_UNLOADED, | |
3754 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | |
3755 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | |
3756 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | |
3757 chrome::NOTIFICATION_EXTENSION_LOADED)); | |
3758 | |
3759 ASSERT_EQ(3u, observer.process_messages.size()); | |
3760 EXPECT_THAT(observer.destroyed_processes, | |
3761 testing::ElementsAre(observer.process_ids[0], | |
3762 observer.process_ids[1])); | |
3763 EXPECT_THAT(ExtensionMessageTypes(*observer.process_messages[0]), | |
3764 testing::ElementsAre()); | |
3765 observer.process_messages[0]->ClearMessages(); | |
3766 EXPECT_THAT(ExtensionMessageTypes(*observer.process_messages[1]), | |
3767 testing::ElementsAre(ExtensionMsg_Loaded::ID, | |
3768 ExtensionMsg_ActivateExtension::ID, | |
3769 ExtensionMsg_Loaded::ID, | |
3770 ExtensionMsg_ActivateExtension::ID, | |
3771 ExtensionMsg_Loaded::ID, | |
3772 ExtensionMsg_ActivateExtension::ID, | |
3773 ExtensionMsg_NotifyRenderViewType::ID)); | |
3774 observer.process_messages[1]->ClearMessages(); | |
3775 EXPECT_THAT(ExtensionMessageTypes(*observer.process_messages[2]), | |
3776 testing::ElementsAre(ExtensionMsg_Loaded::ID, | |
3777 ExtensionMsg_ActivateExtension::ID, | |
3778 ExtensionMsg_Loaded::ID, | |
3779 ExtensionMsg_ActivateExtension::ID, | |
3780 ExtensionMsg_Loaded::ID, | |
3781 ExtensionMsg_ActivateExtension::ID, | |
3782 ExtensionMsg_NotifyRenderViewType::ID)); | |
3783 observer.process_messages[2]->ClearMessages(); | |
3784 | |
3642 // Extension should be enabled again. | 3785 // Extension should be enabled again. |
3643 EXPECT_EQ(1u, service_->extensions()->size()); | 3786 EXPECT_EQ(1u, service_->extensions()->size()); |
3644 EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 3787 EXPECT_EQ(0u, service_->disabled_extensions()->size()); |
3645 } | 3788 } |
3646 | 3789 |
3647 TEST_F(ExtensionServiceTest, UninstallExtension) { | 3790 TEST_F(ExtensionServiceTest, UninstallExtension) { |
3648 InitializeEmptyExtensionService(); | 3791 InitializeEmptyExtensionService(); |
3649 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); | 3792 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); |
3650 EXPECT_EQ(1u, service_->extensions()->size()); | 3793 EXPECT_EQ(1u, service_->extensions()->size()); |
3651 UninstallExtension(good_crx, false); | 3794 UninstallExtension(good_crx, false); |
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5901 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); | 6044 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); |
5902 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); | 6045 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); |
5903 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); | 6046 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); |
5904 | 6047 |
5905 ExtensionPrefs* prefs = service_->extension_prefs(); | 6048 ExtensionPrefs* prefs = service_->extension_prefs(); |
5906 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) & | 6049 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) & |
5907 Extension::DISABLE_SIDELOAD_WIPEOUT); | 6050 Extension::DISABLE_SIDELOAD_WIPEOUT); |
5908 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) & | 6051 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) & |
5909 Extension::DISABLE_SIDELOAD_WIPEOUT); | 6052 Extension::DISABLE_SIDELOAD_WIPEOUT); |
5910 } | 6053 } |
OLD | NEW |