Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: chrome/browser/extensions/extension_preference_apitest.cc

Issue 7298005: Expose privacy-relevant preferences via Chrome's extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_preference_api.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/pref_names.h"
12 #include "webkit/plugins/npapi/mock_plugin_list.h"
13
14 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PreferenceApi) {
15 CommandLine::ForCurrentProcess()->AppendSwitch(
16 switches::kEnableExperimentalExtensionApis);
17
18 PrefService* pref_service = browser()->profile()->GetPrefs();
19 pref_service->SetBoolean(prefs::kAlternateErrorPagesEnabled, false);
20 pref_service->SetBoolean(prefs::kAutofillEnabled, false);
21 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true);
22 pref_service->SetBoolean(prefs::kEnableHyperlinkAuditing, false);
23 pref_service->SetBoolean(prefs::kEnableReferrers, false);
24 pref_service->SetBoolean(prefs::kEnableTranslate, false);
25 pref_service->SetBoolean(prefs::kInstantEnabled, false);
26 pref_service->SetBoolean(prefs::kNetworkPredictionEnabled, false);
27 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false);
28 pref_service->SetBoolean(prefs::kSearchSuggestEnabled, false);
29
30 EXPECT_TRUE(RunExtensionTest("preference/standard")) << message_;
31
32 const PrefService::Preference* pref = pref_service->FindPreference(
33 prefs::kBlockThirdPartyCookies);
34 ASSERT_TRUE(pref);
35 EXPECT_TRUE(pref->IsExtensionControlled());
36 EXPECT_TRUE(pref_service->GetBoolean(prefs::kAlternateErrorPagesEnabled));
37 EXPECT_TRUE(pref_service->GetBoolean(prefs::kAutofillEnabled));
38 EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies));
39 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableHyperlinkAuditing));
40 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers));
41 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableTranslate));
42 EXPECT_TRUE(pref_service->GetBoolean(prefs::kInstantEnabled));
43 EXPECT_TRUE(pref_service->GetBoolean(prefs::kNetworkPredictionEnabled));
44 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled));
45 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSearchSuggestEnabled));
46 }
47
48 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PreferencePersistentIncognito) {
49 CommandLine::ForCurrentProcess()->AppendSwitch(
50 switches::kEnableExperimentalExtensionApis);
51
52 PrefService* prefs = browser()->profile()->GetPrefs();
53 prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false);
54
55 EXPECT_TRUE(
56 RunExtensionTestIncognito("preference/persistent_incognito")) <<
57 message_;
58
59 // Setting an incognito preference should not create an incognito profile.
60 EXPECT_FALSE(browser()->profile()->HasOffTheRecordProfile());
61
62 PrefService* otr_prefs =
63 browser()->profile()->GetOffTheRecordProfile()->GetPrefs();
64 const PrefService::Preference* pref =
65 otr_prefs->FindPreference(prefs::kBlockThirdPartyCookies);
66 ASSERT_TRUE(pref);
67 EXPECT_TRUE(pref->IsExtensionControlled());
68 EXPECT_TRUE(otr_prefs->GetBoolean(prefs::kBlockThirdPartyCookies));
69
70 pref = prefs->FindPreference(prefs::kBlockThirdPartyCookies);
71 ASSERT_TRUE(pref);
72 EXPECT_FALSE(pref->IsExtensionControlled());
73 EXPECT_FALSE(prefs->GetBoolean(prefs::kBlockThirdPartyCookies));
74 }
75
76 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PreferenceIncognitoDisabled) {
77 CommandLine::ForCurrentProcess()->AppendSwitch(
78 switches::kEnableExperimentalExtensionApis);
79
80 EXPECT_FALSE(RunExtensionTest("preference/persistent_incognito"));
81 }
82
83 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PreferenceSessionOnlyIncognito) {
84 CommandLine::ForCurrentProcess()->AppendSwitch(
85 switches::kEnableExperimentalExtensionApis);
86
87 PrefService* prefs = browser()->profile()->GetPrefs();
88 prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false);
89
90 EXPECT_TRUE(
91 RunExtensionTestIncognito("preference/session_only_incognito")) <<
92 message_;
93
94 EXPECT_TRUE(browser()->profile()->HasOffTheRecordProfile());
95
96 PrefService* otr_prefs =
97 browser()->profile()->GetOffTheRecordProfile()->GetPrefs();
98 const PrefService::Preference* pref =
99 otr_prefs->FindPreference(prefs::kBlockThirdPartyCookies);
100 ASSERT_TRUE(pref);
101 EXPECT_TRUE(pref->IsExtensionControlled());
102 EXPECT_FALSE(otr_prefs->GetBoolean(prefs::kBlockThirdPartyCookies));
103
104 pref = prefs->FindPreference(prefs::kBlockThirdPartyCookies);
105 ASSERT_TRUE(pref);
106 EXPECT_FALSE(pref->IsExtensionControlled());
107 EXPECT_FALSE(prefs->GetBoolean(prefs::kBlockThirdPartyCookies));
108 }
109
110 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PreferenceClear) {
111 CommandLine::ForCurrentProcess()->AppendSwitch(
112 switches::kEnableExperimentalExtensionApis);
113
114 PrefService* pref_service = browser()->profile()->GetPrefs();
115 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true);
116
117 EXPECT_TRUE(RunExtensionTest("preference/clear")) << message_;
118
119 const PrefService::Preference* pref = pref_service->FindPreference(
120 prefs::kBlockThirdPartyCookies);
121 ASSERT_TRUE(pref);
122 EXPECT_FALSE(pref->IsExtensionControlled());
123 EXPECT_EQ(true, pref_service->GetBoolean(prefs::kBlockThirdPartyCookies));
124 }
125
126 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PreferenceOnChange) {
127 CommandLine::ForCurrentProcess()->AppendSwitch(
128 switches::kEnableExperimentalExtensionApis);
129
130 PrefService* prefs = browser()->profile()->GetPrefs();
131 prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false);
132
133 EXPECT_TRUE(RunExtensionTestIncognito("preference/onchange")) <<
134 message_;
135 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_preference_api.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698