Bug 832811 - Show desktop notifications command doesn't toggle. r=jaws, a=gavin
authorMark Hammond <mhammond@skippinet.com.au>
Mon, 21 Jan 2013 15:38:35 +1100
changeset 127368 e99c2df4862d7a01b29526648ea1b0947ca87fa1
parent 127367 10e995513c118b3b11d3a643061e998dffaea5e0
child 127369 6051dccd3d5e4b5089640c632ee92487c58db198
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, gavin
bugs832811
milestone20.0a2
Bug 832811 - Show desktop notifications command doesn't toggle. r=jaws, a=gavin
browser/base/content/browser-social.js
browser/base/content/test/social/browser_social_toolbar.js
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -123,16 +123,18 @@ let SocialUI = {
           if (Social.provider && Social.provider.origin == data) {
             SocialSidebar.setSidebarErrorMessage("frameworker-error");
           }
           break;
 
         case "nsPref:changed":
           if (data == "social.sidebar.open") {
             SocialSidebar.update();
+          } else if (data == "social.toast-notifications.enabled") {
+            SocialToolbar.updateButton();
           }
           break;
       }
     } catch (e) {
       Components.utils.reportError(e + "\n" + e.stack);
       throw e;
     }
   },
--- a/browser/base/content/test/social/browser_social_toolbar.js
+++ b/browser/base/content/test/social/browser_social_toolbar.js
@@ -151,11 +151,20 @@ var tests = {
     is(toggleSidebarMenuitems.length, 2, "Toggle Sidebar menuitems exist");
     let toggleDesktopNotificationsMenuitems = document.getElementsByClassName("social-toggle-notifications-menuitem");
     is(toggleDesktopNotificationsMenuitems.length, 2, "Toggle notifications menuitems exist");
     let toggleSocialMenuitems = document.getElementsByClassName("social-toggle-menuitem");
     is(toggleSocialMenuitems.length, 2, "Toggle Social menuitems exist");
     let removeSocialMenuitems = document.getElementsByClassName("social-remove-menuitem");
     is(removeSocialMenuitems.length, 2, "Remove Social menuitems exist");
     next();
-  }
+  },
+  testToggleNotifications: function(next) {
+    let enabled = Services.prefs.getBoolPref("social.toast-notifications.enabled");
+    let cmd = document.getElementById("Social:ToggleNotifications");
+    is(cmd.getAttribute("checked"), enabled ? "true" : "false");
+    enabled = !enabled;
+    Services.prefs.setBoolPref("social.toast-notifications.enabled", enabled);
+    is(cmd.getAttribute("checked"), enabled ? "true" : "false");
+    Services.prefs.clearUserPref("social.toast-notifications.enabled");
+    next();
+  },
 }
-