| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <list> | 5 #include <list> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 700 |
| 701 protected: | 701 protected: |
| 702 // The id of the extension we want to have force-installed. | 702 // The id of the extension we want to have force-installed. |
| 703 std::string id_ = "npnbmohejbjohgpjnmjagbafnjhkmgko"; | 703 std::string id_ = "npnbmohejbjohgpjnmjagbafnjhkmgko"; |
| 704 | 704 |
| 705 private: | 705 private: |
| 706 policy::MockConfigurationPolicyProvider policy_provider_; | 706 policy::MockConfigurationPolicyProvider policy_provider_; |
| 707 DownloaderTestDelegate downloader_; | 707 DownloaderTestDelegate downloader_; |
| 708 }; | 708 }; |
| 709 | 709 |
| 710 // Disabled due to flakiness (crbug.com/668067) | |
| 711 // We want to test what happens at startup with a corroption-disabled policy | 710 // We want to test what happens at startup with a corroption-disabled policy |
| 712 // force installed extension. So we set that up in the PRE test here. | 711 // force installed extension. So we set that up in the PRE test here. |
| 713 IN_PROC_BROWSER_TEST_F(ContentVerifierPolicyTest, | 712 IN_PROC_BROWSER_TEST_F(ContentVerifierPolicyTest, |
| 714 DISABLED_PRE_PolicyCorruptedOnStartup) { | 713 PRE_PolicyCorruptedOnStartup) { |
| 715 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 714 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 716 RegistryObserver registry_observer(registry); | 715 RegistryObserver registry_observer(registry); |
| 717 | 716 |
| 718 // Wait for the extension to be installed by policy we set up in | 717 // Wait for the extension to be installed by policy we set up in |
| 719 // SetUpInProcessBrowserTestFixture. | 718 // SetUpInProcessBrowserTestFixture. |
| 720 if (!registry->GetInstalledExtension(id_)) { | 719 if (!registry->GetInstalledExtension(id_)) { |
| 721 EXPECT_TRUE(registry_observer.WaitForInstall(id_)); | 720 EXPECT_TRUE(registry_observer.WaitForInstall(id_)); |
| 722 } | 721 } |
| 723 | 722 |
| 724 // Simulate corruption of the extension so that we can test what happens | 723 // Simulate corruption of the extension so that we can test what happens |
| 725 // at startup in the non-PRE test. | 724 // at startup in the non-PRE test. |
| 726 ExtensionSystem* system = ExtensionSystem::Get(profile()); | 725 ExtensionSystem* system = ExtensionSystem::Get(profile()); |
| 727 ContentVerifier* verifier = system->content_verifier(); | 726 ContentVerifier* verifier = system->content_verifier(); |
| 728 verifier->VerifyFailed(id_, ContentVerifyJob::HASH_MISMATCH); | 727 verifier->VerifyFailed(id_, ContentVerifyJob::HASH_MISMATCH); |
| 729 EXPECT_TRUE(registry_observer.WaitForUnload(id_)); | 728 EXPECT_TRUE(registry_observer.WaitForUnload(id_)); |
| 730 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 729 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
| 731 int reasons = prefs->GetDisableReasons(id_); | 730 int reasons = prefs->GetDisableReasons(id_); |
| 732 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED); | 731 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED); |
| 733 } | 732 } |
| 734 | 733 |
| 735 // Disabled due to flakiness (crbug.com/668067) | |
| 736 // Now actually test what happens on the next startup after the PRE test above. | 734 // Now actually test what happens on the next startup after the PRE test above. |
| 737 IN_PROC_BROWSER_TEST_F(ContentVerifierPolicyTest, | 735 IN_PROC_BROWSER_TEST_F(ContentVerifierPolicyTest, PolicyCorruptedOnStartup) { |
| 738 DISABLED_PolicyCorruptedOnStartup) { | 736 // Depdending on timing, the extension may have already been reinstalled |
| 739 // Expect that the extension is still disabled for corruption. | 737 // between SetUpInProcessBrowserTestFixture and now (usually not during local |
| 738 // testing on a developer machine, but sometimes on a heavily loaded system |
| 739 // such as the build waterfall / trybots). If the reinstall didn't already |
| 740 // happen, wait for it. |
| 740 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 741 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
| 741 int reasons = prefs->GetDisableReasons(id_); | |
| 742 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED); | |
| 743 | |
| 744 // Now expect that it gets reinstalled (because a job should have been kicked | |
| 745 // off by the installed extension loading code). | |
| 746 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 742 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 747 RegistryObserver registry_observer(registry); | 743 int disable_reasons = prefs->GetDisableReasons(id_); |
| 748 EXPECT_TRUE(registry_observer.WaitForInstall(id_)); | 744 if (disable_reasons & Extension::DISABLE_CORRUPTED) { |
| 749 reasons = prefs->GetDisableReasons(id_); | 745 RegistryObserver registry_observer(registry); |
| 750 EXPECT_FALSE(reasons & Extension::DISABLE_CORRUPTED); | 746 EXPECT_TRUE(registry_observer.WaitForInstall(id_)); |
| 747 disable_reasons = prefs->GetDisableReasons(id_); |
| 748 } |
| 749 EXPECT_FALSE(disable_reasons & Extension::DISABLE_CORRUPTED); |
| 750 EXPECT_TRUE(registry->enabled_extensions().Contains(id_)); |
| 751 } | 751 } |
| 752 | 752 |
| 753 } // namespace extensions | 753 } // namespace extensions |
| OLD | NEW |