Bug 1508961 - Don't prematurely check for permissions in pushManager.subscribe() permission requests. r=lina a=pascalc
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 05 Apr 2019 10:22:21 +0000
changeset 526330 45360f538e3d4c6e1672a2b2c9bd343ba49c61ec
parent 526329 4b5a567ae62d4a2b1d18e7adf37802dc1052d9f6
child 526331 f71a18e81a6989dfd853195cb5abd0de7df068fa
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslina, pascalc
bugs1508961
milestone67.0
Bug 1508961 - Don't prematurely check for permissions in pushManager.subscribe() permission requests. r=lina a=pascalc This permission checking should be handled by PermissionUI.jsm, to be able to apply custom heuristics for denying the permission and also to be able to "post-prompt" after denying automatically. Differential Revision: https://phabricator.services.mozilla.com/D25416
dom/push/Push.jsm
--- a/dom/push/Push.jsm
+++ b/dom/push/Push.jsm
@@ -65,31 +65,21 @@ Push.prototype = {
     return this.createPromise((resolve, reject) => {
       let permissionDenied = () => {
         reject(new this._window.DOMException(
           "User denied permission to use the Push API.",
           "NotAllowedError"
         ));
       };
 
-      let permission = Ci.nsIPermissionManager.UNKNOWN_ACTION;
-      try {
-        permission = this._testPermission();
-      } catch (e) {
-        permissionDenied();
-        return;
+      if (Services.prefs.getBoolPref("dom.push.testing.ignorePermission", false)) {
+        resolve();
       }
 
-      if (permission == Ci.nsIPermissionManager.ALLOW_ACTION) {
-        resolve();
-      } else if (permission == Ci.nsIPermissionManager.DENY_ACTION) {
-        permissionDenied();
-      } else {
-        this._requestPermission(isHandlingUserInput, resolve, permissionDenied);
-      }
+      this._requestPermission(isHandlingUserInput, resolve, permissionDenied);
     });
   },
 
   subscribe: function(options) {
     console.debug("subscribe()", this._scope);
 
     return this.askPermission().then(() =>
       this.createPromise((resolve, reject) => {