From 0d904ab620d241bef329044a965c2494cb96cf2b Mon Sep 17 00:00:00 2001 From: James Willcox Date: Fri, 8 Jun 2018 16:36:40 -0500 Subject: [PATCH] Bug 1467919 - Don't initialize PushService unless dom.push.enabled is true r=lina MozReview-Commit-ID: JfQUHf1JCRb --- dom/push/PushComponents.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dom/push/PushComponents.js b/dom/push/PushComponents.js index 8738b832a244..252167fcd3c5 100644 --- a/dom/push/PushComponents.js +++ b/dom/push/PushComponents.js @@ -16,10 +16,14 @@ var isParent = Services.appinfo.processType === Ci.nsIXULRuntime.PROCESS_TYPE_DE // The default Push service implementation. XPCOMUtils.defineLazyGetter(this, "PushService", function() { - const {PushService} = ChromeUtils.import("resource://gre/modules/PushService.jsm", - {}); - PushService.init(); - return PushService; + if (Services.prefs.getBoolPref("dom.push.enabled")) { + const {PushService} = ChromeUtils.import("resource://gre/modules/PushService.jsm", + {}); + PushService.init(); + return PushService; + } + + throw Cr.NS_ERROR_NOT_AVAILABLE; }); // Observer notification topics for push messages and subscription status @@ -251,7 +255,7 @@ Object.assign(PushServiceParent.prototype, { return data; }, - _handleRequest(name, principal, data) { + async _handleRequest(name, principal, data) { if (name == "Push:Clear") { return this.service.clear(data); }