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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 ? num_tracked_prefs() | 512 ? num_tracked_prefs() |
513 : 0, | 513 : 0, |
514 GetTrackedPrefHistogramCount( | 514 GetTrackedPrefHistogramCount( |
515 user_prefs::tracked::kTrackedPrefHistogramUnchanged, | 515 user_prefs::tracked::kTrackedPrefHistogramUnchanged, |
516 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 516 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
517 ALLOW_ANY)); | 517 ALLOW_ANY)); |
518 } | 518 } |
519 } | 519 } |
520 }; | 520 }; |
521 | 521 |
522 // Test is flaky. crbug.com/723639 | 522 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedDefault, UnchangedDefault); |
jam
2017/05/17 19:06:16
https://codereview.chromium.org/2882423002 was als
gab
2017/05/17 20:01:04
Done.
| |
523 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedDefault, | |
524 DISABLED_UnchangedDefault); | |
525 | 523 |
526 // Augments PrefHashBrowserTestUnchangedDefault to confirm that nothing is reset | 524 // Augments PrefHashBrowserTestUnchangedDefault to confirm that nothing is reset |
527 // when nothing is tampered with, even if Chrome itself wrote custom prefs in | 525 // when nothing is tampered with, even if Chrome itself wrote custom prefs in |
528 // its last run. | 526 // its last run. |
529 class PrefHashBrowserTestUnchangedCustom | 527 class PrefHashBrowserTestUnchangedCustom |
530 : public PrefHashBrowserTestUnchangedDefault { | 528 : public PrefHashBrowserTestUnchangedDefault { |
531 public: | 529 public: |
532 void SetupPreferences() override { | 530 void SetupPreferences() override { |
533 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 531 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
534 | 532 |
535 InstallExtensionWithUIAutoConfirm( | 533 InstallExtensionWithUIAutoConfirm( |
536 test_data_dir_.AppendASCII("good.crx"), 1, browser()); | 534 test_data_dir_.AppendASCII("good.crx"), 1, browser()); |
537 } | 535 } |
538 | 536 |
539 void VerifyReactionToPrefAttack() override { | 537 void VerifyReactionToPrefAttack() override { |
540 // Make sure the settings written in the last run stuck. | 538 // Make sure the settings written in the last run stuck. |
541 EXPECT_EQ("http://example.com", | 539 EXPECT_EQ("http://example.com", |
542 profile()->GetPrefs()->GetString(prefs::kHomePage)); | 540 profile()->GetPrefs()->GetString(prefs::kHomePage)); |
543 | 541 |
544 EXPECT_TRUE(extension_service()->GetExtensionById(kGoodCrxId, false)); | 542 EXPECT_TRUE(extension_service()->GetExtensionById(kGoodCrxId, false)); |
545 | 543 |
546 // Reaction should be identical to unattacked default prefs. | 544 // Reaction should be identical to unattacked default prefs. |
547 PrefHashBrowserTestUnchangedDefault::VerifyReactionToPrefAttack(); | 545 PrefHashBrowserTestUnchangedDefault::VerifyReactionToPrefAttack(); |
548 } | 546 } |
549 }; | 547 }; |
550 | 548 |
551 // Test is flaky. crbug.com/723639 | 549 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedCustom, UnchangedCustom); |
552 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedCustom, | |
553 DISABLED_UnchangedCustom); | |
554 | 550 |
555 // Verifies that cleared prefs are reported. | 551 // Verifies that cleared prefs are reported. |
556 class PrefHashBrowserTestClearedAtomic : public PrefHashBrowserTestBase { | 552 class PrefHashBrowserTestClearedAtomic : public PrefHashBrowserTestBase { |
557 public: | 553 public: |
558 void SetupPreferences() override { | 554 void SetupPreferences() override { |
559 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 555 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
560 } | 556 } |
561 | 557 |
562 void AttackPreferencesOnDisk( | 558 void AttackPreferencesOnDisk( |
563 base::DictionaryValue* unprotected_preferences, | 559 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. | 611 // Expect homepage clearance to have been noticed by registry validation. |
616 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 612 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
617 GetTrackedPrefHistogramCount( | 613 GetTrackedPrefHistogramCount( |
618 user_prefs::tracked::kTrackedPrefHistogramCleared, | 614 user_prefs::tracked::kTrackedPrefHistogramCleared, |
619 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 615 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
620 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 616 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
621 } | 617 } |
622 } | 618 } |
623 }; | 619 }; |
624 | 620 |
625 // Test is flaky. crbug.com/723639 | 621 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestClearedAtomic, ClearedAtomic); |
626 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestClearedAtomic, | |
627 DISABLED_ClearedAtomic); | |
628 | 622 |
629 // Verifies that clearing the MACs results in untrusted Initialized pings for | 623 // Verifies that clearing the MACs results in untrusted Initialized pings for |
630 // non-null protected prefs. | 624 // non-null protected prefs. |
631 class PrefHashBrowserTestUntrustedInitialized : public PrefHashBrowserTestBase { | 625 class PrefHashBrowserTestUntrustedInitialized : public PrefHashBrowserTestBase { |
632 public: | 626 public: |
633 void SetupPreferences() override { | 627 void SetupPreferences() override { |
634 // Explicitly set the DSE (it's otherwise NULL by default, preventing | 628 // Explicitly set the DSE (it's otherwise NULL by default, preventing |
635 // thorough testing of the PROTECTION_ENABLED_DSE level). | 629 // thorough testing of the PROTECTION_ENABLED_DSE level). |
636 DefaultSearchManager default_search_manager( | 630 DefaultSearchManager default_search_manager( |
637 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); | 631 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 ? num_tracked_prefs() | 745 ? num_tracked_prefs() |
752 : 0, | 746 : 0, |
753 GetTrackedPrefHistogramCount( | 747 GetTrackedPrefHistogramCount( |
754 user_prefs::tracked::kTrackedPrefHistogramUnchanged, | 748 user_prefs::tracked::kTrackedPrefHistogramUnchanged, |
755 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 749 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
756 ALLOW_ANY)); | 750 ALLOW_ANY)); |
757 } | 751 } |
758 } | 752 } |
759 }; | 753 }; |
760 | 754 |
761 // Test is flaky. crbug.com/723639 | |
762 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedInitialized, | 755 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedInitialized, |
763 DISABLED_UntrustedInitialized); | 756 UntrustedInitialized); |
764 | 757 |
765 // Verifies that changing an atomic pref results in it being reported (and reset | 758 // Verifies that changing an atomic pref results in it being reported (and reset |
766 // if the protection level allows it). | 759 // if the protection level allows it). |
767 class PrefHashBrowserTestChangedAtomic : public PrefHashBrowserTestBase { | 760 class PrefHashBrowserTestChangedAtomic : public PrefHashBrowserTestBase { |
768 public: | 761 public: |
769 void SetupPreferences() override { | 762 void SetupPreferences() override { |
770 profile()->GetPrefs()->SetInteger(prefs::kRestoreOnStartup, | 763 profile()->GetPrefs()->SetInteger(prefs::kRestoreOnStartup, |
771 SessionStartupPref::URLS); | 764 SessionStartupPref::URLS); |
772 | 765 |
773 ListPrefUpdate update(profile()->GetPrefs(), | 766 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). | 844 // Expect a single Changed event for tracked pref #4 (startup URLs). |
852 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 845 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
853 GetTrackedPrefHistogramCount( | 846 GetTrackedPrefHistogramCount( |
854 user_prefs::tracked::kTrackedPrefHistogramChanged, | 847 user_prefs::tracked::kTrackedPrefHistogramChanged, |
855 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 848 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
856 BEGIN_ALLOW_SINGLE_BUCKET + 4)); | 849 BEGIN_ALLOW_SINGLE_BUCKET + 4)); |
857 } | 850 } |
858 } | 851 } |
859 }; | 852 }; |
860 | 853 |
861 // Test is flaky. crbug.com/723639 | 854 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedAtomic, ChangedAtomic); |
862 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedAtomic, | |
863 DISABLED_ChangedAtomic); | |
864 | 855 |
865 // Verifies that changing or adding an entry in a split pref results in both | 856 // 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). | 857 // items being reported (and remove if the protection level allows it). |
867 class PrefHashBrowserTestChangedSplitPref : public PrefHashBrowserTestBase { | 858 class PrefHashBrowserTestChangedSplitPref : public PrefHashBrowserTestBase { |
868 public: | 859 public: |
869 void SetupPreferences() override { | 860 void SetupPreferences() override { |
870 InstallExtensionWithUIAutoConfirm( | 861 InstallExtensionWithUIAutoConfirm( |
871 test_data_dir_.AppendASCII("good.crx"), 1, browser()); | 862 test_data_dir_.AppendASCII("good.crx"), 1, browser()); |
872 } | 863 } |
873 | 864 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 // pref #5 (extensions). | 951 // pref #5 (extensions). |
961 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 952 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
962 GetTrackedPrefHistogramCount( | 953 GetTrackedPrefHistogramCount( |
963 user_prefs::tracked::kTrackedPrefHistogramChanged, | 954 user_prefs::tracked::kTrackedPrefHistogramChanged, |
964 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 955 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
965 BEGIN_ALLOW_SINGLE_BUCKET + 5)); | 956 BEGIN_ALLOW_SINGLE_BUCKET + 5)); |
966 } | 957 } |
967 } | 958 } |
968 }; | 959 }; |
969 | 960 |
970 // Test is flaky. crbug.com/723639 | 961 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedSplitPref, ChangedSplitPref); |
971 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedSplitPref, | |
972 DISABLED_ChangedSplitPref); | |
973 | 962 |
974 // Verifies that adding a value to unprotected preferences for a key which is | 963 // 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) | 964 // 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 | 965 // doesn't allow that value to slip in with no valid MAC (regression test for |
977 // http://crbug.com/414554) | 966 // http://crbug.com/414554) |
978 class PrefHashBrowserTestUntrustedAdditionToPrefs | 967 class PrefHashBrowserTestUntrustedAdditionToPrefs |
979 : public PrefHashBrowserTestBase { | 968 : public PrefHashBrowserTestBase { |
980 public: | 969 public: |
981 void SetupPreferences() override { | 970 void SetupPreferences() override { |
982 // Ensure there is no user-selected value for kRestoreOnStartup. | 971 // 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 | 1035 ? changed_expected |
1047 : 0, | 1036 : 0, |
1048 GetTrackedPrefHistogramCount( | 1037 GetTrackedPrefHistogramCount( |
1049 user_prefs::tracked::kTrackedPrefHistogramChanged, | 1038 user_prefs::tracked::kTrackedPrefHistogramChanged, |
1050 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1039 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
1051 BEGIN_ALLOW_SINGLE_BUCKET + 3)); | 1040 BEGIN_ALLOW_SINGLE_BUCKET + 3)); |
1052 } | 1041 } |
1053 } | 1042 } |
1054 }; | 1043 }; |
1055 | 1044 |
1056 // Test is flaky. crbug.com/723639 | |
1057 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefs, | 1045 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefs, |
1058 DISABLED_UntrustedAdditionToPrefs); | 1046 UntrustedAdditionToPrefs); |
1059 | 1047 |
1060 // Verifies that adding a value to unprotected preferences while wiping a | 1048 // Verifies that adding a value to unprotected preferences while wiping a |
1061 // user-selected value from protected preferences doesn't allow that value to | 1049 // 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). | 1050 // slip in with no valid MAC (regression test for http://crbug.com/414554). |
1063 class PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe | 1051 class PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe |
1064 : public PrefHashBrowserTestBase { | 1052 : public PrefHashBrowserTestBase { |
1065 public: | 1053 public: |
1066 void SetupPreferences() override { | 1054 void SetupPreferences() override { |
1067 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 1055 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
1068 } | 1056 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1134 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1122 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
1135 EXPECT_EQ(cleared_expected, | 1123 EXPECT_EQ(cleared_expected, |
1136 GetTrackedPrefHistogramCount( | 1124 GetTrackedPrefHistogramCount( |
1137 user_prefs::tracked::kTrackedPrefHistogramCleared, | 1125 user_prefs::tracked::kTrackedPrefHistogramCleared, |
1138 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1126 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
1139 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1127 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
1140 } | 1128 } |
1141 } | 1129 } |
1142 }; | 1130 }; |
1143 | 1131 |
1144 // Test is flaky. crbug.com/723639 | |
1145 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe, | 1132 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe, |
1146 DISABLED_UntrustedAdditionToPrefsAfterWipe); | 1133 UntrustedAdditionToPrefsAfterWipe); |
1147 | 1134 |
1148 #if defined(OS_WIN) | 1135 #if defined(OS_WIN) |
1149 class PrefHashBrowserTestRegistryValidationFailure | 1136 class PrefHashBrowserTestRegistryValidationFailure |
1150 : public PrefHashBrowserTestBase { | 1137 : public PrefHashBrowserTestBase { |
1151 public: | 1138 public: |
1152 void SetupPreferences() override { | 1139 void SetupPreferences() override { |
1153 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 1140 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
1154 } | 1141 } |
1155 | 1142 |
1156 void AttackPreferencesOnDisk( | 1143 void AttackPreferencesOnDisk( |
(...skipping 22 matching lines...) Expand all Loading... | |
1179 // (homepage). | 1166 // (homepage). |
1180 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 1167 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
1181 GetTrackedPrefHistogramCount( | 1168 GetTrackedPrefHistogramCount( |
1182 user_prefs::tracked::kTrackedPrefHistogramChanged, | 1169 user_prefs::tracked::kTrackedPrefHistogramChanged, |
1183 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1170 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
1184 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1171 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
1185 } | 1172 } |
1186 } | 1173 } |
1187 }; | 1174 }; |
1188 | 1175 |
1189 // Test is flaky. crbug.com/723639 | |
1190 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestRegistryValidationFailure, | 1176 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestRegistryValidationFailure, |
1191 DISABLED_RegistryValidationFailure); | 1177 RegistryValidationFailure); |
1192 #endif | 1178 #endif |
1193 | 1179 |
1194 // Verifies that all preferences related to choice of default search engine are | 1180 // Verifies that all preferences related to choice of default search engine are |
1195 // protected. | 1181 // protected. |
1196 class PrefHashBrowserTestDefaultSearch : public PrefHashBrowserTestBase { | 1182 class PrefHashBrowserTestDefaultSearch : public PrefHashBrowserTestBase { |
1197 public: | 1183 public: |
1198 void SetupPreferences() override { | 1184 void SetupPreferences() override { |
1199 // Set user selected default search engine. | 1185 // Set user selected default search engine. |
1200 DefaultSearchManager default_search_manager( | 1186 DefaultSearchManager default_search_manager( |
1201 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); | 1187 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1286 // Attack fails. | 1272 // Attack fails. |
1287 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, dse_source); | 1273 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, dse_source); |
1288 EXPECT_NE(current_dse->keyword(), base::UTF8ToUTF16("badkeyword")); | 1274 EXPECT_NE(current_dse->keyword(), base::UTF8ToUTF16("badkeyword")); |
1289 EXPECT_NE(current_dse->short_name(), base::UTF8ToUTF16("badname")); | 1275 EXPECT_NE(current_dse->short_name(), base::UTF8ToUTF16("badname")); |
1290 EXPECT_NE(current_dse->url(), | 1276 EXPECT_NE(current_dse->url(), |
1291 "http://bad_default_engine/search?q=dirty_user_query"); | 1277 "http://bad_default_engine/search?q=dirty_user_query"); |
1292 } | 1278 } |
1293 } | 1279 } |
1294 }; | 1280 }; |
1295 | 1281 |
1296 // Test is flaky. crbug.com/723639 | 1282 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestDefaultSearch, SearchProtected); |
1297 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestDefaultSearch, | |
1298 DISABLED_SearchProtected); | |
OLD | NEW |