Bug 1209601 - follow-up, check that AlertsService.manualDoNotDisturb is implemented in the AlertsService lazy getter. r=MattN CLOSED TREE
authorJared Wein <jwein@mozilla.com>
Tue, 20 Oct 2015 18:07:20 -0400
changeset 303787 545fdb4211b7ffbdcf196ae5ee3c30bf6c166aae
parent 303786 aa65b3b28dcf84960826a9e150c21ba39bc1e5e0
child 303788 78dec2028dd2565cd386c6b1f57921060f300a67
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1209601
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 1209601 - follow-up, check that AlertsService.manualDoNotDisturb is implemented in the AlertsService lazy getter. r=MattN CLOSED TREE
browser/components/preferences/in-content/content.js
--- a/browser/components/preferences/in-content/content.js
+++ b/browser/components/preferences/in-content/content.js
@@ -1,19 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-XPCOMUtils.defineLazyGetter(this, "AlertsService", function () {
+XPCOMUtils.defineLazyGetter(this, "AlertsServiceDND", function () {
   try {
-    return Cc["@mozilla.org/alerts-service;1"]
-             .getService(Ci.nsIAlertsService)
-             .QueryInterface(Ci.nsIAlertsDoNotDisturb);
+    let alertsService = Cc["@mozilla.org/alerts-service;1"]
+                          .getService(Ci.nsIAlertsService)
+                          .QueryInterface(Ci.nsIAlertsDoNotDisturb);
+    // This will throw if manualDoNotDisturb isn't implemented.
+    alertsService.manualDoNotDisturb;
+    return alertsService;
   } catch (ex) {
-    return;
+    return undefined;
   }
 });
 
 var gContentPane = {
   init: function ()
   {
     function setEventListener(aId, aEventType, aCallback)
     {
@@ -36,21 +39,21 @@ var gContentPane = {
       // Showing attribution only for Bing Translator.
       Components.utils.import("resource:///modules/translation/Translation.jsm");
       if (Translation.translationEngine == "bing") {
         document.getElementById("bingAttribution").removeAttribute("hidden");
       }
     }
 
     let doNotDisturbAlertsEnabled = false;
-    if (AlertsService) {
+    if (AlertsServiceDND) {
       let notificationsDoNotDisturbRow =
         document.getElementById("notificationsDoNotDisturbRow");
       notificationsDoNotDisturbRow.removeAttribute("hidden");
-      if (AlertsService.manualDoNotDisturb) {
+      if (AlertsServiceDND.manualDoNotDisturb) {
         let notificationsDoNotDisturb =
           document.getElementById("notificationsDoNotDisturb");
         notificationsDoNotDisturb.setAttribute("checked", true);
       }
     }
 
     setEventListener("font.language.group", "change",
       gContentPane._rebuildFonts);
@@ -276,11 +279,11 @@ var gContentPane = {
   openTranslationProviderAttribution: function ()
   {
     Components.utils.import("resource:///modules/translation/Translation.jsm");
     Translation.openProviderAttribution();
   },
 
   toggleDoNotDisturbNotifications: function (event)
   {
-    AlertsService.manualDoNotDisturb = event.target.checked;
+    AlertsServiceDND.manualDoNotDisturb = event.target.checked;
   },
 };