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 "chrome/browser/chrome_elf_init_win.h" | 5 #include "chrome/browser/chrome_elf_init_win.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/files/file_path.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/path_service.h" |
| 12 #include "base/scoped_native_library.h" |
10 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
11 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
13 #include "base/test/test_reg_util_win.h" | 16 #include "base/test/test_reg_util_win.h" |
14 #include "chrome/common/chrome_version_info.h" | 17 #include "chrome/common/chrome_version_info.h" |
| 18 #include "chrome_elf/blacklist/blacklist.h" |
15 #include "chrome_elf/chrome_elf_constants.h" | 19 #include "chrome_elf/chrome_elf_constants.h" |
16 #include "components/variations/entropy_provider.h" | 20 #include "components/variations/entropy_provider.h" |
17 #include "components/variations/variations_associated_data.h" | 21 #include "components/variations/variations_associated_data.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "version.h" // NOLINT | 23 #include "version.h" // NOLINT |
20 | 24 |
21 namespace { | 25 namespace { |
22 | 26 |
23 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled"; | 27 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled"; |
| 28 const wchar_t kTestDllName[] = L"blacklist_test_dll_1.dll"; |
24 | 29 |
25 class ChromeBlacklistTrialTest : public testing::Test { | 30 class ChromeBlacklistTrialTest : public testing::Test { |
26 protected: | 31 protected: |
27 ChromeBlacklistTrialTest() {} | 32 ChromeBlacklistTrialTest() {} |
28 virtual ~ChromeBlacklistTrialTest() {} | 33 virtual ~ChromeBlacklistTrialTest() {} |
29 | 34 |
30 virtual void SetUp() OVERRIDE { | 35 virtual void SetUp() OVERRIDE { |
31 testing::Test::SetUp(); | 36 testing::Test::SetUp(); |
32 | 37 |
33 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, | 38 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 finch_blacklist_registry_key.GetValueCount()); | 193 finch_blacklist_registry_key.GetValueCount()); |
189 | 194 |
190 for (std::map<std::string, std::string>::iterator it = desired_params.begin(); | 195 for (std::map<std::string, std::string>::iterator it = desired_params.begin(); |
191 it != desired_params.end(); | 196 it != desired_params.end(); |
192 ++it) { | 197 ++it) { |
193 std::wstring name = base::UTF8ToWide(it->first); | 198 std::wstring name = base::UTF8ToWide(it->first); |
194 ASSERT_TRUE(finch_blacklist_registry_key.HasValue(name.c_str())); | 199 ASSERT_TRUE(finch_blacklist_registry_key.HasValue(name.c_str())); |
195 } | 200 } |
196 } | 201 } |
197 | 202 |
| 203 TEST_F(ChromeBlacklistTrialTest, TestBlacklistBypass) { |
| 204 base::FilePath current_dir; |
| 205 ASSERT_TRUE(PathService::Get(base::DIR_EXE, ¤t_dir)); |
| 206 |
| 207 // Load test dll. |
| 208 base::ScopedNativeLibrary dll1(current_dir.Append(kTestDllName)); |
| 209 |
| 210 // No blacklisted dll should be found. |
| 211 std::vector<base::string16> module_names; |
| 212 EXPECT_FALSE(GetLoadedBlacklistedModules(&module_names)); |
| 213 std::vector<base::string16>::const_iterator module_iter(module_names.begin()); |
| 214 // For posterity, print any that are. |
| 215 for (; module_iter != module_names.end(); ++module_iter) { |
| 216 LOG(ERROR) << "Found blacklisted module: " << *module_iter; |
| 217 } |
| 218 |
| 219 // Add test dll to blacklist |
| 220 blacklist::AddDllToBlacklist(kTestDllName); |
| 221 |
| 222 // Check that the test dll appears in list. |
| 223 module_names.clear(); |
| 224 EXPECT_TRUE(GetLoadedBlacklistedModules(&module_names)); |
| 225 ASSERT_EQ(1, module_names.size()); |
| 226 EXPECT_STREQ(kTestDllName, |
| 227 StringToLowerASCII( |
| 228 base::FilePath(module_names[0]).BaseName().value()).c_str()); |
| 229 } |
| 230 |
198 } // namespace | 231 } // namespace |
OLD | NEW |