Bug 826146 - Add a pref-controlled install confirmation override for automation. r=sicking
☠☠ backed out by e9cbccc2814c ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Thu, 03 Jan 2013 18:27:43 -0800
changeset 126646 1024e72d4ef9e650369e99a80756cb0b09334554
parent 126645 40025046531f8f0bfcb43fe5d78d6642dc4e4a46
child 126647 f0c778cd83a1074ed337766501c55ba3336fe472
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs826146
milestone20.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 826146 - Add a pref-controlled install confirmation override for automation. r=sicking
dom/apps/src/Webapps.jsm
testing/specialpowers/content/specialpowersAPI.js
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -1377,18 +1377,24 @@ this.DOMApplicationRegistry = {
         if (!AppsUtils.checkManifest(app.manifest)) {
           sendError("INVALID_MANIFEST");
         } else if (!AppsUtils.checkInstallAllowed(app.manifest, app.installOrigin)) {
           sendError("INSTALL_FROM_DENIED");
         } else if (!checkAppStatus(app.manifest)) {
           sendError("INVALID_SECURITY_LEVEL");
         } else {
           app.etag = xhr.getResponseHeader("Etag");
-          Services.obs.notifyObservers(aMm, "webapps-ask-install",
-                                       JSON.stringify(aData));
+          // We allow bypassing the install confirmation process to facilitate
+          // automation.
+          if (Services.prefs.getBoolPref("dom.mozApps.auto_confirm_install")) {
+            this.confirmInstall(aData);
+          } else {
+            Services.obs.notifyObservers(aMm, "webapps-ask-install",
+                                         JSON.stringify(aData));
+          }
         }
       } else {
         sendError("MANIFEST_URL_ERROR");
       }
     }).bind(this), false);
 
     xhr.addEventListener("error", (function() {
       sendError("NETWORK_ERROR");
--- a/testing/specialpowers/content/specialpowersAPI.js
+++ b/testing/specialpowers/content/specialpowersAPI.js
@@ -714,16 +714,24 @@ SpecialPowersAPI.prototype = {
       if (pref.action == 'set') {
         this._setPref(pref.name, pref.type, pref.value, pref.Iid);
       } else if (pref.action == 'clear') {
         this.clearUserPref(pref.name);
       }
     }
   },
 
+  // Disables the app install prompt for the duration of this test. There is
+  // no need to re-enable the prompt at the end of the test.
+  //
+  // The provided callback is invoked once the prompt is disabled.
+  autoConfirmAppInstall: function(cb) {
+    this.pushPrefEnv({set: [['dom.mozApps.auto_confirm_install', true]]}, cb);
+  },
+
   addObserver: function(obs, notification, weak) {
     var obsvc = Cc['@mozilla.org/observer-service;1']
                    .getService(Ci.nsIObserverService);
     obsvc.addObserver(obs, notification, weak);
   },
   removeObserver: function(obs, notification) {
     var obsvc = Cc['@mozilla.org/observer-service;1']
                    .getService(Ci.nsIObserverService);