[email protected] | 4d245165 | 2012-02-14 23:54:26 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 038d52e1 | 2009-10-14 16:53:41 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame^] | 5 | #include <stddef.h> |
| 6 | #include <stdint.h> |
| 7 | |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
brettw | f195891 | 2015-10-07 19:43:12 | [diff] [blame] | 10 | #include "base/base_switches.h" |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 11 | #include "base/command_line.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 12 | #include "base/files/file_path.h" |
thestig | 18dfb7a5 | 2014-08-26 10:44:04 | [diff] [blame] | 13 | #include "base/files/file_util.h" |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 14 | #include "base/path_service.h" |
[email protected] | 00e7bef | 2013-06-10 20:35:17 | [diff] [blame] | 15 | #include "base/strings/string_util.h" |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 16 | #include "base/strings/stringprintf.h" |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame^] | 17 | #include "build/build_config.h" |
[email protected] | 9ea0cd3 | 2013-07-12 01:50:36 | [diff] [blame] | 18 | #include "chrome/browser/chrome_notification_types.h" |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 19 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | a7ff4b7 | 2013-10-17 20:56:02 | [diff] [blame] | 20 | #include "chrome/browser/extensions/extension_util.h" |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 21 | #include "chrome/browser/extensions/shared_user_script_master.h" |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 22 | #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 23 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 7b5dc00 | 2010-11-16 23:08:10 | [diff] [blame] | 24 | #include "chrome/browser/ui/browser.h" |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 25 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | e96a060 | 2014-02-15 08:27:42 | [diff] [blame] | 26 | #include "chrome/common/chrome_constants.h" |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 27 | #include "chrome/common/chrome_paths.h" |
| 28 | #include "chrome/common/chrome_switches.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 29 | #include "chrome/test/base/in_process_browser_test.h" |
[email protected] | 89dbb177 | 2012-07-17 13:47:25 | [diff] [blame] | 30 | #include "chrome/test/base/testing_profile.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 31 | #include "chrome/test/base/ui_test_utils.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 32 | #include "content/public/browser/notification_details.h" |
[email protected] | ad50def5 | 2011-10-19 23:17:07 | [diff] [blame] | 33 | #include "content/public/browser/notification_service.h" |
[email protected] | 4ca1530 | 2012-01-03 05:53:20 | [diff] [blame] | 34 | #include "content/public/browser/web_contents.h" |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 35 | #include "content/public/common/content_switches.h" |
[email protected] | 7d478cb | 2012-07-24 17:19:42 | [diff] [blame] | 36 | #include "content/public/test/browser_test_utils.h" |
[email protected] | 1d5cf414 | 2014-01-24 18:25:22 | [diff] [blame] | 37 | #include "extensions/browser/extension_registry.h" |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 38 | #include "extensions/browser/extension_system.h" |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame] | 39 | #include "extensions/common/extension.h" |
| 40 | #include "extensions/common/extension_set.h" |
[email protected] | 5ef835a | 2013-11-08 20:42:57 | [diff] [blame] | 41 | #include "extensions/common/feature_switch.h" |
[email protected] | d96cf75 | 2014-04-09 04:05:28 | [diff] [blame] | 42 | #include "net/base/filename_util.h" |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 43 | |
[email protected] | 00b5d0a5 | 2012-10-30 13:13:53 | [diff] [blame] | 44 | using extensions::FeatureSwitch; |
| 45 | |
[email protected] | 17c4f3c | 2009-07-04 16:36:25 | [diff] [blame] | 46 | // This file contains high-level startup tests for the extensions system. We've |
| 47 | // had many silly bugs where command line flags did not get propagated correctly |
| 48 | // into the services, so we didn't start correctly. |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 49 | |
[email protected] | 3e59bac | 2010-04-08 16:16:55 | [diff] [blame] | 50 | class ExtensionStartupTestBase : public InProcessBrowserTest { |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 51 | public: |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 52 | ExtensionStartupTestBase() : unauthenticated_load_allowed_(true) { |
[email protected] | fe13bf6 | 2010-08-26 14:33:19 | [diff] [blame] | 53 | num_expected_extensions_ = 3; |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | protected: |
| 57 | // InProcessBrowserTest |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 58 | void SetUpCommandLine(base::CommandLine* command_line) override { |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 59 | if (load_extensions_.empty()) { |
| 60 | // If no |load_extensions_| were specified, allow unauthenticated |
| 61 | // extension settings to be loaded from Preferences as if they had been |
| 62 | // authenticated correctly before they were handed to the ExtensionSystem. |
| 63 | command_line->AppendSwitchASCII( |
| 64 | switches::kForceFieldTrials, |
| 65 | base::StringPrintf( |
| 66 | "%s/%s/", |
| 67 | chrome_prefs::internals::kSettingsEnforcementTrialName, |
| 68 | chrome_prefs::internals::kSettingsEnforcementGroupNoEnforcement)); |
[email protected] | 337695e | 2014-04-17 03:55:49 | [diff] [blame] | 69 | #if defined(OFFICIAL_BUILD) && defined(OS_WIN) |
| 70 | // In Windows official builds, it is not possible to disable settings |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 71 | // authentication. |
[email protected] | 55274dd | 2014-06-23 21:51:18 | [diff] [blame] | 72 | unauthenticated_load_allowed_ = false; |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 73 | #endif |
| 74 | } else { |
brettw | d94a2214 | 2015-07-15 05:19:26 | [diff] [blame] | 75 | base::FilePath::StringType paths = |
| 76 | base::JoinString(load_extensions_, |
| 77 | base::FilePath::StringType(1, ',')); |
[email protected] | 10f6b14 | 2012-04-14 19:22:43 | [diff] [blame] | 78 | command_line->AppendSwitchNative(switches::kLoadExtension, |
| 79 | paths); |
| 80 | command_line->AppendSwitch(switches::kDisableExtensionsFileAccessCheck); |
| 81 | } |
| 82 | } |
| 83 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 84 | bool SetUpUserDataDirectory() override { |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 85 | base::FilePath profile_dir; |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 86 | PathService::Get(chrome::DIR_USER_DATA, &profile_dir); |
[email protected] | 89dbb177 | 2012-07-17 13:47:25 | [diff] [blame] | 87 | profile_dir = profile_dir.AppendASCII(TestingProfile::kTestUserProfileDir); |
[email protected] | 426d1c9 | 2013-12-03 20:08:54 | [diff] [blame] | 88 | base::CreateDirectory(profile_dir); |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 89 | |
[email protected] | e96a060 | 2014-02-15 08:27:42 | [diff] [blame] | 90 | preferences_file_ = profile_dir.Append(chrome::kPreferencesFilename); |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 91 | user_scripts_dir_ = profile_dir.AppendASCII("User Scripts"); |
| 92 | extensions_dir_ = profile_dir.AppendASCII("Extensions"); |
| 93 | |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 94 | if (load_extensions_.empty()) { |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 95 | base::FilePath src_dir; |
[email protected] | 10f6b14 | 2012-04-14 19:22:43 | [diff] [blame] | 96 | PathService::Get(chrome::DIR_TEST_DATA, &src_dir); |
| 97 | src_dir = src_dir.AppendASCII("extensions").AppendASCII("good"); |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 98 | |
[email protected] | e96a060 | 2014-02-15 08:27:42 | [diff] [blame] | 99 | base::CopyFile(src_dir.Append(chrome::kPreferencesFilename), |
| 100 | preferences_file_); |
[email protected] | f0ff2ad | 2013-07-09 17:42:26 | [diff] [blame] | 101 | base::CopyDirectory(src_dir.AppendASCII("Extensions"), |
| 102 | profile_dir, true); // recursive |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 103 | } |
[email protected] | 10f6b14 | 2012-04-14 19:22:43 | [diff] [blame] | 104 | return true; |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 105 | } |
| 106 | |
gab | bcdefd0cc | 2015-02-17 18:12:40 | [diff] [blame] | 107 | void SetUpInProcessBrowserTestFixture() override { |
| 108 | InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 109 | |
| 110 | // Bots are on a domain, turn off the domain check for settings hardening in |
| 111 | // order to be able to test all SettingsEnforcement groups. |
| 112 | chrome_prefs::DisableDomainCheckForTesting(); |
| 113 | } |
| 114 | |
dcheng | 7219181 | 2014-10-28 20:49:56 | [diff] [blame] | 115 | void TearDown() override { |
[email protected] | dd3aa79 | 2013-07-16 19:10:23 | [diff] [blame] | 116 | EXPECT_TRUE(base::DeleteFile(preferences_file_, false)); |
[email protected] | 020f49e | 2010-04-08 19:51:12 | [diff] [blame] | 117 | |
| 118 | // TODO(phajdan.jr): Check return values of the functions below, carefully. |
[email protected] | dd3aa79 | 2013-07-16 19:10:23 | [diff] [blame] | 119 | base::DeleteFile(user_scripts_dir_, true); |
| 120 | base::DeleteFile(extensions_dir_, true); |
[email protected] | 36fb2c7c | 2011-04-04 15:49:08 | [diff] [blame] | 121 | |
| 122 | InProcessBrowserTest::TearDown(); |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 123 | } |
| 124 | |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 125 | void WaitForServicesToStart(int num_expected_extensions, |
| 126 | bool expect_extensions_enabled) { |
reillyg | a3acbc1 | 2014-11-11 23:17:12 | [diff] [blame] | 127 | extensions::ExtensionRegistry* registry = |
| 128 | extensions::ExtensionRegistry::Get(browser()->profile()); |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 129 | |
[email protected] | fe13bf6 | 2010-08-26 14:33:19 | [diff] [blame] | 130 | // Count the number of non-component extensions. |
| 131 | int found_extensions = 0; |
reillyg | a3acbc1 | 2014-11-11 23:17:12 | [diff] [blame] | 132 | for (const scoped_refptr<const extensions::Extension>& extension : |
| 133 | registry->enabled_extensions()) { |
| 134 | if (extension->location() != extensions::Manifest::COMPONENT) |
[email protected] | fe13bf6 | 2010-08-26 14:33:19 | [diff] [blame] | 135 | found_extensions++; |
[email protected] | 1d5cf414 | 2014-01-24 18:25:22 | [diff] [blame] | 136 | } |
[email protected] | fe13bf6 | 2010-08-26 14:33:19 | [diff] [blame] | 137 | |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 138 | if (!unauthenticated_load_allowed_) |
| 139 | num_expected_extensions = 0; |
| 140 | |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame^] | 141 | ASSERT_EQ(static_cast<uint32_t>(num_expected_extensions), |
| 142 | static_cast<uint32_t>(found_extensions)); |
reillyg | a3acbc1 | 2014-11-11 23:17:12 | [diff] [blame] | 143 | |
| 144 | ExtensionService* service = extensions::ExtensionSystem::Get( |
| 145 | browser()->profile())->extension_service(); |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 146 | ASSERT_EQ(expect_extensions_enabled, service->extensions_enabled()); |
| 147 | |
[email protected] | a7fe911 | 2012-07-20 02:34:45 | [diff] [blame] | 148 | content::WindowedNotificationObserver user_scripts_observer( |
[email protected] | adf5a10 | 2014-07-31 12:44:06 | [diff] [blame] | 149 | extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, |
[email protected] | ad50def5 | 2011-10-19 23:17:07 | [diff] [blame] | 150 | content::NotificationService::AllSources()); |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 151 | extensions::SharedUserScriptMaster* master = |
[email protected] | 5d272a4 | 2012-10-29 13:28:22 | [diff] [blame] | 152 | extensions::ExtensionSystem::Get(browser()->profile())-> |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 153 | shared_user_script_master(); |
| 154 | if (!master->scripts_ready()) |
[email protected] | 120abf13 | 2011-09-27 21:38:06 | [diff] [blame] | 155 | user_scripts_observer.Wait(); |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 156 | ASSERT_TRUE(master->scripts_ready()); |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | void TestInjection(bool expect_css, bool expect_script) { |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 160 | if (!unauthenticated_load_allowed_) { |
| 161 | expect_css = false; |
| 162 | expect_script = false; |
| 163 | } |
| 164 | |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 165 | // Load a page affected by the content script and test to see the effect. |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 166 | base::FilePath test_file; |
[email protected] | 6277144 | 2009-11-22 02:25:04 | [diff] [blame] | 167 | PathService::Get(chrome::DIR_TEST_DATA, &test_file); |
| 168 | test_file = test_file.AppendASCII("extensions") |
| 169 | .AppendASCII("test_file.html"); |
| 170 | |
| 171 | ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file)); |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 172 | |
| 173 | bool result = false; |
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 174 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 175 | browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | 06bc5d9 | 2013-01-02 22:44:13 | [diff] [blame] | 176 | "window.domAutomationController.send(" |
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 177 | " document.defaultView.getComputedStyle(document.body, null)." |
| 178 | " getPropertyValue('background-color') == 'rgb(245, 245, 220)')", |
[email protected] | 9fabbf7 | 2010-09-30 21:50:05 | [diff] [blame] | 179 | &result)); |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 180 | EXPECT_EQ(expect_css, result); |
| 181 | |
| 182 | result = false; |
[email protected] | b6987e0 | 2013-01-04 18:30:43 | [diff] [blame] | 183 | ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
[email protected] | 47ae2337 | 2013-01-29 01:50:48 | [diff] [blame] | 184 | browser()->tab_strip_model()->GetActiveWebContents(), |
[email protected] | 06bc5d9 | 2013-01-02 22:44:13 | [diff] [blame] | 185 | "window.domAutomationController.send(document.title == 'Modified')", |
[email protected] | 9fabbf7 | 2010-09-30 21:50:05 | [diff] [blame] | 186 | &result)); |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 187 | EXPECT_EQ(expect_script, result); |
| 188 | } |
| 189 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 190 | base::FilePath preferences_file_; |
| 191 | base::FilePath extensions_dir_; |
| 192 | base::FilePath user_scripts_dir_; |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 193 | // True unless unauthenticated extension settings are not allowed to be |
| 194 | // loaded in this configuration. |
| 195 | bool unauthenticated_load_allowed_; |
[email protected] | bfc9356 | 2011-12-14 19:40:04 | [diff] [blame] | 196 | // Extensions to load from the command line. |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 197 | std::vector<base::FilePath::StringType> load_extensions_; |
[email protected] | e50013c3 | 2010-08-18 21:05:24 | [diff] [blame] | 198 | |
| 199 | int num_expected_extensions_; |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | |
| 203 | // ExtensionsStartupTest |
| 204 | // Ensures that we can startup the browser with --enable-extensions and some |
| 205 | // extensions installed and see them run and do basic things. |
[email protected] | 60f7d7a | 2014-04-03 07:15:11 | [diff] [blame] | 206 | typedef ExtensionStartupTestBase ExtensionsStartupTest; |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 207 | |
Nico Weber | 9ce471d4 | 2015-04-13 20:52:39 | [diff] [blame] | 208 | // Broken in official builds, http://crbug.com/474659 |
| 209 | IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, DISABLED_Test) { |
[email protected] | e50013c3 | 2010-08-18 21:05:24 | [diff] [blame] | 210 | WaitForServicesToStart(num_expected_extensions_, true); |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 211 | TestInjection(true, true); |
| 212 | } |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 213 | |
Nico Weber | 9ce471d4 | 2015-04-13 20:52:39 | [diff] [blame] | 214 | // Broken in official builds, http://crbug.com/474659 |
[email protected] | b2f665f5 | 2010-07-02 01:32:09 | [diff] [blame] | 215 | // Sometimes times out on Mac. http://crbug.com/48151 |
[email protected] | 05c8218 | 2010-06-24 17:49:08 | [diff] [blame] | 216 | // Tests that disallowing file access on an extension prevents it from injecting |
| 217 | // script into a page with a file URL. |
Nico Weber | 9ce471d4 | 2015-04-13 20:52:39 | [diff] [blame] | 218 | IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, DISABLED_NoFileAccess) { |
[email protected] | e50013c3 | 2010-08-18 21:05:24 | [diff] [blame] | 219 | WaitForServicesToStart(num_expected_extensions_, true); |
[email protected] | 05c8218 | 2010-06-24 17:49:08 | [diff] [blame] | 220 | |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 221 | // Keep a separate list of extensions for which to disable file access, since |
| 222 | // doing so reloads them. |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 223 | std::vector<const extensions::Extension*> extension_list; |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 224 | |
[email protected] | 1d5cf414 | 2014-01-24 18:25:22 | [diff] [blame] | 225 | extensions::ExtensionRegistry* registry = |
| 226 | extensions::ExtensionRegistry::Get(browser()->profile()); |
[email protected] | 289c44b | 2013-12-17 03:26:57 | [diff] [blame] | 227 | for (extensions::ExtensionSet::const_iterator it = |
[email protected] | 1d5cf414 | 2014-01-24 18:25:22 | [diff] [blame] | 228 | registry->enabled_extensions().begin(); |
| 229 | it != registry->enabled_extensions().end(); ++it) { |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 230 | if ((*it)->location() == extensions::Manifest::COMPONENT) |
[email protected] | fe13bf6 | 2010-08-26 14:33:19 | [diff] [blame] | 231 | continue; |
[email protected] | 1d5cf414 | 2014-01-24 18:25:22 | [diff] [blame] | 232 | if (extensions::util::AllowFileAccess((*it)->id(), browser()->profile())) |
[email protected] | cadac62 | 2013-06-11 16:46:36 | [diff] [blame] | 233 | extension_list.push_back(it->get()); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | for (size_t i = 0; i < extension_list.size(); ++i) { |
[email protected] | a7fe911 | 2012-07-20 02:34:45 | [diff] [blame] | 237 | content::WindowedNotificationObserver user_scripts_observer( |
[email protected] | adf5a10 | 2014-07-31 12:44:06 | [diff] [blame] | 238 | extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 239 | content::NotificationService::AllSources()); |
[email protected] | 1d5cf414 | 2014-01-24 18:25:22 | [diff] [blame] | 240 | extensions::util::SetAllowFileAccess( |
| 241 | extension_list[i]->id(), browser()->profile(), false); |
[email protected] | 84df833 | 2011-12-06 18:22:46 | [diff] [blame] | 242 | user_scripts_observer.Wait(); |
[email protected] | 05c8218 | 2010-06-24 17:49:08 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | TestInjection(false, false); |
| 246 | } |
| 247 | |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 248 | // ExtensionsLoadTest |
| 249 | // Ensures that we can startup the browser with --load-extension and see them |
| 250 | // run. |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 251 | class ExtensionsLoadTest : public ExtensionStartupTestBase { |
| 252 | public: |
| 253 | ExtensionsLoadTest() { |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 254 | base::FilePath one_extension_path; |
[email protected] | bfc9356 | 2011-12-14 19:40:04 | [diff] [blame] | 255 | PathService::Get(chrome::DIR_TEST_DATA, &one_extension_path); |
| 256 | one_extension_path = one_extension_path |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 257 | .AppendASCII("extensions") |
| 258 | .AppendASCII("good") |
| 259 | .AppendASCII("Extensions") |
| 260 | .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 261 | .AppendASCII("1.0.0.0"); |
[email protected] | bfc9356 | 2011-12-14 19:40:04 | [diff] [blame] | 262 | load_extensions_.push_back(one_extension_path.value()); |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 263 | } |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 264 | }; |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 265 | |
[email protected] | dc12802 | 2012-02-17 23:14:58 | [diff] [blame] | 266 | IN_PROC_BROWSER_TEST_F(ExtensionsLoadTest, Test) { |
[email protected] | d728e00 | 2010-12-08 04:46:23 | [diff] [blame] | 267 | WaitForServicesToStart(1, true); |
[email protected] | 919ddc8 | 2009-07-15 04:30:12 | [diff] [blame] | 268 | TestInjection(true, true); |
[email protected] | f0488f2f | 2009-07-01 05:25:22 | [diff] [blame] | 269 | } |
[email protected] | bfc9356 | 2011-12-14 19:40:04 | [diff] [blame] | 270 | |
| 271 | // ExtensionsLoadMultipleTest |
| 272 | // Ensures that we can startup the browser with multiple extensions |
| 273 | // via --load-extension=X1,X2,X3. |
| 274 | class ExtensionsLoadMultipleTest : public ExtensionStartupTestBase { |
| 275 | public: |
| 276 | ExtensionsLoadMultipleTest() { |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 277 | base::FilePath one_extension_path; |
[email protected] | bfc9356 | 2011-12-14 19:40:04 | [diff] [blame] | 278 | PathService::Get(chrome::DIR_TEST_DATA, &one_extension_path); |
| 279 | one_extension_path = one_extension_path |
| 280 | .AppendASCII("extensions") |
| 281 | .AppendASCII("good") |
| 282 | .AppendASCII("Extensions") |
| 283 | .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 284 | .AppendASCII("1.0.0.0"); |
| 285 | load_extensions_.push_back(one_extension_path.value()); |
| 286 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 287 | base::FilePath second_extension_path; |
[email protected] | bfc9356 | 2011-12-14 19:40:04 | [diff] [blame] | 288 | PathService::Get(chrome::DIR_TEST_DATA, &second_extension_path); |
| 289 | second_extension_path = second_extension_path |
| 290 | .AppendASCII("extensions") |
| 291 | .AppendASCII("app"); |
| 292 | load_extensions_.push_back(second_extension_path.value()); |
| 293 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 294 | base::FilePath third_extension_path; |
[email protected] | bfc9356 | 2011-12-14 19:40:04 | [diff] [blame] | 295 | PathService::Get(chrome::DIR_TEST_DATA, &third_extension_path); |
| 296 | third_extension_path = third_extension_path |
| 297 | .AppendASCII("extensions") |
| 298 | .AppendASCII("app1"); |
| 299 | load_extensions_.push_back(third_extension_path.value()); |
| 300 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 301 | base::FilePath fourth_extension_path; |
[email protected] | bfc9356 | 2011-12-14 19:40:04 | [diff] [blame] | 302 | PathService::Get(chrome::DIR_TEST_DATA, &fourth_extension_path); |
| 303 | fourth_extension_path = fourth_extension_path |
| 304 | .AppendASCII("extensions") |
| 305 | .AppendASCII("app2"); |
| 306 | load_extensions_.push_back(fourth_extension_path.value()); |
| 307 | } |
| 308 | }; |
| 309 | |
| 310 | IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { |
| 311 | WaitForServicesToStart(4, true); |
| 312 | TestInjection(true, true); |
| 313 | } |