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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 } | 437 } |
432 | 438 |
433 ExtensionServiceTestBase::~ExtensionServiceTestBase() { | 439 ExtensionServiceTestBase::~ExtensionServiceTestBase() { |
434 // Drop our reference to ExtensionService and TestingProfile, so that they | 440 // Drop our reference to ExtensionService and TestingProfile, so that they |
435 // can be destroyed while BrowserThreads and MessageLoop are still around | 441 // can be destroyed while BrowserThreads and MessageLoop are still around |
436 // (they are used in the destruction process). | 442 // (they are used in the destruction process). |
437 service_ = NULL; | 443 service_ = NULL; |
438 MessageLoop::current()->RunUntilIdle(); | 444 MessageLoop::current()->RunUntilIdle(); |
439 profile_.reset(NULL); | 445 profile_.reset(NULL); |
440 MessageLoop::current()->RunUntilIdle(); | 446 MessageLoop::current()->RunUntilIdle(); |
| 447 |
| 448 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); |
441 } | 449 } |
442 | 450 |
443 void ExtensionServiceTestBase::InitializeExtensionService( | 451 void ExtensionServiceTestBase::InitializeExtensionService( |
444 const base::FilePath& profile_path, | 452 const base::FilePath& profile_path, |
445 const base::FilePath& pref_file, | 453 const base::FilePath& pref_file, |
446 const base::FilePath& extensions_install_dir, | 454 const base::FilePath& extensions_install_dir, |
447 bool autoupdate_enabled) { | 455 bool autoupdate_enabled) { |
448 TestingProfile::Builder profile_builder; | 456 TestingProfile::Builder profile_builder; |
449 // Create a PrefService that only contains user defined preference values. | 457 // Create a PrefService that only contains user defined preference values. |
450 PrefServiceMockBuilder builder; | 458 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); | 508 file_util::CopyDirectory(source_install_dir, extensions_install_dir_, true); |
501 | 509 |
502 InitializeExtensionService(path, temp_prefs, extensions_install_dir_, false); | 510 InitializeExtensionService(path, temp_prefs, extensions_install_dir_, false); |
503 } | 511 } |
504 | 512 |
505 void ExtensionServiceTestBase::InitializeEmptyExtensionService() { | 513 void ExtensionServiceTestBase::InitializeEmptyExtensionService() { |
506 InitializeExtensionServiceHelper(false); | 514 InitializeExtensionServiceHelper(false); |
507 } | 515 } |
508 | 516 |
509 void ExtensionServiceTestBase::InitializeExtensionProcessManager() { | 517 void ExtensionServiceTestBase::InitializeExtensionProcessManager() { |
510 static_cast<extensions::TestExtensionSystem*>( | 518 // Needed in order to look up RenderProcessHosts. |
511 ExtensionSystem::Get(profile_.get()))-> | 519 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
512 CreateExtensionProcessManager(); | 520 new ProfileManagerWithoutInit(temp_dir_.path())); |
| 521 |
| 522 extensions::TestExtensionSystem* system = |
| 523 static_cast<extensions::TestExtensionSystem*>( |
| 524 ExtensionSystem::Get(profile_.get())); |
| 525 system->CreateExtensionProcessManager(); |
| 526 system->process_manager()->GetSiteInstanceForTest()-> |
| 527 SetRenderProcessHostFactory(&rph_factory_); |
513 } | 528 } |
514 | 529 |
515 void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() { | 530 void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() { |
516 InitializeExtensionServiceHelper(true); | 531 InitializeExtensionServiceHelper(true); |
517 service_->updater()->Start(); | 532 service_->updater()->Start(); |
518 } | 533 } |
519 | 534 |
520 void ExtensionServiceTestBase::InitializeExtensionServiceHelper( | 535 void ExtensionServiceTestBase::InitializeExtensionServiceHelper( |
521 bool autoupdate_enabled) { | 536 bool autoupdate_enabled) { |
522 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 537 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 | 3615 // EnableExtension() call above inserted into it and |
3601 // UnloadAllExtensions() doesn't send out notifications. | 3616 // UnloadAllExtensions() doesn't send out notifications. |
3602 loaded_.clear(); | 3617 loaded_.clear(); |
3603 service_->ReloadExtensions(); | 3618 service_->ReloadExtensions(); |
3604 | 3619 |
3605 // Extension counts shouldn't change. | 3620 // Extension counts shouldn't change. |
3606 EXPECT_EQ(1u, service_->extensions()->size()); | 3621 EXPECT_EQ(1u, service_->extensions()->size()); |
3607 EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 3622 EXPECT_EQ(0u, service_->disabled_extensions()->size()); |
3608 } | 3623 } |
3609 | 3624 |
| 3625 namespace { |
| 3626 std::vector<uint32> MessageTypes(const IPC::TestSink& sink) { |
| 3627 std::vector<uint32> message_types; |
| 3628 for (size_t i = 0; i < sink.message_count(); ++i) { |
| 3629 message_types.push_back(sink.GetMessageAt(i)->type()); |
| 3630 } |
| 3631 return message_types; |
| 3632 } |
| 3633 |
| 3634 struct ProcessObserver |
| 3635 : public content::MockRenderProcessHostFactory::Observer { |
| 3636 explicit ProcessObserver(content::MockRenderProcessHostFactory* factory) |
| 3637 : Observer(factory) {} |
| 3638 |
| 3639 ~ProcessObserver() { |
| 3640 for (size_t i = 0; i < hosts.size(); ++i) { |
| 3641 if (destroyed_processes.count(process_ids[i]) == 0) |
| 3642 hosts[i]->sink().RemoveFilter(process_messages[i]); |
| 3643 delete process_messages[i]; |
| 3644 } |
| 3645 } |
| 3646 |
| 3647 virtual void OnRenderProcessHostCreated( |
| 3648 content::MockRenderProcessHost* host) { |
| 3649 IPC::TestSink* sink = new IPC::TestSink; |
| 3650 hosts.push_back(host); |
| 3651 process_ids.push_back(host->GetID()); |
| 3652 process_messages.push_back(sink); |
| 3653 host->sink().AddFilter(sink); |
| 3654 } |
| 3655 virtual void OnRenderProcessHostDestroyed( |
| 3656 content::MockRenderProcessHost* host) { |
| 3657 destroyed_processes.insert(host->GetID()); |
| 3658 } |
| 3659 |
| 3660 std::vector<content::MockRenderProcessHost*> hosts; |
| 3661 std::vector<int> process_ids; |
| 3662 std::vector<IPC::TestSink*> process_messages; |
| 3663 std::set<int> destroyed_processes; |
| 3664 }; |
| 3665 } // namespace |
| 3666 |
3610 // Tests reloading an extension. | 3667 // Tests reloading an extension. |
3611 TEST_F(ExtensionServiceTest, ReloadExtension) { | 3668 TEST_F(ExtensionServiceTest, ReloadExtension) { |
| 3669 ProcessObserver observer(&rph_factory_); |
| 3670 |
| 3671 content::TestNotificationTracker notifications; |
| 3672 notifications.ListenForAll(chrome::NOTIFICATION_EXTENSIONS_READY); |
| 3673 notifications.ListenForAll(chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED); |
| 3674 notifications.ListenForAll(chrome::NOTIFICATION_EXTENSION_LOADED); |
| 3675 notifications.ListenForAll(chrome::NOTIFICATION_EXTENSION_UNLOADED); |
| 3676 notifications.ListenForAll(content::NOTIFICATION_RENDERER_PROCESS_CLOSING); |
| 3677 notifications.ListenForAll(content::NOTIFICATION_RENDERER_PROCESS_CREATED); |
| 3678 notifications.ListenForAll(content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); |
| 3679 notifications.ListenForAll( |
| 3680 content::NOTIFICATION_RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW); |
| 3681 |
3612 InitializeEmptyExtensionService(); | 3682 InitializeEmptyExtensionService(); |
3613 InitializeExtensionProcessManager(); | 3683 InitializeExtensionProcessManager(); |
| 3684 service_->Init(); |
| 3685 EXPECT_THAT(notifications.GetTypesAndReset(), |
| 3686 testing::ElementsAre(chrome::NOTIFICATION_EXTENSIONS_READY)); |
3614 | 3687 |
3615 // Simple extension that should install without error. | 3688 // Simple extension that should install without error. |
3616 const char* extension_id = "behllobkkfkfnphdnhnkndlbkcpglgmj"; | 3689 const char* extension_id = "behllobkkfkfnphdnhnkndlbkcpglgmj"; |
3617 base::FilePath ext = data_dir_ | 3690 base::FilePath ext = data_dir_ |
3618 .AppendASCII("good") | 3691 .AppendASCII("good") |
3619 .AppendASCII("Extensions") | 3692 .AppendASCII("Extensions") |
3620 .AppendASCII(extension_id) | 3693 .AppendASCII(extension_id) |
3621 .AppendASCII("1.0.0.0"); | 3694 .AppendASCII("1.0.0.0"); |
3622 extensions::UnpackedInstaller::Create(service_)->Load(ext); | 3695 extensions::UnpackedInstaller::Create(service_)->Load(ext); |
3623 loop_.RunUntilIdle(); | 3696 loop_.RunUntilIdle(); |
3624 | 3697 |
| 3698 EXPECT_THAT(notifications.GetTypesAndReset(), |
| 3699 testing::ElementsAre(chrome::NOTIFICATION_EXTENSION_LOADED)); |
| 3700 ASSERT_EQ(1u, observer.process_messages.size()); |
| 3701 { |
| 3702 testing::Matcher<uint32> expected_types[] = { |
| 3703 ExtensionMsg_Loaded::ID, |
| 3704 ExtensionMsg_ActivateExtension::ID, |
| 3705 ExtensionMsg_Loaded::ID, |
| 3706 ExtensionMsg_ActivateExtension::ID, |
| 3707 testing::_, // ViewMsg_New::ID, |
| 3708 testing::_, // ViewMsg_AllowBindings::ID, |
| 3709 ExtensionMsg_Loaded::ID, |
| 3710 ExtensionMsg_ActivateExtension::ID, |
| 3711 ExtensionMsg_NotifyRenderViewType::ID, |
| 3712 testing::_, // ViewMsg_Close::ID, |
| 3713 testing::_, // ViewMsg_Navigate::ID |
| 3714 }; |
| 3715 IPC::TestSink& sink = *observer.process_messages[0]; |
| 3716 EXPECT_THAT(MessageTypes(sink), testing::ElementsAreArray(expected_types)); |
| 3717 sink.ClearMessages(); |
| 3718 } |
| 3719 |
3625 EXPECT_EQ(1u, service_->extensions()->size()); | 3720 EXPECT_EQ(1u, service_->extensions()->size()); |
3626 EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 3721 EXPECT_EQ(0u, service_->disabled_extensions()->size()); |
3627 | 3722 |
3628 service_->ReloadExtension(extension_id); | 3723 service_->ReloadExtension(extension_id); |
3629 | 3724 |
| 3725 EXPECT_THAT(notifications.GetTypesAndReset(), |
| 3726 testing::ElementsAre( |
| 3727 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 3728 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 3729 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 3730 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED)); |
| 3731 |
| 3732 ASSERT_EQ(1u, observer.process_messages.size()); |
| 3733 EXPECT_THAT(MessageTypes(*observer.process_messages[0]), |
| 3734 testing::ElementsAre(testing::_ /*ViewMsg_Close::ID*/)); |
| 3735 observer.process_messages[0]->ClearMessages(); |
| 3736 |
3630 // Extension should be disabled now, waiting to be reloaded. | 3737 // Extension should be disabled now, waiting to be reloaded. |
3631 EXPECT_EQ(0u, service_->extensions()->size()); | 3738 EXPECT_EQ(0u, service_->extensions()->size()); |
3632 EXPECT_EQ(1u, service_->disabled_extensions()->size()); | 3739 EXPECT_EQ(1u, service_->disabled_extensions()->size()); |
3633 EXPECT_EQ(Extension::DISABLE_RELOAD, | 3740 EXPECT_EQ(Extension::DISABLE_RELOAD, |
3634 service_->extension_prefs()->GetDisableReasons(extension_id)); | 3741 service_->extension_prefs()->GetDisableReasons(extension_id)); |
3635 | 3742 |
3636 // Reloading again should not crash. | 3743 // Reloading again before iterating the MessageLoop should not crash and |
| 3744 // shouldn't cause an extra reload. |
3637 service_->ReloadExtension(extension_id); | 3745 service_->ReloadExtension(extension_id); |
| 3746 EXPECT_THAT(notifications.GetTypesAndReset(), |
| 3747 testing::ElementsAre()); |
| 3748 ASSERT_EQ(1u, observer.process_messages.size()); |
| 3749 EXPECT_THAT(MessageTypes(*observer.process_messages[0]), |
| 3750 testing::ElementsAre()); |
| 3751 observer.process_messages[0]->ClearMessages(); |
3638 | 3752 |
3639 // Finish reloading | 3753 // Finish reloading |
3640 loop_.RunUntilIdle(); | 3754 loop_.RunUntilIdle(); |
3641 | 3755 |
| 3756 EXPECT_THAT(notifications.GetTypesAndReset(), |
| 3757 testing::ElementsAre( |
| 3758 chrome::NOTIFICATION_EXTENSION_LOADED, |
| 3759 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 3760 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 3761 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 3762 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 3763 chrome::NOTIFICATION_EXTENSION_LOADED)); |
| 3764 |
| 3765 ASSERT_EQ(3u, observer.process_messages.size()); |
| 3766 EXPECT_THAT(observer.destroyed_processes, |
| 3767 testing::ElementsAre(observer.process_ids[0], |
| 3768 observer.process_ids[1])); |
| 3769 EXPECT_THAT(MessageTypes(*observer.process_messages[0]), |
| 3770 testing::ElementsAre()); |
| 3771 observer.process_messages[0]->ClearMessages(); |
| 3772 { |
| 3773 testing::Matcher<uint32> expected_types[] = { |
| 3774 ExtensionMsg_Loaded::ID, |
| 3775 ExtensionMsg_ActivateExtension::ID, |
| 3776 ExtensionMsg_Loaded::ID, |
| 3777 ExtensionMsg_ActivateExtension::ID, |
| 3778 testing::_, // ViewMsg_New::ID, |
| 3779 testing::_, // ViewMsg_AllowBindings::ID, |
| 3780 ExtensionMsg_Loaded::ID, |
| 3781 ExtensionMsg_ActivateExtension::ID, |
| 3782 ExtensionMsg_NotifyRenderViewType::ID, |
| 3783 testing::_, // ViewMsg_Close::ID, |
| 3784 testing::_, // ViewMsg_Navigate::ID, |
| 3785 testing::_, // ViewMsg_Close::ID |
| 3786 }; |
| 3787 EXPECT_THAT(MessageTypes(*observer.process_messages[1]), |
| 3788 testing::ElementsAreArray(expected_types)); |
| 3789 observer.process_messages[1]->ClearMessages(); |
| 3790 } |
| 3791 { |
| 3792 testing::Matcher<uint32> expected_types[] = { |
| 3793 ExtensionMsg_Loaded::ID, |
| 3794 ExtensionMsg_ActivateExtension::ID, |
| 3795 ExtensionMsg_Loaded::ID, |
| 3796 ExtensionMsg_ActivateExtension::ID, |
| 3797 testing::_, // ViewMsg_New::ID |
| 3798 testing::_, // ViewMsg_AllowBindings::ID, |
| 3799 ExtensionMsg_Loaded::ID, |
| 3800 ExtensionMsg_ActivateExtension::ID, |
| 3801 ExtensionMsg_NotifyRenderViewType::ID, |
| 3802 testing::_, // ViewMsg_Close::ID, |
| 3803 testing::_, // ViewMsg_Navigate::ID |
| 3804 }; |
| 3805 EXPECT_THAT(MessageTypes(*observer.process_messages[2]), |
| 3806 testing::ElementsAreArray(expected_types)); |
| 3807 observer.process_messages[2]->ClearMessages(); |
| 3808 } |
| 3809 |
3642 // Extension should be enabled again. | 3810 // Extension should be enabled again. |
3643 EXPECT_EQ(1u, service_->extensions()->size()); | 3811 EXPECT_EQ(1u, service_->extensions()->size()); |
3644 EXPECT_EQ(0u, service_->disabled_extensions()->size()); | 3812 EXPECT_EQ(0u, service_->disabled_extensions()->size()); |
3645 } | 3813 } |
3646 | 3814 |
3647 TEST_F(ExtensionServiceTest, UninstallExtension) { | 3815 TEST_F(ExtensionServiceTest, UninstallExtension) { |
3648 InitializeEmptyExtensionService(); | 3816 InitializeEmptyExtensionService(); |
3649 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); | 3817 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); |
3650 EXPECT_EQ(1u, service_->extensions()->size()); | 3818 EXPECT_EQ(1u, service_->extensions()->size()); |
3651 UninstallExtension(good_crx, false); | 3819 UninstallExtension(good_crx, false); |
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5901 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); | 6069 EXPECT_FALSE(extensions::HasExternalInstallError(service_)); |
5902 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); | 6070 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); |
5903 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); | 6071 EXPECT_TRUE(service_->IsExtensionEnabled(page_action)); |
5904 | 6072 |
5905 ExtensionPrefs* prefs = service_->extension_prefs(); | 6073 ExtensionPrefs* prefs = service_->extension_prefs(); |
5906 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) & | 6074 EXPECT_NE(0, prefs->GetDisableReasons(good_crx) & |
5907 Extension::DISABLE_SIDELOAD_WIPEOUT); | 6075 Extension::DISABLE_SIDELOAD_WIPEOUT); |
5908 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) & | 6076 EXPECT_EQ(0, prefs->GetDisableReasons(page_action) & |
5909 Extension::DISABLE_SIDELOAD_WIPEOUT); | 6077 Extension::DISABLE_SIDELOAD_WIPEOUT); |
5910 } | 6078 } |
OLD | NEW |