Bug 1192458, Part 1 - Consolidate push and desktop notification permissions. r=nsm,wchen,MattN
authorKit Cambridge <kcambridge@mozilla.com>
Mon, 05 Oct 2015 16:39:34 -0700
changeset 299525 dbd2cecedbe3650c74e895dcec479b49af0c08ea
parent 299524 4fb5f812f7c99c51373855ab26ba95007f71d93d
child 299526 8c261f0d4d3e47e04690824c953b5f8471ddd73e
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnsm, wchen, MattN
bugs1192458
milestone44.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 1192458, Part 1 - Consolidate push and desktop notification permissions. r=nsm,wchen,MattN
browser/base/content/browser.xul
browser/components/nsBrowserGlue.js
browser/components/preferences/aboutPermissions.js
browser/components/preferences/aboutPermissions.xul
browser/components/preferences/in-content/tests/browser_permissions.js
browser/locales/en-US/chrome/browser/browser.properties
browser/locales/en-US/chrome/browser/preferences/aboutPermissions.dtd
browser/locales/en-US/chrome/browser/sitePermissions.properties
browser/modules/SitePermissions.jsm
browser/modules/test/xpcshell/test_SitePermissions.js
browser/themes/linux/Push-16.png
browser/themes/linux/Push-64.png
browser/themes/linux/jar.mn
browser/themes/linux/preferences/aboutPermissions.css
browser/themes/osx/Push-16.png
browser/themes/osx/Push-16@2x.png
browser/themes/osx/Push-64.png
browser/themes/osx/Push-64@2x.png
browser/themes/osx/jar.mn
browser/themes/osx/preferences/aboutPermissions.css
browser/themes/shared/notification-icons.inc.css
browser/themes/windows/Push-16.png
browser/themes/windows/Push-64.png
browser/themes/windows/jar.mn
browser/themes/windows/preferences/aboutPermissions.css
dom/notification/Notification.cpp
dom/permission/PermissionUtils.cpp
dom/permission/tests/test_permissions_api.html
dom/push/Push.js
dom/push/PushManager.cpp
dom/push/PushRecord.jsm
dom/push/test/test_data.html
dom/push/test/test_has_permissions.html
dom/push/test/test_multiple_register.html
dom/push/test/test_multiple_register_different_scope.html
dom/push/test/test_multiple_register_during_service_activation.html
dom/push/test/test_permissions.html
dom/push/test/test_register.html
dom/push/test/test_try_registering_offline_disabled.html
dom/push/test/test_unregister.html
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -708,17 +708,16 @@
                      ontextreverted="return this.handleRevert();"
                      pageproxystate="invalid"
                      onfocus="document.getElementById('identity-box').style.MozUserFocus= 'normal'"
                      onblur="setTimeout(() => { document.getElementById('identity-box').style.MozUserFocus = ''; }, 0);">
               <box id="notification-popup-box" hidden="true" align="center">
                 <image id="default-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="identity-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="geo-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="push-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="addons-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="indexedDB-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="login-fill-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="password-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="webapps-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="plugins-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="web-notifications-notification-icon" class="notification-anchor-icon" role="button"/>
                 <image id="webRTC-shareDevices-notification-icon" class="notification-anchor-icon" role="button"/>
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -2547,48 +2547,16 @@ ContentPermissionPrompt.prototype = {
     if (!aOptions)
       aOptions = {};
     aOptions.displayURI = requestPrincipal.URI;
 
     return chromeWin.PopupNotifications.show(browser, aNotificationId, aMessage, aAnchorId,
                                              mainAction, secondaryActions, aOptions);
   },
 
-  _promptPush : function(aRequest) {
-    var message = gBrowserBundle.GetStringFromName("push.enablePush2");
-
-    var actions = [
-    {
-      stringId: "push.alwaysAllow",
-      action: Ci.nsIPermissionManager.ALLOW_ACTION,
-      expireType: null,
-      callback: function() {}
-    },
-    {
-      stringId: "push.allowForSession",
-      action: Ci.nsIPermissionManager.ALLOW_ACTION,
-      expireType: Ci.nsIPermissionManager.EXPIRE_SESSION,
-      callback: function() {}
-    },
-    {
-      stringId: "push.alwaysBlock",
-      action: Ci.nsIPermissionManager.DENY_ACTION,
-      expireType: null,
-      callback: function() {}
-    }]
-
-    var options = {
-      learnMoreURL: Services.urlFormatter.formatURLPref("browser.push.warning.infoURL"),
-    };
-
-    this._showPrompt(aRequest, message, "push", actions, "push",
-                     "push-notification-icon", options);
-
-  },
-
   _promptGeo : function(aRequest) {
     var secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
 
     var message;
 
     // Share location action.
     var actions = [{
       stringId: "geolocation.shareLocation",
@@ -2634,38 +2602,36 @@ ContentPermissionPrompt.prototype = {
                      "geo-notification-icon", options);
   },
 
   _promptWebNotifications : function(aRequest) {
     var message = gBrowserBundle.GetStringFromName("webNotifications.showFromSite2");
 
     var actions = [
       {
-        stringId: "webNotifications.showForSession",
-        action: Ci.nsIPermissionManager.ALLOW_ACTION,
-        expireType: Ci.nsIPermissionManager.EXPIRE_SESSION,
-        callback: function() {},
-      },
-      {
         stringId: "webNotifications.alwaysShow",
         action: Ci.nsIPermissionManager.ALLOW_ACTION,
         expireType: null,
         callback: function() {},
       },
       {
         stringId: "webNotifications.neverShow",
         action: Ci.nsIPermissionManager.DENY_ACTION,
         expireType: null,
         callback: function() {},
       },
     ];
 
+    var options = {
+      learnMoreURL: Services.urlFormatter.formatURLPref("browser.push.warning.infoURL"),
+    };
+
     this._showPrompt(aRequest, message, "desktop-notification", actions,
                      "web-notifications",
-                     "web-notifications-notification-icon", null);
+                     "web-notifications-notification-icon", options);
   },
 
   _promptPointerLock: function CPP_promtPointerLock(aRequest, autoAllow) {
     let message = gBrowserBundle.GetStringFromName(autoAllow ?
                                   "pointerLock.autoLock.title3" : "pointerLock.title3");
 
     // If this is an autoAllow info prompt, offer no actions.
     // _showPrompt() will allow the request when it's dismissed.
@@ -2726,17 +2692,16 @@ ContentPermissionPrompt.prototype = {
       request.cancel();
       return;
     }
     let perm = types.queryElementAt(0, Ci.nsIContentPermissionType);
 
     const kFeatureKeys = { "geolocation" : "geo",
                            "desktop-notification" : "desktop-notification",
                            "pointerLock" : "pointerLock",
-                           "push" : "push"
                          };
 
     // Make sure that we support the request.
     if (!(perm.type in kFeatureKeys)) {
       return;
     }
 
     var requestingPrincipal = request.principal;
@@ -2777,19 +2742,16 @@ ContentPermissionPrompt.prototype = {
       this._promptGeo(request);
       break;
     case "desktop-notification":
       this._promptWebNotifications(request);
       break;
     case "pointerLock":
       this._promptPointerLock(request, autoAllow);
       break;
-    case "push":
-      this._promptPush(request);
-      break;
     }
   },
 
 };
 
 var DefaultBrowserCheck = {
   get OPTIONPOPUP() { return "defaultBrowserNotificationPopup" },
   _setAsDefaultTimer: null,
--- a/browser/components/preferences/aboutPermissions.js
+++ b/browser/components/preferences/aboutPermissions.js
@@ -41,17 +41,17 @@ var gVisitStmt = gPlacesDatabase.createA
                   "SELECT SUM(visit_count) AS count " +
                   "FROM moz_places " +
                   "WHERE rev_host = :rev_host");
 
 /**
  * Permission types that should be tested with testExactPermission, as opposed
  * to testPermission. This is based on what consumers use to test these permissions.
  */
-var TEST_EXACT_PERM_TYPES = ["geo", "camera", "microphone"];
+var TEST_EXACT_PERM_TYPES = ["geo", "camera", "microphone", "desktop-notification"];
 
 /**
  * Site object represents a single site, uniquely identified by a principal.
  */
 function Site(principal) {
   this.principal = principal;
   this.listitem = null;
 }
@@ -316,26 +316,19 @@ var PermissionDefaults = {
     }
     return this.ALLOW;
   },
   set popup(aValue) {
     let value = (aValue == this.DENY);
     Services.prefs.setBoolPref("dom.disable_open_during_load", value);
   },
 
-  get push() {
-    if (!Services.prefs.getBoolPref("dom.push.enabled")) {
-      return this.DENY;
-    }
+  get ["desktop-notification"]() {
     return this.UNKNOWN;
   },
-  set push(aValue) {
-    let value = (aValue != this.DENY);
-    Services.prefs.setBoolPref("dom.push.enabled", value);
-  },
   get camera() {
     return this.UNKNOWN;
   },
   get microphone() {
     return this.UNKNOWN;
   }
 };
 
@@ -379,27 +372,28 @@ var AboutPermissions = {
   /**
    * This reflects the permissions that we expose in the UI. These correspond
    * to permission type strings in the permission manager, PermissionDefaults,
    * and element ids in aboutPermissions.xul.
    *
    * Potential future additions: "sts/use", "sts/subd"
    */
   _supportedPermissions: ["password", "cookie", "geo", "indexedDB", "popup",
-                          "camera", "microphone", "push"],
+                          "camera", "microphone", "desktop-notification"],
 
   /**
    * Permissions that don't have a global "Allow" option.
    */
-  _noGlobalAllow: ["geo", "indexedDB", "camera", "microphone", "push"],
+  _noGlobalAllow: ["geo", "indexedDB", "camera", "microphone",
+                   "desktop-notification"],
 
   /**
    * Permissions that don't have a global "Deny" option.
    */
-  _noGlobalDeny: ["camera", "microphone"],
+  _noGlobalDeny: ["camera", "microphone", "desktop-notification"],
 
   _stringBundle: Services.strings.
                  createBundle("chrome://browser/locale/preferences/aboutPermissions.properties"),
 
   /**
    * Called on page load.
    */
   init: function() {
--- a/browser/components/preferences/aboutPermissions.xul
+++ b/browser/components/preferences/aboutPermissions.xul
@@ -234,31 +234,31 @@
                   <menuitem id="indexedDB-1" value="1" label="&permission.allow;"/>
                   <menuitem id="indexedDB-2" value="2" label="&permission.block;"/>
                 </menupopup>
               </menulist>
             </hbox>
           </vbox>
         </hbox>
 
-        <!-- Push Notifications -->
-        <hbox id="push-pref-item"
+        <!-- Notifications -->
+        <hbox id="desktop-notification-pref-item"
               class="pref-item" align="top">
-          <image class="pref-icon" type="push"/>
+          <image class="pref-icon" type="desktop-notification"/>
           <vbox>
-            <label class="pref-title" value="&push.label;"/>
+            <label class="pref-title" value="&desktop-notification.label;"/>
             <hbox align="center">
-              <menulist id="push-menulist"
+              <menulist id="desktop-notification-menulist"
                         class="pref-menulist"
-                        type="push"
+                        type="desktop-notification"
                         oncommand="AboutPermissions.onPermissionCommand(event);">
                 <menupopup>
-                  <menuitem id="push-0" value="0" label="&permission.alwaysAsk;"/>
-                  <menuitem id="push-1" value="1" label="&permission.allow;"/>
-                  <menuitem id="push-2" value="2" label="&permission.block;"/>
+                  <menuitem id="desktop-notification-0" value="0" label="&permission.alwaysAsk;"/>
+                  <menuitem id="desktop-notification-1" value="1" label="&permission.allow;"/>
+                  <menuitem id="desktop-notification-2" value="2" label="&permission.block;"/>
                 </menupopup>
               </menulist>
             </hbox>
           </vbox>
         </hbox>
       </vbox>
     </vbox>
   </hbox>
--- a/browser/components/preferences/in-content/tests/browser_permissions.js
+++ b/browser/components/preferences/in-content/tests/browser_permissions.js
@@ -23,17 +23,17 @@ const PERM_DENY = 2;
 // cookie specific permissions
 const PERM_FIRST_PARTY_ONLY = 9;
 
 // used to set permissions on test sites
 const TEST_PERMS = {
   "password": PERM_ALLOW,
   "cookie": PERM_ALLOW,
   "geo": PERM_UNKNOWN,
-  "push": PERM_DENY,
+  "desktop-notification": PERM_UNKNOWN,
   "indexedDB": PERM_UNKNOWN,
   "popup": PERM_DENY,
   "camera": PERM_UNKNOWN,
   "microphone": PERM_UNKNOWN
 };
 
 const NO_GLOBAL_ALLOW = [
   "geo",
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -370,33 +370,22 @@ geolocation.shareLocation=Share Location
 geolocation.shareLocation.accesskey=a
 geolocation.alwaysShareLocation=Always Share Location
 geolocation.alwaysShareLocation.accesskey=A
 geolocation.neverShareLocation=Never Share Location
 geolocation.neverShareLocation.accesskey=N
 geolocation.shareWithSite2=Would you like to share your location with this site?
 geolocation.shareWithFile2=Would you like to share your location with this file?
 
-webNotifications.showForSession=Show for this session
-webNotifications.showForSession.accesskey=s
 webNotifications.alwaysShow=Always Show Notifications
 webNotifications.alwaysShow.accesskey=A
 webNotifications.neverShow=Always Block Notifications
 webNotifications.neverShow.accesskey=N
 webNotifications.showFromSite2=Would you like to show notifications from this site?
 
-# Push Notifications
-push.allowForSession=Allow for Session
-push.allowForSession.accesskey=S
-push.alwaysAllow=Always Allow Push Notifications
-push.alwaysAllow.accesskey=A
-push.alwaysBlock=Always Block Push Notifications
-push.alwaysBlock.accesskey=B
-push.enablePush2=Would you like to allow Push Notifications for this site?
-
 # Pointer lock UI
 
 pointerLock.allow2=Hide pointer
 pointerLock.allow2.accesskey=H
 pointerLock.alwaysAllow=Always allow hiding
 pointerLock.alwaysAllow.accesskey=A
 pointerLock.neverAllow=Never allow hiding
 pointerLock.neverAllow.accesskey=N
--- a/browser/locales/en-US/chrome/browser/preferences/aboutPermissions.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/aboutPermissions.dtd
@@ -36,13 +36,13 @@
 <!ENTITY plugins.label                   "Plugins">
 
 <!-- LOCALIZATION NOTE (indexedDB.label): This is describing indexedDB storage
      using the same language used for the permIndexedDB string in browser/pageInfo.dtd -->
 <!ENTITY indexedDB.label                 "Maintain Offline Storage">
 
 <!ENTITY popup.label                     "Open Pop-up Windows">
 
-<!ENTITY push.label                      "Receive Push Notifications">
+<!ENTITY desktop-notification.label      "Show Notifications">
 <!ENTITY camera.label                    "Use the Camera">
 <!ENTITY microphone.label                "Use the Microphone">
 
 <!ENTITY focusSearch.key                 "f">
--- a/browser/locales/en-US/chrome/browser/sitePermissions.properties
+++ b/browser/locales/en-US/chrome/browser/sitePermissions.properties
@@ -12,9 +12,8 @@ permission.desktop-notification.label = 
 permission.image.label = Load Images
 permission.camera.label = Use the Camera
 permission.microphone.label = Use the Microphone
 permission.install.label = Install Add-ons
 permission.popup.label = Open Pop-up Windows
 permission.geo.label = Access Your Location
 permission.indexedDB.label = Maintain Offline Storage
 permission.pointerLock.label = Hide the Mouse Pointer
-permission.push.label = Receive Push Notifications
--- a/browser/modules/SitePermissions.jsm
+++ b/browser/modules/SitePermissions.jsm
@@ -156,17 +156,19 @@ var gPermissionObject = {
 
       if (Services.prefs.getIntPref("network.cookie.lifetimePolicy") == 2)
         return SitePermissions.SESSION;
 
       return SitePermissions.ALLOW;
     }
   },
 
-  "desktop-notification": {},
+  "desktop-notification": {
+    exactHostMatch: true
+  },
 
   "camera": {},
   "microphone": {},
 
   "popup": {
     getDefault: function () {
       return Services.prefs.getBoolPref("dom.disable_open_during_load") ?
                SitePermissions.BLOCK : SitePermissions.ALLOW;
@@ -183,14 +185,10 @@ var gPermissionObject = {
   "geo": {
     exactHostMatch: true
   },
 
   "indexedDB": {},
 
   "pointerLock": {
     exactHostMatch: true
-  },
-
-  "push": {
-    exactHostMatch: true
   }
 };
--- a/browser/modules/test/xpcshell/test_SitePermissions.js
+++ b/browser/modules/test/xpcshell/test_SitePermissions.js
@@ -3,12 +3,11 @@
  */
 "use strict";
 
 Components.utils.import("resource:///modules/SitePermissions.jsm");
 
 add_task(function* testPermissionsListing() {
   Assert.deepEqual(SitePermissions.listPermissions().sort(),
     ["camera","cookie","desktop-notification","geo","image",
-     "indexedDB","install","microphone","pointerLock","popup",
-     "push"],
+     "indexedDB","install","microphone","pointerLock","popup"],
     "Correct list of all permissions");
 });
deleted file mode 100644
index 082b177811eb58303ee74b744e924adaf7223ade..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 6e09ab9c32d021d9f1f4c937943b31be08cb87c8..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/browser/themes/linux/jar.mn
+++ b/browser/themes/linux/jar.mn
@@ -18,18 +18,16 @@ browser.jar:
   skin/classic/browser/actionicon-tab.png
 * skin/classic/browser/browser.css
 * skin/classic/browser/devedition.css
 * skin/classic/browser/browser-lightweightTheme.css
   skin/classic/browser/click-to-play-warning-stripes.png
   skin/classic/browser/content-contextmenu.svg
   skin/classic/browser/Geolocation-16.png
   skin/classic/browser/Geolocation-64.png
-  skin/classic/browser/Push-16.png
-  skin/classic/browser/Push-64.png
   skin/classic/browser/Info.png
   skin/classic/browser/menuPanel.png
   skin/classic/browser/menuPanel@2x.png
   skin/classic/browser/menuPanel-customize.png
   skin/classic/browser/menuPanel-customize@2x.png
   skin/classic/browser/menuPanel-exit.png
   skin/classic/browser/menuPanel-exit@2x.png
   skin/classic/browser/menuPanel-help.png
--- a/browser/themes/linux/preferences/aboutPermissions.css
+++ b/browser/themes/linux/preferences/aboutPermissions.css
@@ -89,18 +89,18 @@
   list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
 }
 .pref-icon[type="cookie"] {
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 .pref-icon[type="geo"] {
   list-style-image: url(chrome://browser/skin/Geolocation-64.png);
 }
-.pref-icon[type="push"] {
-  list-style-image: url(chrome://browser/skin/Push-64.png);
+.pref-icon[type="desktop-notification"] {
+  list-style-image: url(chrome://browser/skin/notification-64.png);
 }
 .pref-icon[type="indexedDB"] {
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 .pref-icon[type="install"] {
   list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.png);
 }
 .pref-icon[type="popup"] {
deleted file mode 100644
index 54ef8f8eae7221735fe774a2d6cfc4c68c1e342e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 314089368457780f64af9b7107edfda1d8f37ebc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 099b9c76f355237c3ae163f5c17845bb2cf36c6c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 411db1a5a455401d5df6a5fd3bca39bd3b3bca77..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/browser/themes/osx/jar.mn
+++ b/browser/themes/osx/jar.mn
@@ -20,20 +20,16 @@ browser.jar:
 * skin/classic/browser/devedition.css
 * skin/classic/browser/browser-lightweightTheme.css
   skin/classic/browser/click-to-play-warning-stripes.png
   skin/classic/browser/content-contextmenu.svg
   skin/classic/browser/Geolocation-16.png
   skin/classic/browser/Geolocation-16@2x.png
   skin/classic/browser/Geolocation-64.png
   skin/classic/browser/Geolocation-64@2x.png
-  skin/classic/browser/Push-16.png
-  skin/classic/browser/Push-16@2x.png
-  skin/classic/browser/Push-64.png
-  skin/classic/browser/Push-64@2x.png
   skin/classic/browser/Info.png
   skin/classic/browser/keyhole-circle.png
   skin/classic/browser/keyhole-circle@2x.png
   skin/classic/browser/KUI-background.png
   skin/classic/browser/subtle-pattern.png
   skin/classic/browser/menu-back.png
   skin/classic/browser/menu-forward.png
   skin/classic/browser/notification-16.png
--- a/browser/themes/osx/preferences/aboutPermissions.css
+++ b/browser/themes/osx/preferences/aboutPermissions.css
@@ -99,18 +99,18 @@
   list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
 }
 .pref-icon[type="cookie"] {
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 .pref-icon[type="geo"] {
   list-style-image: url(chrome://browser/skin/Geolocation-64.png);
 }
-.pref-icon[type="push"] {
-  list-style-image: url(chrome://browser/skin/Push-64.png);
+.pref-icon[type="desktop-notification"] {
+  list-style-image: url(chrome://browser/skin/notification-64.png);
 }
 .pref-icon[type="indexedDB"] {
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 .pref-icon[type="install"] {
   list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.png);
 }
 .pref-icon[type="popup"] {
@@ -128,16 +128,19 @@
 .pref-icon[type="microphone"] {
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 
 @media (min-resolution: 2dppx) {
   .pref-icon[type="geo"] {
     list-style-image: url(chrome://browser/skin/Geolocation-64@2x.png);
   }
+  .pref-icon[type="desktop-notification"] {
+    list-style-image: url(chrome://browser/skin/notification-64@2x.png);
+  }
 }
 
 .pref-title {
   font-size: 125%;
   -moz-margin-start: 2px; /* align with the menulists */
   margin-bottom: 0;
   font-weight: bold;
 }
--- a/browser/themes/shared/notification-icons.inc.css
+++ b/browser/themes/shared/notification-icons.inc.css
@@ -9,20 +9,16 @@
   height: 64px;
   -moz-margin-end: 10px;
 }
 
 .popup-notification-icon[popupid="geolocation"] {
   list-style-image: url(chrome://browser/skin/Geolocation-64.png);
 }
 
-.popup-notification-icon[popupid="push"] {
-  list-style-image: url(chrome://browser/skin/Push-64.png);
-}
-
 .popup-notification-icon[popupid="xpinstall-disabled"],
 .popup-notification-icon[popupid="addon-install-blocked"],
 .popup-notification-icon[popupid="addon-install-origin-blocked"] {
   list-style-image: url(chrome://browser/skin/addons/addon-install-blocked.svg);
 }
 
 .popup-notification-icon[popupid="addon-progress"] {
   list-style-image: url(chrome://browser/skin/addons/addon-install-downloading.svg);
@@ -137,20 +133,16 @@
   /* XXX: need HiDPI version */
 }
 
 .geo-notification-icon,
 #geo-notification-icon {
   list-style-image: url(chrome://browser/skin/Geolocation-16.png);
 }
 
-#push-notification-icon {
-  list-style-image: url(chrome://browser/skin/Push-16.png);
-}
-
 #addons-notification-icon {
   list-style-image: url(chrome://browser/skin/addons/addon-install-anchor.svg#default);
 }
 
 #addons-notification-icon:hover {
   list-style-image: url(chrome://browser/skin/addons/addon-install-anchor.svg#hover);
 }
 
@@ -364,20 +356,16 @@
 
 %ifdef XP_MACOSX
 /* OSX only until we have icons for Windows and Linux */
   .geo-notification-icon,
   #geo-notification-icon {
     list-style-image: url(chrome://browser/skin/Geolocation-16@2x.png);
   }
 
-  #push-notification-icon {
-    list-style-image: url(chrome://browser/skin/Push-16@2x.png);
-  }
-
   .indexedDB-notification-icon,
   #indexedDB-notification-icon {
     list-style-image: url(chrome://global/skin/icons/question-32.png);
   }
 
   #login-fill-notification-icon,
   #password-notification-icon {
     list-style-image: url(chrome://mozapps/skin/passwordmgr/key-16@2x.png);
@@ -433,20 +421,16 @@
     list-style-image: url(chrome://browser/skin/translation-16@2x.png);
     -moz-image-region: rect(0px, 64px, 32px, 32px);
   }
 
   .popup-notification-icon[popupid="geolocation"] {
     list-style-image: url(chrome://browser/skin/Geolocation-64@2x.png);
   }
 
-  .popup-notification-icon[popupid="push"] {
-    list-style-image: url(chrome://browser/skin/Push-64@2x.png);
-  }
-
   .popup-notification-icon[popupid="web-notifications"] {
     list-style-image: url(chrome://browser/skin/notification-64@2x.png);
   }
 
   .popup-notification-icon[popupid="pointerLock"] {
     list-style-image: url(chrome://browser/skin/pointerLock-64@2x.png);
   }
 
deleted file mode 100644
index d710e7336dbc445d36ee4868257d9139c50f8919..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 27fecb8588f939fbb33347518c1627fc8e9b8af8..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
--- a/browser/themes/windows/jar.mn
+++ b/browser/themes/windows/jar.mn
@@ -20,18 +20,16 @@ browser.jar:
 * skin/classic/browser/browser.css
 * skin/classic/browser/devedition.css
 * skin/classic/browser/browser-lightweightTheme.css
   skin/classic/browser/caption-buttons.svg
   skin/classic/browser/click-to-play-warning-stripes.png
   skin/classic/browser/content-contextmenu.svg
   skin/classic/browser/Geolocation-16.png
   skin/classic/browser/Geolocation-64.png
-  skin/classic/browser/Push-16.png
-  skin/classic/browser/Push-64.png
   skin/classic/browser/Info.png
   skin/classic/browser/Info-XP.png
   skin/classic/browser/keyhole-forward-mask.svg
   skin/classic/browser/KUI-background.png
   skin/classic/browser/livemark-folder.png
   skin/classic/browser/livemark-folder-XP.png
   skin/classic/browser/menu-back.png
   skin/classic/browser/menu-back-XP.png
--- a/browser/themes/windows/preferences/aboutPermissions.css
+++ b/browser/themes/windows/preferences/aboutPermissions.css
@@ -93,18 +93,18 @@
   list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
 }
 .pref-icon[type="cookie"] {
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 .pref-icon[type="geo"] {
   list-style-image: url(chrome://browser/skin/Geolocation-64.png);
 }
-.pref-icon[type="push"] {
-  list-style-image: url(chrome://browser/skin/Push-64.png);
+.pref-icon[type="desktop-notification"] {
+  list-style-image: url(chrome://browser/skin/notification-64.png);
 }
 .pref-icon[type="indexedDB"] {
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 .pref-icon[type="install"] {
   list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.png);
 }
 .pref-icon[type="popup"] {
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -1634,19 +1634,19 @@ Notification::GetPermissionInternal(nsIP
     }
   }
 
   uint32_t permission = nsIPermissionManager::UNKNOWN_ACTION;
 
   nsCOMPtr<nsIPermissionManager> permissionManager =
     services::GetPermissionManager();
 
-  permissionManager->TestPermissionFromPrincipal(aPrincipal,
-                                                 "desktop-notification",
-                                                 &permission);
+  permissionManager->TestExactPermissionFromPrincipal(aPrincipal,
+                                                      "desktop-notification",
+                                                      &permission);
 
   // Convert the result to one of the enum types.
   switch (permission) {
   case nsIPermissionManager::ALLOW_ACTION:
     return NotificationPermission::Granted;
   case nsIPermissionManager::DENY_ACTION:
     return NotificationPermission::Denied;
   default:
--- a/dom/permission/PermissionUtils.cpp
+++ b/dom/permission/PermissionUtils.cpp
@@ -7,17 +7,18 @@
 #include "PermissionUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 const char* kPermissionTypes[] = {
   "geo",
   "desktop-notification",
-  "push",
+  // Alias `push` to `desktop-notification`.
+  "desktop-notification",
   "midi"
 };
 
 // `-1` for the last null entry.
 const size_t kPermissionNameCount =
   MOZ_ARRAY_LENGTH(PermissionNameValues::strings) - 1;
 
 static_assert(MOZ_ARRAY_LENGTH(kPermissionTypes) == kPermissionNameCount,
--- a/dom/permission/tests/test_permissions_api.html
+++ b/dom/permission/tests/test_permissions_api.html
@@ -18,17 +18,17 @@
 let { UNKNOWN_ACTION, PROMPT_ACTION, ALLOW_ACTION, DENY_ACTION } =
   SpecialPowers.Ci.nsIPermissionManager;
 
 SimpleTest.waitForExplicitFinish();
 
 const PERMISSIONS = [
   { name: 'geolocation', perm: 'geo' },
   { name: 'notifications', perm: 'desktop-notification' },
-  { name: 'push', perm: 'push' },
+  { name: 'push', perm: 'desktop-notification' },
 ];
 
 const UNSUPPORTED_PERMISSIONS = [
   'midi',
 ];
 
 function setup() {
   return new Promise((resolve, reject) => {
--- a/dom/push/Push.js
+++ b/dom/push/Push.js
@@ -62,45 +62,45 @@ Push.prototype = {
   setScope: function(scope){
     debug('setScope ' + scope);
     this._scope = scope;
   },
 
   askPermission: function (aAllowCallback, aCancelCallback) {
     debug("askPermission");
 
-    let principal = this._window.document.nodePrincipal;
-    let type = "push";
-    let permValue =
-      Services.perms.testExactPermissionFromPrincipal(principal, type);
+    let permValue = Services.perms.testExactPermissionFromPrincipal(
+      this._principal,
+      "desktop-notification"
+    );
 
     if (permValue == Ci.nsIPermissionManager.ALLOW_ACTION) {
-        aAllowCallback();
+      aAllowCallback();
       return;
     }
 
     if (permValue == Ci.nsIPermissionManager.DENY_ACTION) {
       aCancelCallback();
       return;
     }
 
     // Create an array with a single nsIContentPermissionType element.
-    type = {
-      type: "push",
+    let type = {
+      type: "desktop-notification",
       access: null,
       options: [],
       QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionType])
     };
     let typeArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
     typeArray.appendElement(type, false);
 
     // create a nsIContentPermissionRequest
     let request = {
       types: typeArray,
-      principal: principal,
+      principal: this._principal,
       QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionRequest]),
       allow: function() {
         let histogram = Services.telemetry.getHistogramById("PUSH_API_PERMISSION_GRANTED");
         histogram.add();
         aAllowCallback();
       },
       cancel: function() {
         let histogram = Services.telemetry.getHistogramById("PUSH_API_PERMISSION_DENIED");
@@ -177,21 +177,18 @@ Push.prototype = {
 
   permissionState: function() {
     debug("permissionState()" + this._scope);
 
     let p = this.createPromise((resolve, reject) => {
       let permission = Ci.nsIPermissionManager.DENY_ACTION;
 
       try {
-        let permissionManager = Cc["@mozilla.org/permissionmanager;1"]
-                                .getService(Ci.nsIPermissionManager);
-        permission =
-          permissionManager.testExactPermissionFromPrincipal(this._principal,
-                                                             "push");
+        permission = Services.perms.testExactPermissionFromPrincipal(
+          this._principal, "desktop-notification");
       } catch(e) {
         reject();
         return;
       }
 
       let pushPermissionStatus = "prompt";
       if (permission == Ci.nsIPermissionManager.ALLOW_ACTION) {
         pushPermissionStatus = "granted";
--- a/dom/push/PushManager.cpp
+++ b/dom/push/PushManager.cpp
@@ -587,17 +587,17 @@ public:
       return NS_OK;
     }
 
     nsCOMPtr<nsIPrincipal> principal = mProxy->GetWorkerPrivate()->GetPrincipal();
 
     uint32_t permission = nsIPermissionManager::DENY_ACTION;
     nsresult rv = permManager->TestExactPermissionFromPrincipal(
                     principal,
-                    "push",
+                    "desktop-notification",
                     &permission);
 
     if (NS_WARN_IF(NS_FAILED(rv)) || permission != nsIPermissionManager::ALLOW_ACTION) {
       callback->OnPushEndpoint(NS_ERROR_FAILURE, EmptyString(), 0, nullptr);
       return NS_OK;
     }
 
     nsCOMPtr<nsIPushClient> client =
@@ -727,38 +727,30 @@ public:
     if (mProxy->CleanedUp()) {
       return NS_OK;
     }
 
     nsCOMPtr<nsIPermissionManager> permManager =
       mozilla::services::GetPermissionManager();
 
     nsresult rv = NS_ERROR_FAILURE;
-    PushPermissionState state = PushPermissionState::Denied;
+    PushPermissionState state = PushPermissionState::Prompt;
 
     if (permManager) {
-      uint32_t permission = nsIPermissionManager::DENY_ACTION;
+      uint32_t permission = nsIPermissionManager::UNKNOWN_ACTION;
       rv = permManager->TestExactPermissionFromPrincipal(
              mProxy->GetWorkerPrivate()->GetPrincipal(),
-             "push",
+             "desktop-notification",
              &permission);
 
       if (NS_SUCCEEDED(rv)) {
-        switch (permission) {
-          case nsIPermissionManager::ALLOW_ACTION:
-            state = PushPermissionState::Granted;
-            break;
-          case nsIPermissionManager::DENY_ACTION:
-            state = PushPermissionState::Denied;
-            break;
-          case nsIPermissionManager::PROMPT_ACTION:
-            state = PushPermissionState::Prompt;
-            break;
-          default:
-            MOZ_CRASH("Unexpected case!");
+        if (permission == nsIPermissionManager::ALLOW_ACTION) {
+          state = PushPermissionState::Granted;
+        } else if (permission == nsIPermissionManager::DENY_ACTION) {
+          state = PushPermissionState::Denied;
         }
       }
     }
 
     AutoJSAPI jsapi;
     jsapi.Init();
     nsRefPtr<PermissionResultRunnable> r =
       new PermissionResultRunnable(mProxy, rv, state);
--- a/dom/push/PushRecord.jsm
+++ b/dom/push/PushRecord.jsm
@@ -156,30 +156,22 @@ PushRecord.prototype = {
           return true;
         }
       }
     }
     return false;
   },
 
   /**
-   * Returns the push permission state for the principal associated with
-   * this registration.
-   */
-  pushPermission() {
-    return Services.perms.testExactPermissionFromPrincipal(
-           this.principal, "push");
-  },
-
-  /**
    * Indicates whether the registration can deliver push messages to its
    * associated service worker.
    */
   hasPermission() {
-    let permission = this.pushPermission();
+    let permission = Services.perms.testExactPermissionFromPrincipal(
+      this.principal, "desktop-notification");
     return permission == Ci.nsIPermissionManager.ALLOW_ACTION;
   },
 
   quotaApplies() {
     return Number.isFinite(this.quota);
   },
 
   isExpired() {
--- a/dom/push/test/test_data.html
+++ b/dom/push/test/test_data.html
@@ -174,13 +174,13 @@ http://creativecommons.org/licenses/publ
   }
 
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true]
     ]}, runTest);
-  SpecialPowers.addPermission('push', true, document);
+  SpecialPowers.addPermission("desktop-notification", true, document);
   SimpleTest.waitForExplicitFinish();
 </script>
 </body>
 </html>
--- a/dom/push/test/test_has_permissions.html
+++ b/dom/push/test/test_has_permissions.html
@@ -60,17 +60,17 @@ http://creativecommons.org/licenses/publ
     start()
     .then(hasPermission)
     .then(unregister)
     .catch(function(e) {
       ok(false, "Some test failed with error " + e);
     }).then(SimpleTest.finish);
   }
 
-  SpecialPowers.addPermission('push', false, document);
+  SpecialPowers.addPermission("desktop-notification", false, document);
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true]
     ]}, runTest);
   SimpleTest.waitForExplicitFinish();
 
--- a/dom/push/test/test_multiple_register.html
+++ b/dom/push/test/test_multiple_register.html
@@ -120,13 +120,13 @@ http://creativecommons.org/licenses/publ
 
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.push.debug", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true]
     ]}, runTest);
-  SpecialPowers.addPermission('push', true, document);
+  SpecialPowers.addPermission("desktop-notification", true, document);
   SimpleTest.waitForExplicitFinish();
 </script>
 </body>
 </html>
--- a/dom/push/test/test_multiple_register_different_scope.html
+++ b/dom/push/test/test_multiple_register_different_scope.html
@@ -114,13 +114,13 @@ http://creativecommons.org/licenses/publ
   }
 
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true]
     ]}, runTest);
-  SpecialPowers.addPermission('push', true, document);
+  SpecialPowers.addPermission("desktop-notification", true, document);
   SimpleTest.waitForExplicitFinish();
 </script>
 </body>
 </html>
--- a/dom/push/test/test_multiple_register_during_service_activation.html
+++ b/dom/push/test/test_multiple_register_during_service_activation.html
@@ -102,13 +102,13 @@ var defaultServerURL = SpecialPowers.get
 
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true],
     ["dom.push.serverURL", "wss://something.org"]
     ]}, runTest);
-  SpecialPowers.addPermission('push', true, document);
+  SpecialPowers.addPermission("desktop-notification", true, document);
   SimpleTest.waitForExplicitFinish();
 </script>
 </body>
 </html>
--- a/dom/push/test/test_permissions.html
+++ b/dom/push/test/test_permissions.html
@@ -66,37 +66,57 @@ http://creativecommons.org/licenses/publ
           res(swr);
         }
         );
     });
     return p;
   }
 
   function checkPermissionState(swr) {
-    return swr.pushManager.permissionState().then(function(state) {
-      ok(state === "denied", "permissionState() should resolve to denied.");
-      return swr;
-    }).catch(function(e) {
-      ok(false, "permissionState() should resolve to denied.");
-      return swr;
-    });
+    var permissionManager = SpecialPowers.Ci.nsIPermissionManager;
+    var tests = [{
+      action: permissionManager.ALLOW_ACTION,
+      state: "granted",
+    }, {
+      action: permissionManager.DENY_ACTION,
+      state: "denied",
+    }, {
+      action: permissionManager.PROMPT_ACTION,
+      state: "prompt",
+    }, {
+      action: permissionManager.UNKNOWN_ACTION,
+      state: "prompt",
+    }];
+    return tests.reduce((promise, test) => {
+      return promise.then(function() {
+        if (test.action == permissionManager.UNKNOWN_ACTION) {
+          SpecialPowers.removePermission("desktop-notification", document);
+        } else {
+          SpecialPowers.addPermission("desktop-notification",
+            test.action, document);
+        }
+        return swr.pushManager.permissionState().then(state => {
+          is(state, test.state, JSON.stringify(test));
+        });
+      });
+    }, Promise.resolve());
   }
 
   function runTest() {
     start()
     .then(setupPushNotification)
     .then(getEndpoint)
     .then(checkPermissionState)
     .then(unregister)
     .catch(function(e) {
       ok(false, "Some test failed with error " + e);
     }).then(SimpleTest.finish);
   }
 
-  SpecialPowers.addPermission('push', false, document);
+  SpecialPowers.addPermission("desktop-notification", false, document);
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true]
     ]}, runTest);
   SimpleTest.waitForExplicitFinish();
 
--- a/dom/push/test/test_register.html
+++ b/dom/push/test/test_register.html
@@ -126,13 +126,13 @@ http://creativecommons.org/licenses/publ
   }
 
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true]
     ]}, runTest);
-  SpecialPowers.addPermission('push', true, document);
+  SpecialPowers.addPermission("desktop-notification", true, document);
   SimpleTest.waitForExplicitFinish();
 </script>
 </body>
 </html>
--- a/dom/push/test/test_try_registering_offline_disabled.html
+++ b/dom/push/test/test_try_registering_offline_disabled.html
@@ -288,13 +288,13 @@ http://creativecommons.org/licenses/publ
   }
 
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true]
     ]}, runTest);
-  SpecialPowers.addPermission('push', true, document);
+  SpecialPowers.addPermission("desktop-notification", true, document);
   SimpleTest.waitForExplicitFinish();
 </script>
 </body>
 </html>
--- a/dom/push/test/test_unregister.html
+++ b/dom/push/test/test_unregister.html
@@ -80,14 +80,14 @@ http://creativecommons.org/licenses/publ
   }
 
   SpecialPowers.pushPrefEnv({"set": [
     ["dom.push.enabled", true],
     ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     ["dom.serviceWorkers.enabled", true],
     ["dom.serviceWorkers.testing.enabled", true]
     ]}, runTest);
-  SpecialPowers.addPermission('push', true, document);
+  SpecialPowers.addPermission("desktop-notification", true, document);
   SimpleTest.waitForExplicitFinish();
 </script>
 </body>
 </html>