| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "components/search_engines/template_url_data.h" | 37 #include "components/search_engines/template_url_data.h" |
| 38 #include "extensions/browser/pref_names.h" | 38 #include "extensions/browser/pref_names.h" |
| 39 #include "extensions/common/extension.h" | 39 #include "extensions/common/extension.h" |
| 40 #include "services/preferences/public/cpp/tracked/tracked_preference_histogram_n
ames.h" | 40 #include "services/preferences/public/cpp/tracked/tracked_preference_histogram_n
ames.h" |
| 41 | 41 |
| 42 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 43 #include "chromeos/chromeos_switches.h" | 43 #include "chromeos/chromeos_switches.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 47 #include "base/test/test_reg_util_win.h" | 47 #include "base/win/registry.h" |
| 48 #include "chrome/install_static/install_util.h" |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 50 namespace { | 51 namespace { |
| 51 | 52 |
| 52 // Extension ID of chrome/test/data/extensions/good.crx | 53 // Extension ID of chrome/test/data/extensions/good.crx |
| 53 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 54 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; |
| 54 | 55 |
| 55 // Explicit expectations from the caller of GetTrackedPrefHistogramCount(). This | 56 // Explicit expectations from the caller of GetTrackedPrefHistogramCount(). This |
| 56 // enables detailed reporting of the culprit on failure. | 57 // enables detailed reporting of the culprit on failure. |
| 57 enum AllowedBuckets { | 58 enum AllowedBuckets { |
| 58 // Allow no samples in any buckets. | 59 // Allow no samples in any buckets. |
| 59 ALLOW_NONE = -1, | 60 ALLOW_NONE = -1, |
| 60 // Any integer between BEGIN_ALLOW_SINGLE_BUCKET and END_ALLOW_SINGLE_BUCKET | 61 // Any integer between BEGIN_ALLOW_SINGLE_BUCKET and END_ALLOW_SINGLE_BUCKET |
| 61 // indicates that only this specific bucket is allowed to have a sample. | 62 // indicates that only this specific bucket is allowed to have a sample. |
| 62 BEGIN_ALLOW_SINGLE_BUCKET = 0, | 63 BEGIN_ALLOW_SINGLE_BUCKET = 0, |
| 63 END_ALLOW_SINGLE_BUCKET = 100, | 64 END_ALLOW_SINGLE_BUCKET = 100, |
| 64 // Allow any buckets (no extra verifications performed). | 65 // Allow any buckets (no extra verifications performed). |
| 65 ALLOW_ANY | 66 ALLOW_ANY |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
| 69 base::string16 GetRegistryPathForTestProfile() { | 70 base::string16 GetRegistryPathForTestProfile() { |
| 71 // Cleanup follow-up to http://crbug.com/721245 for the previous location of |
| 72 // this test key which had similar problems (to a lesser extent). It's |
| 73 // redundant but harmless to have multiple callers hit this on the same |
| 74 // machine. TODO(gab): remove this mid-june 2017. |
| 75 base::win::RegKey key; |
| 76 if (key.Open(HKEY_CURRENT_USER, L"SOFTWARE\\Chromium\\PrefHashBrowserTest", |
| 77 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { |
| 78 LONG result = key.DeleteKey(L""); |
| 79 EXPECT_TRUE(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND); |
| 80 } |
| 81 |
| 70 base::FilePath profile_dir; | 82 base::FilePath profile_dir; |
| 71 EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &profile_dir)); | 83 EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &profile_dir)); |
| 72 return L"SOFTWARE\\Chromium\\PrefHashBrowserTest\\" + | 84 |
| 85 // Use a location under the real PreferenceMACs path so that the backup |
| 86 // cleanup logic in ChromeTestLauncherDelegate::PreSharding() for interrupted |
| 87 // tests covers this test key as well. |
| 88 return install_static::GetRegistryPath() + |
| 89 L"\\PreferenceMACs\\PrefHashBrowserTest\\" + |
| 73 profile_dir.BaseName().value(); | 90 profile_dir.BaseName().value(); |
| 74 } | 91 } |
| 75 #endif | 92 #endif |
| 76 | 93 |
| 77 // Returns the number of times |histogram_name| was reported so far; adding the | 94 // Returns the number of times |histogram_name| was reported so far; adding the |
| 78 // results of the first 100 buckets (there are only ~19 reporting IDs as of this | 95 // results of the first 100 buckets (there are only ~19 reporting IDs as of this |
| 79 // writing; varies depending on the platform). |allowed_buckets| hints at extra | 96 // writing; varies depending on the platform). |allowed_buckets| hints at extra |
| 80 // requirements verified in this method (see AllowedBuckets for details). | 97 // requirements verified in this method (see AllowedBuckets for details). |
| 81 int GetTrackedPrefHistogramCount(const char* histogram_name, | 98 int GetTrackedPrefHistogramCount(const char* histogram_name, |
| 82 const char* histogram_suffix, | 99 const char* histogram_suffix, |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 LONG result = key.DeleteKey(L""); | 307 LONG result = key.DeleteKey(L""); |
| 291 ASSERT_TRUE(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND); | 308 ASSERT_TRUE(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND); |
| 292 } | 309 } |
| 293 } | 310 } |
| 294 #endif | 311 #endif |
| 295 } | 312 } |
| 296 | 313 |
| 297 void TearDown() override { | 314 void TearDown() override { |
| 298 #if defined(OS_WIN) | 315 #if defined(OS_WIN) |
| 299 // When done, delete the Registry key to avoid polluting the registry. | 316 // When done, delete the Registry key to avoid polluting the registry. |
| 300 // TODO(proberge): it would be nice to delete keys from interrupted tests | |
| 301 // as well. | |
| 302 if (!IsPRETest()) { | 317 if (!IsPRETest()) { |
| 303 base::string16 registry_key = GetRegistryPathForTestProfile(); | 318 base::string16 registry_key = GetRegistryPathForTestProfile(); |
| 304 base::win::RegKey key; | 319 base::win::RegKey key; |
| 305 if (key.Open(HKEY_CURRENT_USER, registry_key.c_str(), | 320 if (key.Open(HKEY_CURRENT_USER, registry_key.c_str(), |
| 306 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { | 321 KEY_SET_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) { |
| 307 LONG result = key.DeleteKey(L""); | 322 LONG result = key.DeleteKey(L""); |
| 308 ASSERT_TRUE(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND); | 323 ASSERT_TRUE(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND); |
| 309 } | 324 } |
| 310 } | 325 } |
| 311 #endif | 326 #endif |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 ? num_tracked_prefs() | 527 ? num_tracked_prefs() |
| 513 : 0, | 528 : 0, |
| 514 GetTrackedPrefHistogramCount( | 529 GetTrackedPrefHistogramCount( |
| 515 user_prefs::tracked::kTrackedPrefHistogramUnchanged, | 530 user_prefs::tracked::kTrackedPrefHistogramUnchanged, |
| 516 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 531 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 517 ALLOW_ANY)); | 532 ALLOW_ANY)); |
| 518 } | 533 } |
| 519 } | 534 } |
| 520 }; | 535 }; |
| 521 | 536 |
| 522 // Test is flaky. crbug.com/723639 | 537 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedDefault, UnchangedDefault); |
| 523 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedDefault, | |
| 524 DISABLED_UnchangedDefault); | |
| 525 | 538 |
| 526 // Augments PrefHashBrowserTestUnchangedDefault to confirm that nothing is reset | 539 // Augments PrefHashBrowserTestUnchangedDefault to confirm that nothing is reset |
| 527 // when nothing is tampered with, even if Chrome itself wrote custom prefs in | 540 // when nothing is tampered with, even if Chrome itself wrote custom prefs in |
| 528 // its last run. | 541 // its last run. |
| 529 class PrefHashBrowserTestUnchangedCustom | 542 class PrefHashBrowserTestUnchangedCustom |
| 530 : public PrefHashBrowserTestUnchangedDefault { | 543 : public PrefHashBrowserTestUnchangedDefault { |
| 531 public: | 544 public: |
| 532 void SetupPreferences() override { | 545 void SetupPreferences() override { |
| 533 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 546 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
| 534 | 547 |
| 535 InstallExtensionWithUIAutoConfirm( | 548 InstallExtensionWithUIAutoConfirm( |
| 536 test_data_dir_.AppendASCII("good.crx"), 1, browser()); | 549 test_data_dir_.AppendASCII("good.crx"), 1, browser()); |
| 537 } | 550 } |
| 538 | 551 |
| 539 void VerifyReactionToPrefAttack() override { | 552 void VerifyReactionToPrefAttack() override { |
| 540 // Make sure the settings written in the last run stuck. | 553 // Make sure the settings written in the last run stuck. |
| 541 EXPECT_EQ("http://example.com", | 554 EXPECT_EQ("http://example.com", |
| 542 profile()->GetPrefs()->GetString(prefs::kHomePage)); | 555 profile()->GetPrefs()->GetString(prefs::kHomePage)); |
| 543 | 556 |
| 544 EXPECT_TRUE(extension_service()->GetExtensionById(kGoodCrxId, false)); | 557 EXPECT_TRUE(extension_service()->GetExtensionById(kGoodCrxId, false)); |
| 545 | 558 |
| 546 // Reaction should be identical to unattacked default prefs. | 559 // Reaction should be identical to unattacked default prefs. |
| 547 PrefHashBrowserTestUnchangedDefault::VerifyReactionToPrefAttack(); | 560 PrefHashBrowserTestUnchangedDefault::VerifyReactionToPrefAttack(); |
| 548 } | 561 } |
| 549 }; | 562 }; |
| 550 | 563 |
| 551 // Test is flaky. crbug.com/723639 | 564 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedCustom, UnchangedCustom); |
| 552 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedCustom, | |
| 553 DISABLED_UnchangedCustom); | |
| 554 | 565 |
| 555 // Verifies that cleared prefs are reported. | 566 // Verifies that cleared prefs are reported. |
| 556 class PrefHashBrowserTestClearedAtomic : public PrefHashBrowserTestBase { | 567 class PrefHashBrowserTestClearedAtomic : public PrefHashBrowserTestBase { |
| 557 public: | 568 public: |
| 558 void SetupPreferences() override { | 569 void SetupPreferences() override { |
| 559 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 570 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
| 560 } | 571 } |
| 561 | 572 |
| 562 void AttackPreferencesOnDisk( | 573 void AttackPreferencesOnDisk( |
| 563 base::DictionaryValue* unprotected_preferences, | 574 base::DictionaryValue* unprotected_preferences, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 // Expect homepage clearance to have been noticed by registry validation. | 626 // Expect homepage clearance to have been noticed by registry validation. |
| 616 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 627 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
| 617 GetTrackedPrefHistogramCount( | 628 GetTrackedPrefHistogramCount( |
| 618 user_prefs::tracked::kTrackedPrefHistogramCleared, | 629 user_prefs::tracked::kTrackedPrefHistogramCleared, |
| 619 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 630 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 620 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 631 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
| 621 } | 632 } |
| 622 } | 633 } |
| 623 }; | 634 }; |
| 624 | 635 |
| 625 // Test is flaky. crbug.com/723639 | 636 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestClearedAtomic, ClearedAtomic); |
| 626 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestClearedAtomic, | |
| 627 DISABLED_ClearedAtomic); | |
| 628 | 637 |
| 629 // Verifies that clearing the MACs results in untrusted Initialized pings for | 638 // Verifies that clearing the MACs results in untrusted Initialized pings for |
| 630 // non-null protected prefs. | 639 // non-null protected prefs. |
| 631 class PrefHashBrowserTestUntrustedInitialized : public PrefHashBrowserTestBase { | 640 class PrefHashBrowserTestUntrustedInitialized : public PrefHashBrowserTestBase { |
| 632 public: | 641 public: |
| 633 void SetupPreferences() override { | 642 void SetupPreferences() override { |
| 634 // Explicitly set the DSE (it's otherwise NULL by default, preventing | 643 // Explicitly set the DSE (it's otherwise NULL by default, preventing |
| 635 // thorough testing of the PROTECTION_ENABLED_DSE level). | 644 // thorough testing of the PROTECTION_ENABLED_DSE level). |
| 636 DefaultSearchManager default_search_manager( | 645 DefaultSearchManager default_search_manager( |
| 637 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); | 646 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 ? num_tracked_prefs() | 760 ? num_tracked_prefs() |
| 752 : 0, | 761 : 0, |
| 753 GetTrackedPrefHistogramCount( | 762 GetTrackedPrefHistogramCount( |
| 754 user_prefs::tracked::kTrackedPrefHistogramUnchanged, | 763 user_prefs::tracked::kTrackedPrefHistogramUnchanged, |
| 755 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 764 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 756 ALLOW_ANY)); | 765 ALLOW_ANY)); |
| 757 } | 766 } |
| 758 } | 767 } |
| 759 }; | 768 }; |
| 760 | 769 |
| 761 // Test is flaky. crbug.com/723639 | |
| 762 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedInitialized, | 770 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedInitialized, |
| 763 DISABLED_UntrustedInitialized); | 771 UntrustedInitialized); |
| 764 | 772 |
| 765 // Verifies that changing an atomic pref results in it being reported (and reset | 773 // Verifies that changing an atomic pref results in it being reported (and reset |
| 766 // if the protection level allows it). | 774 // if the protection level allows it). |
| 767 class PrefHashBrowserTestChangedAtomic : public PrefHashBrowserTestBase { | 775 class PrefHashBrowserTestChangedAtomic : public PrefHashBrowserTestBase { |
| 768 public: | 776 public: |
| 769 void SetupPreferences() override { | 777 void SetupPreferences() override { |
| 770 profile()->GetPrefs()->SetInteger(prefs::kRestoreOnStartup, | 778 profile()->GetPrefs()->SetInteger(prefs::kRestoreOnStartup, |
| 771 SessionStartupPref::URLS); | 779 SessionStartupPref::URLS); |
| 772 | 780 |
| 773 ListPrefUpdate update(profile()->GetPrefs(), | 781 ListPrefUpdate update(profile()->GetPrefs(), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 // Expect a single Changed event for tracked pref #4 (startup URLs). | 859 // Expect a single Changed event for tracked pref #4 (startup URLs). |
| 852 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 860 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
| 853 GetTrackedPrefHistogramCount( | 861 GetTrackedPrefHistogramCount( |
| 854 user_prefs::tracked::kTrackedPrefHistogramChanged, | 862 user_prefs::tracked::kTrackedPrefHistogramChanged, |
| 855 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 863 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 856 BEGIN_ALLOW_SINGLE_BUCKET + 4)); | 864 BEGIN_ALLOW_SINGLE_BUCKET + 4)); |
| 857 } | 865 } |
| 858 } | 866 } |
| 859 }; | 867 }; |
| 860 | 868 |
| 861 // Test is flaky. crbug.com/723639 | 869 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedAtomic, ChangedAtomic); |
| 862 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedAtomic, | |
| 863 DISABLED_ChangedAtomic); | |
| 864 | 870 |
| 865 // Verifies that changing or adding an entry in a split pref results in both | 871 // Verifies that changing or adding an entry in a split pref results in both |
| 866 // items being reported (and remove if the protection level allows it). | 872 // items being reported (and remove if the protection level allows it). |
| 867 class PrefHashBrowserTestChangedSplitPref : public PrefHashBrowserTestBase { | 873 class PrefHashBrowserTestChangedSplitPref : public PrefHashBrowserTestBase { |
| 868 public: | 874 public: |
| 869 void SetupPreferences() override { | 875 void SetupPreferences() override { |
| 870 InstallExtensionWithUIAutoConfirm( | 876 InstallExtensionWithUIAutoConfirm( |
| 871 test_data_dir_.AppendASCII("good.crx"), 1, browser()); | 877 test_data_dir_.AppendASCII("good.crx"), 1, browser()); |
| 872 } | 878 } |
| 873 | 879 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 // pref #5 (extensions). | 966 // pref #5 (extensions). |
| 961 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 967 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
| 962 GetTrackedPrefHistogramCount( | 968 GetTrackedPrefHistogramCount( |
| 963 user_prefs::tracked::kTrackedPrefHistogramChanged, | 969 user_prefs::tracked::kTrackedPrefHistogramChanged, |
| 964 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 970 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 965 BEGIN_ALLOW_SINGLE_BUCKET + 5)); | 971 BEGIN_ALLOW_SINGLE_BUCKET + 5)); |
| 966 } | 972 } |
| 967 } | 973 } |
| 968 }; | 974 }; |
| 969 | 975 |
| 970 // Test is flaky. crbug.com/723639 | 976 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedSplitPref, ChangedSplitPref); |
| 971 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedSplitPref, | |
| 972 DISABLED_ChangedSplitPref); | |
| 973 | 977 |
| 974 // Verifies that adding a value to unprotected preferences for a key which is | 978 // Verifies that adding a value to unprotected preferences for a key which is |
| 975 // still using the default (i.e. has no value stored in protected preferences) | 979 // still using the default (i.e. has no value stored in protected preferences) |
| 976 // doesn't allow that value to slip in with no valid MAC (regression test for | 980 // doesn't allow that value to slip in with no valid MAC (regression test for |
| 977 // http://crbug.com/414554) | 981 // http://crbug.com/414554) |
| 978 class PrefHashBrowserTestUntrustedAdditionToPrefs | 982 class PrefHashBrowserTestUntrustedAdditionToPrefs |
| 979 : public PrefHashBrowserTestBase { | 983 : public PrefHashBrowserTestBase { |
| 980 public: | 984 public: |
| 981 void SetupPreferences() override { | 985 void SetupPreferences() override { |
| 982 // Ensure there is no user-selected value for kRestoreOnStartup. | 986 // Ensure there is no user-selected value for kRestoreOnStartup. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 ? changed_expected | 1050 ? changed_expected |
| 1047 : 0, | 1051 : 0, |
| 1048 GetTrackedPrefHistogramCount( | 1052 GetTrackedPrefHistogramCount( |
| 1049 user_prefs::tracked::kTrackedPrefHistogramChanged, | 1053 user_prefs::tracked::kTrackedPrefHistogramChanged, |
| 1050 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1054 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 1051 BEGIN_ALLOW_SINGLE_BUCKET + 3)); | 1055 BEGIN_ALLOW_SINGLE_BUCKET + 3)); |
| 1052 } | 1056 } |
| 1053 } | 1057 } |
| 1054 }; | 1058 }; |
| 1055 | 1059 |
| 1056 // Test is flaky. crbug.com/723639 | |
| 1057 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefs, | 1060 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefs, |
| 1058 DISABLED_UntrustedAdditionToPrefs); | 1061 UntrustedAdditionToPrefs); |
| 1059 | 1062 |
| 1060 // Verifies that adding a value to unprotected preferences while wiping a | 1063 // Verifies that adding a value to unprotected preferences while wiping a |
| 1061 // user-selected value from protected preferences doesn't allow that value to | 1064 // user-selected value from protected preferences doesn't allow that value to |
| 1062 // slip in with no valid MAC (regression test for http://crbug.com/414554). | 1065 // slip in with no valid MAC (regression test for http://crbug.com/414554). |
| 1063 class PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe | 1066 class PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe |
| 1064 : public PrefHashBrowserTestBase { | 1067 : public PrefHashBrowserTestBase { |
| 1065 public: | 1068 public: |
| 1066 void SetupPreferences() override { | 1069 void SetupPreferences() override { |
| 1067 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 1070 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
| 1068 } | 1071 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1137 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
| 1135 EXPECT_EQ(cleared_expected, | 1138 EXPECT_EQ(cleared_expected, |
| 1136 GetTrackedPrefHistogramCount( | 1139 GetTrackedPrefHistogramCount( |
| 1137 user_prefs::tracked::kTrackedPrefHistogramCleared, | 1140 user_prefs::tracked::kTrackedPrefHistogramCleared, |
| 1138 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1141 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 1139 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1142 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
| 1140 } | 1143 } |
| 1141 } | 1144 } |
| 1142 }; | 1145 }; |
| 1143 | 1146 |
| 1144 // Test is flaky. crbug.com/723639 | |
| 1145 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe, | 1147 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe, |
| 1146 DISABLED_UntrustedAdditionToPrefsAfterWipe); | 1148 UntrustedAdditionToPrefsAfterWipe); |
| 1147 | 1149 |
| 1148 #if defined(OS_WIN) | 1150 #if defined(OS_WIN) |
| 1149 class PrefHashBrowserTestRegistryValidationFailure | 1151 class PrefHashBrowserTestRegistryValidationFailure |
| 1150 : public PrefHashBrowserTestBase { | 1152 : public PrefHashBrowserTestBase { |
| 1151 public: | 1153 public: |
| 1152 void SetupPreferences() override { | 1154 void SetupPreferences() override { |
| 1153 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 1155 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
| 1154 } | 1156 } |
| 1155 | 1157 |
| 1156 void AttackPreferencesOnDisk( | 1158 void AttackPreferencesOnDisk( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1179 // (homepage). | 1181 // (homepage). |
| 1180 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 1182 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
| 1181 GetTrackedPrefHistogramCount( | 1183 GetTrackedPrefHistogramCount( |
| 1182 user_prefs::tracked::kTrackedPrefHistogramChanged, | 1184 user_prefs::tracked::kTrackedPrefHistogramChanged, |
| 1183 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1185 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 1184 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1186 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
| 1185 } | 1187 } |
| 1186 } | 1188 } |
| 1187 }; | 1189 }; |
| 1188 | 1190 |
| 1189 // Test is flaky. crbug.com/723639 | |
| 1190 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestRegistryValidationFailure, | 1191 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestRegistryValidationFailure, |
| 1191 DISABLED_RegistryValidationFailure); | 1192 RegistryValidationFailure); |
| 1192 #endif | 1193 #endif |
| 1193 | 1194 |
| 1194 // Verifies that all preferences related to choice of default search engine are | 1195 // Verifies that all preferences related to choice of default search engine are |
| 1195 // protected. | 1196 // protected. |
| 1196 class PrefHashBrowserTestDefaultSearch : public PrefHashBrowserTestBase { | 1197 class PrefHashBrowserTestDefaultSearch : public PrefHashBrowserTestBase { |
| 1197 public: | 1198 public: |
| 1198 void SetupPreferences() override { | 1199 void SetupPreferences() override { |
| 1199 // Set user selected default search engine. | 1200 // Set user selected default search engine. |
| 1200 DefaultSearchManager default_search_manager( | 1201 DefaultSearchManager default_search_manager( |
| 1201 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); | 1202 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 // Attack fails. | 1287 // Attack fails. |
| 1287 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, dse_source); | 1288 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, dse_source); |
| 1288 EXPECT_NE(current_dse->keyword(), base::UTF8ToUTF16("badkeyword")); | 1289 EXPECT_NE(current_dse->keyword(), base::UTF8ToUTF16("badkeyword")); |
| 1289 EXPECT_NE(current_dse->short_name(), base::UTF8ToUTF16("badname")); | 1290 EXPECT_NE(current_dse->short_name(), base::UTF8ToUTF16("badname")); |
| 1290 EXPECT_NE(current_dse->url(), | 1291 EXPECT_NE(current_dse->url(), |
| 1291 "http://bad_default_engine/search?q=dirty_user_query"); | 1292 "http://bad_default_engine/search?q=dirty_user_query"); |
| 1292 } | 1293 } |
| 1293 } | 1294 } |
| 1294 }; | 1295 }; |
| 1295 | 1296 |
| 1296 // Test is flaky. crbug.com/723639 | 1297 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestDefaultSearch, SearchProtected); |
| 1297 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestDefaultSearch, | |
| 1298 DISABLED_SearchProtected); | |
| OLD | NEW |