OLD | NEW |
(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 "chrome/browser/extensions/extension_apitest.h" |
| 6 #include "chrome/browser/prefs/pref_service.h" |
| 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/pref_names.h" |
| 11 |
| 12 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { |
| 13 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 14 switches::kEnableExperimentalExtensionApis); |
| 15 |
| 16 PrefService* pref_service = browser()->profile()->GetPrefs(); |
| 17 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true); |
| 18 |
| 19 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; |
| 20 |
| 21 const PrefService::Preference* pref = pref_service->FindPreference( |
| 22 prefs::kBlockThirdPartyCookies); |
| 23 ASSERT_TRUE(pref); |
| 24 EXPECT_TRUE(pref->IsExtensionControlled()); |
| 25 EXPECT_EQ(false, pref_service->GetBoolean(prefs::kBlockThirdPartyCookies)); |
| 26 } |
| 27 |
| 28 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoContentSettings) { |
| 29 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 30 switches::kEnableExperimentalExtensionApis); |
| 31 |
| 32 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 33 prefs->SetBoolean(prefs::kBlockThirdPartyCookies, false); |
| 34 |
| 35 EXPECT_TRUE(RunExtensionTest("content_settings/incognito")) << message_; |
| 36 |
| 37 // Setting an incognito preference should not create an incognito profile. |
| 38 EXPECT_FALSE(browser()->profile()->HasOffTheRecordProfile()); |
| 39 |
| 40 PrefService* otr_prefs = |
| 41 browser()->profile()->GetOffTheRecordProfile()->GetPrefs(); |
| 42 const PrefService::Preference* pref = |
| 43 otr_prefs->FindPreference(prefs::kBlockThirdPartyCookies); |
| 44 ASSERT_TRUE(pref); |
| 45 EXPECT_TRUE(pref->IsExtensionControlled()); |
| 46 EXPECT_EQ(true, otr_prefs->GetBoolean(prefs::kBlockThirdPartyCookies)); |
| 47 |
| 48 pref = prefs->FindPreference(prefs::kBlockThirdPartyCookies); |
| 49 ASSERT_TRUE(pref); |
| 50 EXPECT_FALSE(pref->IsExtensionControlled()); |
| 51 EXPECT_EQ(false, prefs->GetBoolean(prefs::kBlockThirdPartyCookies)); |
| 52 } |
OLD | NEW |