Bug 1568994 - Convert Enterprise policy AppUpdateURL to work with the new update url mechanism r=mkaply,mhowell
authorKirk Steuber <ksteuber@mozilla.com>
Tue, 24 Mar 2020 22:03:27 +0000
changeset 520586 cd6bf21b54db5f25518fa4f0d60e0827bbbdc44b
parent 520585 12efcfc5555aa400a3ee7fdbc8f178a908f4a4c9
child 520587 270ba3bd1c225c47ac7669b161b74b671d8f0cc3
push id37253
push usernerli@mozilla.com
push dateThu, 26 Mar 2020 21:36:52 +0000
treeherdermozilla-central@c644dd16e2cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkaply, mhowell
bugs1568994
milestone76.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 1568994 - Convert Enterprise policy AppUpdateURL to work with the new update url mechanism r=mkaply,mhowell Differential Revision: https://phabricator.services.mozilla.com/D45869
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/tests/xpcshell/test_appupdateurl.js
toolkit/mozapps/update/UpdateService.jsm
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -85,19 +85,18 @@ var Policies = {
         manager.disallowFeature("app-auto-updates-off");
       } else {
         manager.disallowFeature("app-auto-updates-on");
       }
     },
   },
 
   AppUpdateURL: {
-    onBeforeAddons(manager, param) {
-      setDefaultPref("app.update.url", param.href);
-    },
+    // No implementation needed here. UpdateService.jsm will check for this
+    // policy directly when determining the update URL.
   },
 
   Authentication: {
     onBeforeAddons(manager, param) {
       let locked = true;
       if ("Locked" in param) {
         locked = param.Locked;
       }
--- a/browser/components/enterprisepolicies/tests/xpcshell/test_appupdateurl.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_appupdateurl.js
@@ -1,25 +1,27 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
+let { Checker } = ChromeUtils.import(
+  "resource://gre/modules/UpdateService.jsm"
+);
+
 add_task(async function test_app_update_URL() {
   await setupPolicyEngineWithJson({
     policies: {
       AppUpdateURL: "https://www.example.com/",
     },
   });
 
   equal(
     Services.policies.status,
     Ci.nsIEnterprisePolicies.ACTIVE,
     "Engine is active"
   );
 
-  // The app.update.url preference is read from the default preferences.
-  let expected = Services.prefs
-    .getDefaultBranch(null)
-    .getCharPref("app.update.url", undefined);
+  let checker = new Checker();
+  let expected = await checker.getUpdateURL();
 
   equal("https://www.example.com/", expected, "Correct app update URL");
 });
--- a/toolkit/mozapps/update/UpdateService.jsm
+++ b/toolkit/mozapps/update/UpdateService.jsm
@@ -3858,16 +3858,23 @@ Checker.prototype = {
    * The URL of the update service XML file to connect to that contains details
    * about available updates.
    */
   getUpdateURL: async function UC_getUpdateURL(force) {
     this._forced = force;
 
     let url = Services.appinfo.updateURL;
 
+    if (Services.policies) {
+      let policies = Services.policies.getActivePolicies();
+      if (policies && "AppUpdateURL" in policies) {
+        url = policies.AppUpdateURL.toString();
+      }
+    }
+
     if (!url) {
       LOG("Checker:getUpdateURL - update URL not defined");
       return null;
     }
 
     url = await UpdateUtils.formatUpdateURL(url);
 
     if (force) {