Bug 1508726 - Prevent application updates when Marionette is enabled. r=bytesized
authorHenrik Skupin <mail@hskupin.info>
Tue, 04 Dec 2018 19:10:18 +0000
changeset 508516 ffc42da8138efd66299329615945c433bcafc2da
parent 508515 5556b6a018243b63071959430e5c496e5c9e2c94
child 508517 81a6b32f2a8bf8e8579ecc6ae81ae7f0d12f0d91
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbytesized
bugs1508726
milestone65.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 1508726 - Prevent application updates when Marionette is enabled. r=bytesized Marionette is a remote protocol which allows to automate the application. Because it is not only run in CI automation but also by users outside of the tree, the flag "Cu.isInAutomation" cannot be used to determine if updates can be downloaded and installed. But it can b achieved by relying on the "running" state as exposed by Marionette through the nsIMarionette interface. Differential Revision: https://phabricator.services.mozilla.com/D13515
toolkit/mozapps/update/nsUpdateService.js
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -2427,17 +2427,24 @@ UpdateService.prototype = {
    */
   get backgroundChecker() {
     if (!this._backgroundChecker)
       this._backgroundChecker = new Checker();
     return this._backgroundChecker;
   },
 
   get disabledForTesting() {
-    return Cu.isInAutomation &&
+    let marionetteRunning = false;
+
+    if ("nsIMarionette" in Ci) {
+      marionetteRunning = Cc["@mozilla.org/remote/marionette;1"].
+                          createInstance(Ci.nsIMarionette).running;
+    }
+
+    return (Cu.isInAutomation || marionetteRunning) &&
            Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false);
   },
 
   get disabledByPolicy() {
     return (Services.policies && !Services.policies.isAllowed("appUpdate")) ||
            this.disabledForTesting;
   },
 
@@ -3109,16 +3116,17 @@ Checker.prototype = {
     if (!listener) {
       throw Cr.NS_ERROR_NULL_POINTER;
     }
 
     let UpdateServiceInstance = UpdateServiceFactory.createInstance();
     // |force| can override |canCheckForUpdates| since |force| indicates a
     // manual update check. But nothing should override enterprise policies.
     if (UpdateServiceInstance.disabledByPolicy) {
+      LOG("Checker: checkForUpdates, disabled by policy");
       return;
     }
     if (!UpdateServiceInstance.canCheckForUpdates && !force) {
       return;
     }
 
     this.getUpdateURL(force).then(url => {
       if (!url) {