From bed367b9a1b5b0ef62aa4bd4553258b2aea7f9b2 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Sun, 4 Aug 2013 01:47:30 -0400 Subject: [PATCH] Bug 707564 followup #2. Make the push code actually follow the contract for JS-implemented webidl in an attempt to reopen the CLOSED TREE. r=khuey --- dom/push/src/Push.js | 19 ++++++++++--------- dom/webidl/PushManager.webidl | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dom/push/src/Push.js b/dom/push/src/Push.js index 9ef41aef4576..4486820d58ac 100644 --- a/dom/push/src/Push.js +++ b/dom/push/src/Push.js @@ -41,9 +41,6 @@ Push.prototype = { init: function(aWindow) { debug("init()"); - if (!Services.prefs.getBoolPref("services.push.enabled")) - return null; - let principal = aWindow.document.nodePrincipal; this._pageURL = principal.URI; @@ -52,13 +49,19 @@ Push.prototype = { .getService(Ci.nsIAppsService); this._app = appsService.getAppByLocalId(principal.appId); this._manifestURL = appsService.getManifestURLByLocalId(principal.appId); - if (!this._manifestURL) - return null; + if (!this._manifestURL) { + // Now what? XXXbz should this be tested in a Func for this + // interface so it wouldn't appear at all? + return; + } let perm = Services.perms.testExactPermissionFromPrincipal(principal, "push"); - if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) - return null; + if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) { + // Now what? XXXbz should this be tested in a Func for this + // interface so it wouldn't appear at all? + return; + } this.initDOMRequestHelper(aWindow, [ "PushService:Register:OK", @@ -71,8 +74,6 @@ Push.prototype = { this._cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"] .getService(Ci.nsISyncMessageSender); - - var self = this; }, receiveMessage: function(aMessage) { diff --git a/dom/webidl/PushManager.webidl b/dom/webidl/PushManager.webidl index 6877b4e02fd0..facf3a31c873 100644 --- a/dom/webidl/PushManager.webidl +++ b/dom/webidl/PushManager.webidl @@ -4,7 +4,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ -[NoInterfaceObject, NavigatorProperty="push", JSImplementation="@mozilla.org/push/PushManager;1"] +[NoInterfaceObject, NavigatorProperty="push", JSImplementation="@mozilla.org/push/PushManager;1", Pref="services.push.enabled"] interface PushManager { DOMRequest register(); DOMRequest unregister(DOMString pushEndpoint);