Bug 587523 - rename referer.userControlPolicy to referer.defaultPolicy r=valentin
authorLuke Crouch <lcrouch@mozilla.com>
Wed, 10 Jan 2018 16:51:10 -0600
changeset 454395 127b3aee4a44ad5cba661cc0f2d00988c368e0ed
parent 454394 36474234a91822bf90d89f5fb67245b9dd2d5f6f
child 454396 3259f30e0fd5b4b28db3145a989d70feaab66b3d
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs587523
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 587523 - rename referer.userControlPolicy to referer.defaultPolicy r=valentin MozReview-Commit-ID: A2hkYfdTCR9
dom/tests/mochitest/fetch/test_fetch_user_control_rp.html
modules/libpref/init/all.js
netwerk/base/nsNetUtil.cpp
netwerk/base/nsNetUtil.h
netwerk/test/mochitests/test_origin_header.html
netwerk/test/unit/test_referrer.js
netwerk/test/unit/test_referrer_policy.js
--- a/dom/tests/mochitest/fetch/test_fetch_user_control_rp.html
+++ b/dom/tests/mochitest/fetch/test_fetch_user_control_rp.html
@@ -6,32 +6,32 @@
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     <script type="application/javascript">
   const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
   const PARAMS = ["SCHEME_FROM", "SCHEME_TO"];
 
   const testCases = [
     {ACTION: ["generate-fetch-user-control-policy-test"],
-      PREFS: [['network.http.referer.userControlPolicy', 0]],
+      PREFS: [['network.http.referer.defaultPolicy', 0]],
       TESTS: [
          // 0. No referrer.
         {NAME: 'default-policy-value-no-referrer-https-http',
          DESC: 'default-policy-value-no-referrer-https-http',
          SCHEME_FROM: 'https',
          SCHEME_TO: 'http',
          RESULT: 'none'},
         {NAME: 'default-policy-value-no-referrer-https-https',
          DESC: 'default-policy-value-no-referrer-https-https',
          SCHEME_FROM: 'https',
          SCHEME_TO: 'https',
          RESULT: 'none'}],
     },
     {ACTION: ["generate-fetch-user-control-policy-test"],
-      PREFS: [['network.http.referer.userControlPolicy', 1]],
+      PREFS: [['network.http.referer.defaultPolicy', 1]],
       TESTS: [
          // 1. Same origin.
         {NAME: 'default-policy-value-same-origin-https-http',
          DESC: 'default-policy-value-same-origin-https-http',
          SCHEME_FROM: 'https',
          SCHEME_TO: 'http',
          RESULT: 'none'},
         {NAME: 'default-policy-value-same-origin-http-https',
@@ -41,17 +41,17 @@
          RESULT: 'none'},
         {NAME: 'default-policy-value-same-origin-https-https',
          DESC: 'default-policy-value-same-origin-https-https',
          SCHEME_FROM: 'https',
          SCHEME_TO: 'https',
          RESULT: 'full'}],
     },
     {ACTION: ["generate-fetch-user-control-policy-test"],
-      PREFS: [['network.http.referer.userControlPolicy', 2]],
+      PREFS: [['network.http.referer.defaultPolicy', 2]],
       TESTS: [
          // 2. strict-origin-when-cross-origin.
         {NAME: 'default-policy-value-strict-origin-when-cross-origin-https-http',
          DESC: 'default-policy-value-strict-origin-when-cross-origin-https-http',
          SCHEME_FROM: 'https',
          SCHEME_TO: 'http',
          RESULT: 'none'},
         {NAME: 'default-policy-value-strict-origin-when-cross-origin-http-https',
@@ -61,17 +61,17 @@
          RESULT: 'origin'},
         {NAME: 'default-policy-value-strict-origin-when-cross-origin-https-https',
          DESC: 'default-policy-value-strict-origin-when-cross-origin-https-https',
          SCHEME_FROM: 'https',
          SCHEME_TO: 'https',
          RESULT: 'full'}],
     },
     {ACTION: ["generate-fetch-user-control-policy-test"],
-      PREFS: [['network.http.referer.userControlPolicy', 3]],
+      PREFS: [['network.http.referer.defaultPolicy', 3]],
       TESTS: [
          // 3. Default no-referrer-when-downgrade.
         {NAME: 'default-policy-value-no-referrer-when-downgrade-https-http',
          DESC: 'default-policy-value-no-referrer-when-downgrade-https-http',
          SCHEME_FROM: 'https',
          SCHEME_TO: 'http',
          RESULT: 'none'},
         {NAME: 'default-policy-value-no-referrer-when-downgrade-http-https',
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1697,17 +1697,17 @@ pref("network.http.request.max-attempts"
 pref("network.http.accept.default", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
 
 // Prefs allowing granular control of referers
 // 0=don't send any, 1=send only on clicks, 2=send on image requests as well
 pref("network.http.sendRefererHeader",      2);
 // Set the default Referrer Policy; to be used unless overriden by the site
 // 0=no-referrer, 1=same-origin, 2=strict-origin-when-cross-origin,
 // 3=no-referrer-when-downgrade
-pref("network.http.referer.userControlPolicy", 3);
+pref("network.http.referer.defaultPolicy", 3);
 // Set the Private Browsing Defaul Referrer Policy;
 // to be used unless overriden by the site;
 // values are identical to defaultPolicy above
 pref("network.http.referer.defaultPolicy.pbmode", 2);
 // false=real referer, true=spoof referer (use target URI as referer)
 pref("network.http.referer.spoofSource", false);
 // false=allow onion referer, true=hide onion referer (use empty referer)
 pref("network.http.referer.hideOnionSource", false);
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -78,21 +78,21 @@
 #include "nsICertBlocklist.h"
 #include "nsICertOverrideService.h"
 
 #include <limits>
 
 using namespace mozilla;
 using namespace mozilla::net;
 
-#define DEFAULT_USER_CONTROL_RP 3
-#define DEFAULT_USER_CONTROL_PRIVATE_RP 2
-
-static uint32_t sUserControlRp = DEFAULT_USER_CONTROL_RP;
-static uint32_t sUserControlPrivateRp = DEFAULT_USER_CONTROL_PRIVATE_RP;
+#define DEFAULT_RP 3
+#define DEFAULT_PRIVATE_RP 2
+
+static uint32_t sDefaultRp = DEFAULT_RP;
+static uint32_t defaultPrivateRp = DEFAULT_PRIVATE_RP;
 
 already_AddRefed<nsIIOService>
 do_GetIOService(nsresult *error /* = 0 */)
 {
     nsCOMPtr<nsIIOService> io = mozilla::services::GetIOService();
     if (error)
         *error = io ? NS_OK : NS_ERROR_FAILURE;
     return io.forget();
@@ -2975,30 +2975,30 @@ NS_CompareLoadInfoAndLoadContext(nsIChan
 }
 
 uint32_t
 NS_GetDefaultReferrerPolicy(bool privateBrowsing)
 {
   static bool preferencesInitialized = false;
 
   if (!preferencesInitialized) {
-    mozilla::Preferences::AddUintVarCache(&sUserControlRp,
-                                          "network.http.referer.userControlPolicy",
-                                          DEFAULT_USER_CONTROL_RP);
-    mozilla::Preferences::AddUintVarCache(&sUserControlPrivateRp,
+    mozilla::Preferences::AddUintVarCache(&sDefaultRp,
+                                          "network.http.referer.defaultPolicy",
+                                          DEFAULT_RP);
+    mozilla::Preferences::AddUintVarCache(&defaultPrivateRp,
                                           "network.http.referer.defaultPolicy.pbmode",
-                                          DEFAULT_USER_CONTROL_PRIVATE_RP);
+                                          DEFAULT_PRIVATE_RP);
     preferencesInitialized = true;
   }
 
   uint32_t defaultToUse;
   if (privateBrowsing) {
-      defaultToUse = sUserControlPrivateRp;
+      defaultToUse = defaultPrivateRp;
   } else {
-      defaultToUse = sUserControlRp;
+      defaultToUse = sDefaultRp;
   }
 
   switch (defaultToUse) {
     case 0:
       return nsIHttpChannel::REFERRER_POLICY_NO_REFERRER;
     case 1:
       return nsIHttpChannel::REFERRER_POLICY_SAME_ORIGIN;
     case 2:
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -931,18 +931,18 @@ nsresult NS_ShouldSecureUpgrade(nsIURI* 
  */
 nsresult NS_GetSecureUpgradedURI(nsIURI* aURI, nsIURI** aUpgradedURI);
 
 nsresult NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel);
 
 /**
  * Return default referrer policy which is controlled by user
  * prefs:
- * network.http.referer.userControlPolicy for regular mode
- * network.http.referer.userControlPrivatePolicy for private mode
+ * network.http.referer.defaultPolicy for regular mode
+ * network.http.referer.defaultPolicy.pbmode for private mode
  */
 uint32_t NS_GetDefaultReferrerPolicy(bool privateBrowsing = false);
 
 namespace mozilla {
 namespace net {
 
 const static uint64_t kJS_MAX_SAFE_UINTEGER = +9007199254740991ULL;
 const static  int64_t kJS_MIN_SAFE_INTEGER  = -9007199254740991LL;
--- a/netwerk/test/mochitests/test_origin_header.html
+++ b/netwerk/test/mochitests/test_origin_header.html
@@ -84,17 +84,17 @@ let testsToRun = [
             framePostSrcDocXOrigin: "Origin: http://mochi.test:8888",
             framePostDataURI: "Origin: null",
         },
     },
     {
         name: "userControlPolicy=0 (no-referrer)",
         prefs: [
             ["network.http.sendRefererHeader", 2],
-            ["network.http.referer.userControlPolicy", 0],
+            ["network.http.referer.defaultPolicy", 0],
         ],
         results: {
             framePost: "Origin: http://mochi.test:8888",
             framePostXOrigin: "Origin: http://mochi.test:8888",
             frameGet: EMPTY_ORIGIN,
             framePostNonSandboxed: "Origin: http://mochi.test:8888",
             framePostNonSandboxedXOrigin: "Origin: http://mochi.test:8888",
             framePostSandboxed: "Origin: null",
--- a/netwerk/test/unit/test_referrer.js
+++ b/netwerk/test/unit/test_referrer.js
@@ -42,29 +42,29 @@ function run_test() {
   prefs.setIntPref("network.http.sendRefererHeader", 0);
   Assert.equal(null, getTestReferrer(server_uri, referer_uri));
   prefs.setIntPref("network.http.sendRefererHeader", 2);
   Assert.equal(getTestReferrer(server_uri, referer_uri), referer_uri);
 
   // test that https ref is not sent to http
   Assert.equal(null, getTestReferrer(server_uri_2, referer_uri_https));
 
-  // tests for referer.userControlPolicy
-  prefs.setIntPref("network.http.referer.userControlPolicy", 0);
+  // tests for referer.defaultPolicy
+  prefs.setIntPref("network.http.referer.defaultPolicy", 0);
   Assert.equal(null, getTestReferrer(server_uri, referer_uri));
-  prefs.setIntPref("network.http.referer.userControlPolicy", 1);
+  prefs.setIntPref("network.http.referer.defaultPolicy", 1);
   Assert.equal(null, getTestReferrer(server_uri, referer_uri));
   Assert.equal(getTestReferrer(server_uri, referer_uri_2), referer_uri_2);
-  prefs.setIntPref("network.http.referer.userControlPolicy", 2);
+  prefs.setIntPref("network.http.referer.defaultPolicy", 2);
   Assert.equal(null, getTestReferrer(server_uri, referer_uri_https));
   Assert.equal(getTestReferrer(server_uri_https, referer_uri_https), referer_uri_https);
   Assert.equal(getTestReferrer(server_uri_https, referer_uri_2_https), "https://bar.examplesite.com/");
   Assert.equal(getTestReferrer(server_uri, referer_uri_2), referer_uri_2);
   Assert.equal(getTestReferrer(server_uri, referer_uri), "http://foo.example.com/");
-  prefs.setIntPref("network.http.referer.userControlPolicy", 3);
+  prefs.setIntPref("network.http.referer.defaultPolicy", 3);
   Assert.equal(getTestReferrer(server_uri, referer_uri), referer_uri);
   Assert.equal(null, getTestReferrer(server_uri_2, referer_uri_https));
 
   // tests for referer.spoofSource
   prefs.setBoolPref("network.http.referer.spoofSource", true);
   Assert.equal(getTestReferrer(server_uri, referer_uri), server_uri);
   prefs.setBoolPref("network.http.referer.spoofSource", false);
   Assert.equal(getTestReferrer(server_uri, referer_uri), referer_uri);
--- a/netwerk/test/unit/test_referrer_policy.js
+++ b/netwerk/test/unit/test_referrer_policy.js
@@ -1,20 +1,20 @@
 Cu.import("resource://gre/modules/NetUtil.jsm");
 
 function test_policy(test) {
   info("Running test: " + test.toSource());
 
   var prefs = Cc["@mozilla.org/preferences-service;1"]
     .getService(Components.interfaces.nsIPrefBranch);
   if (test.defaultReferrerPolicyPref !== undefined) {
-    prefs.setIntPref("network.http.referer.userControlPolicy",
+    prefs.setIntPref("network.http.referer.defaultPolicy",
                      test.defaultReferrerPolicyPref);
   } else {
-    prefs.setIntPref("network.http.referer.userControlPolicy", 3);
+    prefs.setIntPref("network.http.referer.defaultPolicy", 3);
   }
 
   var uri = NetUtil.newURI(test.url)
   var chan = NetUtil.newChannel({
     uri: uri,
     loadUsingSystemPrincipal: true
   });