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

Unified Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2030193004: Add a policy for disabling the stripping of PAC URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add better documentatiob Created 4 years, 6 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/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index b3aaa9de541f352640e94aa4505e11d584965ab5..3e34b3d9f3a5caef9c2d7f0752e57eea478dffb5 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -54,6 +54,7 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/interstitials/security_interstitial_page.h"
#include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
+#include "chrome/browser/io_thread.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/media_stream_devices_controller.h"
#include "chrome/browser/metrics/variations/chrome_variations_service_client.h"
@@ -1352,6 +1353,48 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DisableSpdy) {
EXPECT_TRUE(net::HttpStreamFactory::spdy_enabled());
}
+namespace {
+
+// The following helpers retrieve whether https:// URL stripping is
+// enabled for PAC scripts. It needs to run on the IO thread.
+void GetPacHttpsUrlStrippingEnabledOnIOThread(IOThread* io_thread,
+ bool* enabled) {
+ *enabled = io_thread->PacHttpsUrlStrippingEnabled();
+}
+
+bool GetPacHttpsUrlStrippingEnabled() {
+ bool enabled;
+ base::RunLoop loop;
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&GetPacHttpsUrlStrippingEnabledOnIOThread,
+ g_browser_process->io_thread(), base::Unretained(&enabled)),
+ loop.QuitClosure());
+ loop.Run();
+ return enabled;
+}
+
+} // namespace
+
+// Verifies that stripping of https:// URLs before sending to PAC scripts can
+// be disabled via a policy. Also verifies that stripping is enabled by
+// default.
+IN_PROC_BROWSER_TEST_F(PolicyTest, DisablePacHttpsUrlStripping) {
+ // Stripping is enabled by default.
+ EXPECT_TRUE(GetPacHttpsUrlStrippingEnabled());
+
+ // Disable it via a policy.
+ PolicyMap policies;
+ policies.Set(key::kPacHttpsUrlStrippingEnabled, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
+ base::WrapUnique(new base::FundamentalValue(false)), nullptr);
+ UpdateProviderPolicy(policies);
+ content::RunAllPendingInMessageLoop();
+
+ // It should now reflect as disabled.
+ EXPECT_FALSE(GetPacHttpsUrlStrippingEnabled());
+}
+
IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) {
// Verifies that plugins can be forced to be disabled by policy.
« no previous file with comments | « chrome/browser/policy/configuration_policy_handler_list_factory.cc ('k') | chrome/browser/prefs/command_line_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698