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

Unified Diff: chrome/browser/extensions/api/proxy/proxy_apitest.cc

Issue 184043024: Limit scope of settings API configuration and proxy permission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Bernhard's comment Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/proxy/proxy_apitest.cc
diff --git a/chrome/browser/extensions/api/proxy/proxy_apitest.cc b/chrome/browser/extensions/api/proxy/proxy_apitest.cc
index 18a62ddb111f1ec36fb5020bb3ea518be3121e6d..16365526409e31dc5285083f5bb538cd912f5e6d 100644
--- a/chrome/browser/extensions/api/proxy/proxy_apitest.cc
+++ b/chrome/browser/extensions/api/proxy/proxy_apitest.cc
@@ -4,6 +4,7 @@
#include "base/prefs/pref_service.h"
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/prefs/proxy_config_dictionary.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -68,6 +69,17 @@ class ProxySettingsApiTest : public ExtensionApiTest {
ASSERT_TRUE(pref != NULL);
EXPECT_FALSE(pref->IsExtensionControlled());
}
+
+ bool SetIsIncognitoEnabled(bool enabled) {
+ ResultCatcher catcher;
+ extensions::util::SetIsIncognitoEnabled(
+ GetSingleLoadedExtension()->id(), browser()->profile(), enabled);
+ if (!catcher.GetNextResult()) {
+ message_ = catcher.message();
+ return false;
+ }
+ return true;
+ }
};
// Tests direct connection settings.
@@ -79,6 +91,12 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyDirectSettings) {
PrefService* pref_service = browser()->profile()->GetPrefs();
ValidateSettings(ProxyPrefs::MODE_DIRECT, kNoServer, kNoBypass, kNoPac,
pref_service);
+
+ // As the extension is executed with incognito permission, the settings
+ // should propagate to incognito mode.
+ pref_service = browser()->profile()->GetOffTheRecordProfile()->GetPrefs();
+ ValidateSettings(ProxyPrefs::MODE_DIRECT, kNoServer, kNoBypass, kNoPac,
+ pref_service);
}
// Tests auto-detect settings.
@@ -101,6 +119,22 @@ IN_PROC_BROWSER_TEST_F(ProxySettingsApiTest, ProxyPacScript) {
PrefService* pref_service = browser()->profile()->GetPrefs();
ValidateSettings(ProxyPrefs::MODE_PAC_SCRIPT, kNoServer, kNoBypass,
"http://wpad/windows.pac", pref_service);
+
+ // As the extension is not executed with incognito permission, the settings
+ // should not propagate to incognito mode.
+ pref_service = browser()->profile()->GetOffTheRecordProfile()->GetPrefs();
+ ExpectNoSettings(pref_service);
+
+ // Now we enable the extension in incognito mode and verify that settings
+ // are applied.
+ ASSERT_TRUE(SetIsIncognitoEnabled(true));
+ ValidateSettings(ProxyPrefs::MODE_PAC_SCRIPT, kNoServer, kNoBypass,
+ "http://wpad/windows.pac", pref_service);
+
+ // Disabling incognito permission should revoke the settings for incognito
+ // mode.
+ ASSERT_TRUE(SetIsIncognitoEnabled(false));
+ ExpectNoSettings(pref_service);
}
// Tests PAC proxy settings.

Powered by Google App Engine
This is Rietveld 408576698