Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/message_loop/message_loop_proxy.h" | |
|
bartfab (slow)
2014/12/04 13:53:01
Nit: You do not need this include. You never deref
binjin
2014/12/04 15:43:15
Done. It's needed in previous patchset and I forge
| |
| 18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 19 #include "base/prefs/pref_service.h" | 20 #include "base/prefs/pref_service.h" |
| 20 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
| 21 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 24 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 25 #include "base/test/test_file_util.h" | 26 #include "base/test/test_file_util.h" |
| 26 #include "base/threading/sequenced_worker_pool.h" | 27 #include "base/threading/sequenced_worker_pool.h" |
| 27 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 28 #include "base/values.h" | 29 #include "base/values.h" |
| 29 #include "chrome/app/chrome_command_ids.h" | 30 #include "chrome/app/chrome_command_ids.h" |
| 30 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 31 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 31 #include "chrome/browser/background/background_contents_service.h" | 32 #include "chrome/browser/background/background_contents_service.h" |
| 32 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
| 33 #include "chrome/browser/chrome_notification_types.h" | 34 #include "chrome/browser/chrome_notification_types.h" |
| 34 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 35 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 35 #include "chrome/browser/devtools/devtools_window_testing.h" | 36 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 36 #include "chrome/browser/download/download_prefs.h" | 37 #include "chrome/browser/download/download_prefs.h" |
| 37 #include "chrome/browser/extensions/api/messaging/message_service.h" | 38 #include "chrome/browser/extensions/api/messaging/message_service.h" |
| 38 #include "chrome/browser/extensions/crx_installer.h" | 39 #include "chrome/browser/extensions/crx_installer.h" |
| 39 #include "chrome/browser/extensions/extension_management_constants.h" | 40 #include "chrome/browser/extensions/extension_management_constants.h" |
| 41 #include "chrome/browser/extensions/extension_management_test_util.h" | |
| 40 #include "chrome/browser/extensions/extension_service.h" | 42 #include "chrome/browser/extensions/extension_service.h" |
| 41 #include "chrome/browser/extensions/shared_module_service.h" | 43 #include "chrome/browser/extensions/shared_module_service.h" |
| 42 #include "chrome/browser/extensions/unpacked_installer.h" | 44 #include "chrome/browser/extensions/unpacked_installer.h" |
| 43 #include "chrome/browser/extensions/updater/extension_cache_fake.h" | 45 #include "chrome/browser/extensions/updater/extension_cache_fake.h" |
| 44 #include "chrome/browser/extensions/updater/extension_updater.h" | 46 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 45 #include "chrome/browser/infobars/infobar_service.h" | 47 #include "chrome/browser/infobars/infobar_service.h" |
| 46 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 48 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 47 #include "chrome/browser/media/media_stream_devices_controller.h" | 49 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 48 #include "chrome/browser/metrics/variations/variations_service.h" | 50 #include "chrome/browser/metrics/variations/variations_service.h" |
| 49 #include "chrome/browser/net/prediction_options.h" | 51 #include "chrome/browser/net/prediction_options.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 #include "content/public/common/process_type.h" | 124 #include "content/public/common/process_type.h" |
| 123 #include "content/public/common/result_codes.h" | 125 #include "content/public/common/result_codes.h" |
| 124 #include "content/public/common/url_constants.h" | 126 #include "content/public/common/url_constants.h" |
| 125 #include "content/public/common/webplugininfo.h" | 127 #include "content/public/common/webplugininfo.h" |
| 126 #include "content/public/test/browser_test_utils.h" | 128 #include "content/public/test/browser_test_utils.h" |
| 127 #include "content/public/test/download_test_observer.h" | 129 #include "content/public/test/download_test_observer.h" |
| 128 #include "content/public/test/mock_notification_observer.h" | 130 #include "content/public/test/mock_notification_observer.h" |
| 129 #include "content/public/test/test_navigation_observer.h" | 131 #include "content/public/test/test_navigation_observer.h" |
| 130 #include "content/public/test/test_utils.h" | 132 #include "content/public/test/test_utils.h" |
| 131 #include "extensions/browser/extension_host.h" | 133 #include "extensions/browser/extension_host.h" |
| 134 #include "extensions/browser/extension_prefs.h" | |
| 132 #include "extensions/browser/extension_registry.h" | 135 #include "extensions/browser/extension_registry.h" |
| 133 #include "extensions/browser/extension_system.h" | 136 #include "extensions/browser/extension_system.h" |
| 134 #include "extensions/browser/process_manager.h" | 137 #include "extensions/browser/process_manager.h" |
| 135 #include "extensions/browser/test_extension_registry_observer.h" | 138 #include "extensions/browser/test_extension_registry_observer.h" |
| 136 #include "extensions/browser/uninstall_reason.h" | 139 #include "extensions/browser/uninstall_reason.h" |
| 137 #include "extensions/common/constants.h" | 140 #include "extensions/common/constants.h" |
| 138 #include "extensions/common/extension.h" | 141 #include "extensions/common/extension.h" |
| 139 #include "extensions/common/extension_set.h" | 142 #include "extensions/common/extension_set.h" |
| 140 #include "extensions/common/manifest_handlers/shared_module_info.h" | 143 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 141 #include "net/base/net_errors.h" | 144 #include "net/base/net_errors.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 FILE_PATH_LITERAL("hosted_app.crx"); | 212 FILE_PATH_LITERAL("hosted_app.crx"); |
| 210 | 213 |
| 211 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 214 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; |
| 212 const char kAdBlockCrxId[] = "dojnnbeimaimaojcialkkgajdnefpgcn"; | 215 const char kAdBlockCrxId[] = "dojnnbeimaimaojcialkkgajdnefpgcn"; |
| 213 const char kHostedAppCrxId[] = "kbmnembihfiondgfjekmnmcbddelicoi"; | 216 const char kHostedAppCrxId[] = "kbmnembihfiondgfjekmnmcbddelicoi"; |
| 214 | 217 |
| 215 const base::FilePath::CharType kGood2CrxManifestName[] = | 218 const base::FilePath::CharType kGood2CrxManifestName[] = |
| 216 FILE_PATH_LITERAL("good2_update_manifest.xml"); | 219 FILE_PATH_LITERAL("good2_update_manifest.xml"); |
| 217 const base::FilePath::CharType kGoodV1CrxManifestName[] = | 220 const base::FilePath::CharType kGoodV1CrxManifestName[] = |
| 218 FILE_PATH_LITERAL("good_v1_update_manifest.xml"); | 221 FILE_PATH_LITERAL("good_v1_update_manifest.xml"); |
| 222 const base::FilePath::CharType kGoodV1CrxName[] = | |
| 223 FILE_PATH_LITERAL("good_v1.crx"); | |
| 219 const base::FilePath::CharType kGoodUnpackedExt[] = | 224 const base::FilePath::CharType kGoodUnpackedExt[] = |
| 220 FILE_PATH_LITERAL("good_unpacked"); | 225 FILE_PATH_LITERAL("good_unpacked"); |
| 221 const base::FilePath::CharType kAppUnpackedExt[] = | 226 const base::FilePath::CharType kAppUnpackedExt[] = |
| 222 FILE_PATH_LITERAL("app"); | 227 FILE_PATH_LITERAL("app"); |
| 223 | 228 |
| 224 #if !defined(OS_MACOSX) | 229 #if !defined(OS_MACOSX) |
| 225 const base::FilePath::CharType kUnpackedFullscreenAppName[] = | 230 const base::FilePath::CharType kUnpackedFullscreenAppName[] = |
| 226 FILE_PATH_LITERAL("fullscreen_app"); | 231 FILE_PATH_LITERAL("fullscreen_app"); |
| 227 #endif // !defined(OS_MACOSX) | 232 #endif // !defined(OS_MACOSX) |
| 228 | 233 |
| (...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1950 observer.Wait(); | 1955 observer.Wait(); |
| 1951 // Note: Cannot check that the notification details match the expected | 1956 // Note: Cannot check that the notification details match the expected |
| 1952 // exception, since the details object has already been freed prior to | 1957 // exception, since the details object has already been freed prior to |
| 1953 // the completion of observer.Wait(). | 1958 // the completion of observer.Wait(). |
| 1954 | 1959 |
| 1955 // The first extension shouldn't be present, the second should be there. | 1960 // The first extension shouldn't be present, the second should be there. |
| 1956 EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true)); | 1961 EXPECT_FALSE(extension_service()->GetExtensionById(kGoodCrxId, true)); |
| 1957 EXPECT_TRUE(extension_service()->GetExtensionById(kAdBlockCrxId, false)); | 1962 EXPECT_TRUE(extension_service()->GetExtensionById(kAdBlockCrxId, false)); |
| 1958 } | 1963 } |
| 1959 | 1964 |
| 1965 // Verifies that extensions with version older than minimum version required by | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/than/than the/
binjin
2014/12/04 15:43:15
Done.
| |
| 1966 // policy will get disabled, and will be auto-updated and/or re-enabled upon | |
| 1967 // policy changes as well as regular auto-updater scheduled updates. | |
| 1968 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionMinimumVersionRequired) { | |
| 1969 ExtensionService* service = extension_service(); | |
| 1970 extensions::ExtensionRegistry* registry = | |
| 1971 extensions::ExtensionRegistry::Get(browser()->profile()); | |
| 1972 extensions::ExtensionPrefs* extension_prefs = | |
| 1973 extensions::ExtensionPrefs::Get(browser()->profile()); | |
| 1974 | |
| 1975 // Explicitly stop the timer to avoid all scheduled extension auto-updates. | |
| 1976 service->updater()->StopTimerForTesting(); | |
| 1977 | |
| 1978 // Setup interceptor for extension updates. | |
| 1979 base::FilePath test_path; | |
| 1980 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_path)); | |
| 1981 TestRequestInterceptor interceptor( | |
| 1982 "update.extension", | |
| 1983 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 1984 interceptor.PushJobCallback(TestRequestInterceptor::BadRequestJob()); | |
| 1985 interceptor.PushJobCallback(TestRequestInterceptor::FileJob( | |
| 1986 test_path.Append(kTestExtensionsDir).Append(kGood2CrxManifestName))); | |
| 1987 | |
| 1988 // Install the extension. | |
| 1989 ASSERT_TRUE(InstallExtension(kGoodV1CrxName)); | |
|
bartfab (slow)
2014/12/04 13:53:01
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:14
Done.
| |
| 1990 ASSERT_TRUE(registry->enabled_extensions().Contains(kGoodCrxId)); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 1991 | |
| 1992 // Update policy to set a minimum version of 1.0.0.0, the extension (with | |
| 1993 // version 1.0.0.0) should still be enabled. | |
| 1994 { | |
| 1995 extensions::ExtensionManagementPolicyUpdater management_policy(&provider_); | |
| 1996 management_policy.SetMinimumVersionRequired(kGoodCrxId, "1.0.0.0"); | |
| 1997 } | |
| 1998 base::RunLoop().RunUntilIdle(); | |
| 1999 | |
| 2000 ASSERT_TRUE(registry->enabled_extensions().Contains(kGoodCrxId)); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 2001 | |
| 2002 // Update policy to set a minimum version of 1.0.0.1, the extension (with | |
| 2003 // version 1.0.0.0) should now be disabled. | |
| 2004 ASSERT_EQ(2u, interceptor.GetPendingSize()); | |
|
bartfab (slow)
2014/12/04 13:53:01
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 2005 base::RunLoop service_request_run_loop; | |
| 2006 interceptor.AddRequestServicedCallback( | |
| 2007 service_request_run_loop.QuitClosure()); | |
| 2008 { | |
| 2009 extensions::ExtensionManagementPolicyUpdater management_policy(&provider_); | |
| 2010 management_policy.SetMinimumVersionRequired(kGoodCrxId, "1.0.0.1"); | |
| 2011 } | |
| 2012 service_request_run_loop.Run(); | |
| 2013 ASSERT_EQ(1u, interceptor.GetPendingSize()); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 2014 | |
| 2015 ASSERT_TRUE(registry->disabled_extensions().Contains(kGoodCrxId)); | |
|
bartfab (slow)
2014/12/04 13:53:01
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 2016 EXPECT_EQ(extensions::Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY, | |
| 2017 extension_prefs->GetDisableReasons(kGoodCrxId)); | |
| 2018 | |
| 2019 // Provide a new version (1.0.0.1) which is expected to be auto updated to | |
| 2020 // via update URL in the manifest of the older version. | |
|
bartfab (slow)
2014/12/04 13:53:01
Nit: s/via/via the/
binjin
2014/12/04 15:43:15
Done.
| |
| 2021 ASSERT_EQ(1u, interceptor.GetPendingSize()); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 2022 { | |
| 2023 content::WindowedNotificationObserver update_observer( | |
| 2024 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | |
| 2025 content::NotificationService::AllSources()); | |
| 2026 service->updater()->CheckSoon(); | |
| 2027 update_observer.Wait(); | |
| 2028 } | |
| 2029 ASSERT_EQ(0u, interceptor.GetPendingSize()); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 2030 | |
| 2031 // The extension should be auto-updated to newer version and re-enabled. | |
| 2032 EXPECT_EQ("1.0.0.1", | |
| 2033 service->GetInstalledExtension(kGoodCrxId)->version()->GetString()); | |
| 2034 EXPECT_TRUE(registry->enabled_extensions().Contains(kGoodCrxId)); | |
| 2035 } | |
| 2036 | |
| 2037 // Similar to ExtensionMinimumVersionRequired test, but with different settings | |
| 2038 // and orders. | |
| 2039 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionMinimumVersionRequiredAlt) { | |
| 2040 ExtensionService* service = extension_service(); | |
| 2041 extensions::ExtensionRegistry* registry = | |
| 2042 extensions::ExtensionRegistry::Get(browser()->profile()); | |
| 2043 extensions::ExtensionPrefs* extension_prefs = | |
| 2044 extensions::ExtensionPrefs::Get(browser()->profile()); | |
| 2045 | |
| 2046 // Explicitly stop the timer to avoid all scheduled extension auto-updates. | |
| 2047 service->updater()->StopTimerForTesting(); | |
| 2048 | |
| 2049 // Setup interceptor for extension updates. | |
| 2050 base::FilePath test_path; | |
| 2051 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_path)); | |
| 2052 TestRequestInterceptor interceptor( | |
| 2053 "update.extension", | |
| 2054 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 2055 interceptor.PushJobCallback(TestRequestInterceptor::FileJob( | |
| 2056 test_path.Append(kTestExtensionsDir).Append(kGood2CrxManifestName))); | |
| 2057 | |
| 2058 // Set the policy to require an even higher minimum version this time. | |
| 2059 { | |
| 2060 extensions::ExtensionManagementPolicyUpdater management_policy(&provider_); | |
| 2061 management_policy.SetMinimumVersionRequired(kGoodCrxId, "1.0.0.2"); | |
| 2062 } | |
| 2063 base::RunLoop().RunUntilIdle(); | |
| 2064 | |
| 2065 // Install the 1.0.0.0 version, it should be installed but disabled. | |
| 2066 ASSERT_TRUE(InstallExtension(kGoodV1CrxName)); | |
|
bartfab (slow)
2014/12/04 13:53:01
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 2067 ASSERT_TRUE(registry->disabled_extensions().Contains(kGoodCrxId)); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:14
Done.
| |
| 2068 EXPECT_EQ(extensions::Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY, | |
| 2069 extension_prefs->GetDisableReasons(kGoodCrxId)); | |
| 2070 EXPECT_EQ("1.0.0.0", | |
| 2071 service->GetInstalledExtension(kGoodCrxId)->version()->GetString()); | |
| 2072 | |
| 2073 // An extension management policy update should trigger an update as well. | |
| 2074 ASSERT_EQ(1u, interceptor.GetPendingSize()); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
| |
| 2075 { | |
| 2076 content::WindowedNotificationObserver update_observer( | |
| 2077 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | |
| 2078 content::NotificationService::AllSources()); | |
| 2079 { | |
| 2080 // Set a higher minimum version, just intend to trigger an policy update. | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/an/a/
binjin
2014/12/04 15:43:14
Done.
| |
| 2081 extensions::ExtensionManagementPolicyUpdater management_policy( | |
| 2082 &provider_); | |
| 2083 management_policy.SetMinimumVersionRequired(kGoodCrxId, "1.0.0.3"); | |
| 2084 } | |
| 2085 base::RunLoop().RunUntilIdle(); | |
| 2086 update_observer.Wait(); | |
| 2087 } | |
| 2088 ASSERT_EQ(0u, interceptor.GetPendingSize()); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:14
Done.
| |
| 2089 | |
| 2090 // It should be updated to 1.0.0.1 but remain disabled. | |
| 2091 EXPECT_EQ("1.0.0.1", | |
| 2092 service->GetInstalledExtension(kGoodCrxId)->version()->GetString()); | |
| 2093 EXPECT_TRUE(registry->disabled_extensions().Contains(kGoodCrxId)); | |
| 2094 EXPECT_EQ(extensions::Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY, | |
| 2095 extension_prefs->GetDisableReasons(kGoodCrxId)); | |
| 2096 | |
| 2097 // Remove the minimum version requirement, it should be re-enabled. | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/, it/. The extension/
binjin
2014/12/04 15:43:15
Done.
| |
| 2098 { | |
| 2099 extensions::ExtensionManagementPolicyUpdater management_policy(&provider_); | |
| 2100 management_policy.UnsetMinimumVersionRequired(kGoodCrxId); | |
| 2101 } | |
| 2102 base::RunLoop().RunUntilIdle(); | |
| 2103 | |
| 2104 EXPECT_TRUE(registry->enabled_extensions().Contains(kGoodCrxId)); | |
| 2105 EXPECT_FALSE(extension_prefs->HasDisableReason( | |
| 2106 kGoodCrxId, extensions::Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY)); | |
| 2107 } | |
| 2108 | |
| 2109 // Verifies that force installed missing the minimum version requirement is | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/force installed missing the/a force-install
| |
| 2110 // handled well. | |
| 2111 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionMinimumVersionForceInstalled) { | |
| 2112 extensions::ExtensionRegistry* registry = | |
| 2113 extensions::ExtensionRegistry::Get(browser()->profile()); | |
| 2114 extensions::ExtensionPrefs* extension_prefs = | |
| 2115 extensions::ExtensionPrefs::Get(browser()->profile()); | |
| 2116 | |
| 2117 // Prepare the update URL for force installing. | |
| 2118 base::FilePath path = | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: const.
binjin
2014/12/04 15:43:14
Done.
| |
| 2119 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); | |
| 2120 GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: const.
binjin
2014/12/04 15:43:15
Done.
| |
| 2121 | |
| 2122 // Set policy to force install the extension, it should be installed and | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/force /force-/
binjin
2014/12/04 15:43:15
Done.
| |
| 2123 // enabled. | |
| 2124 content::WindowedNotificationObserver install_observer( | |
| 2125 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | |
| 2126 content::NotificationService::AllSources()); | |
| 2127 ASSERT_FALSE(registry->enabled_extensions().Contains(kGoodCrxId)); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:15
Done.
binjin
2014/12/04 15:43:15
Done.
| |
| 2128 { | |
| 2129 extensions::ExtensionManagementPolicyUpdater management_policy(&provider_); | |
| 2130 management_policy.SetIndividualExtensionAutoInstalled(kGoodCrxId, | |
| 2131 url.spec(), true); | |
| 2132 } | |
| 2133 base::RunLoop().RunUntilIdle(); | |
| 2134 install_observer.Wait(); | |
| 2135 | |
| 2136 ASSERT_TRUE(registry->enabled_extensions().Contains(kGoodCrxId)); | |
|
bartfab (slow)
2014/12/04 13:53:00
Nit: s/ASSERT/EXPECT/
binjin
2014/12/04 15:43:14
Done.
| |
| 2137 | |
| 2138 // Set policy a minimum version of "1.0.0.1", the extension now should be | |
| 2139 // disabled. | |
| 2140 { | |
| 2141 extensions::ExtensionManagementPolicyUpdater management_policy(&provider_); | |
| 2142 management_policy.SetMinimumVersionRequired(kGoodCrxId, "1.0.0.1"); | |
| 2143 } | |
| 2144 base::RunLoop().RunUntilIdle(); | |
| 2145 EXPECT_FALSE(registry->enabled_extensions().Contains(kGoodCrxId)); | |
| 2146 EXPECT_TRUE(registry->disabled_extensions().Contains(kGoodCrxId)); | |
| 2147 EXPECT_EQ(extensions::Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY, | |
| 2148 extension_prefs->GetDisableReasons(kGoodCrxId)); | |
| 2149 } | |
| 2150 | |
| 1960 IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) { | 2151 IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) { |
| 1961 #if defined(OS_WIN) && defined(USE_ASH) | 2152 #if defined(OS_WIN) && defined(USE_ASH) |
| 1962 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 2153 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 1963 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 2154 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 1964 return; | 2155 return; |
| 1965 #endif | 2156 #endif |
| 1966 | 2157 |
| 1967 // Verifies that the homepage can be configured with policies. | 2158 // Verifies that the homepage can be configured with policies. |
| 1968 // Set a default, and check that the home button navigates there. | 2159 // Set a default, and check that the home button navigates there. |
| 1969 browser()->profile()->GetPrefs()->SetString( | 2160 browser()->profile()->GetPrefs()->SetString( |
| (...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3428 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 3619 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 3429 browser2->tab_strip_model()->GetActiveWebContents(), | 3620 browser2->tab_strip_model()->GetActiveWebContents(), |
| 3430 "domAutomationController.send(window.showModalDialog !== undefined);", | 3621 "domAutomationController.send(window.showModalDialog !== undefined);", |
| 3431 &result)); | 3622 &result)); |
| 3432 EXPECT_TRUE(result); | 3623 EXPECT_TRUE(result); |
| 3433 } | 3624 } |
| 3434 | 3625 |
| 3435 #endif // !defined(CHROME_OS) | 3626 #endif // !defined(CHROME_OS) |
| 3436 | 3627 |
| 3437 } // namespace policy | 3628 } // namespace policy |
| OLD | NEW |