Bug 596799 - document.getElementById("sync-button") is null. r=gavin, a=blocking-beta7
authorPhilipp von Weitershausen <philipp@weitershausen.de>
Thu, 16 Sep 2010 04:24:10 +0200
changeset 54122 dd872c73e5c42565419f70ca8f59a01701379d8e
parent 54121 cdb90b48f19ff8e332a4bbbb22f9d2071a4d8796
child 54123 7676e2b0fea0f968a78b31191b253be3a377fb16
push id15769
push userpweitershausen@mozilla.com
push dateThu, 16 Sep 2010 02:25:40 +0000
treeherdermozilla-central@dd872c73e5c4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, blocking-beta7
bugs596799
milestone2.0b7pre
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 596799 - document.getElementById("sync-button") is null. r=gavin, a=blocking-beta7 Make sure that the Sync button is only accessed when it actually exists in the toolbar. Also fix its entry in browserShared.inc.
browser/base/content/browser-syncui.js
browser/themes/browserShared.inc
--- a/browser/base/content/browser-syncui.js
+++ b/browser/base/content/browser-syncui.js
@@ -103,23 +103,27 @@ let gSyncUI = {
     return Weave.Service.isLoggedIn;
   },
 
   updateUI: function SUI_updateUI() {
     let needsSetup = this._needsSetup();
     document.getElementById("sync-setup-state").hidden = !needsSetup;
     document.getElementById("sync-syncnow-state").hidden = needsSetup;
 
-    if (gBrowser) {
-      document.getElementById("sync-button").removeAttribute("status");
-      this._updateLastSyncTime();
-    }
-    if (needsSetup) {
-      document.getElementById("sync-button").removeAttribute("tooltiptext");
-    }
+    if (!gBrowser)
+      return;
+
+    let button = document.getElementById("sync-button");
+    if (!button)
+      return;
+
+    button.removeAttribute("status");
+    this._updateLastSyncTime();
+    if (needsSetup)
+      button.removeAttribute("tooltiptext");
   },
 
   alltabsPopupShowing: function(event) {
     // Should we show the menu item?
     if (!Weave.Service.isLoggedIn || !Weave.Engines.get("tabs").enabled)
       return;
 
     let label = this._stringBundle.GetStringFromName("tabs.fromOtherComputers.label");
@@ -142,19 +146,24 @@ let gSyncUI = {
 
     popup.insertBefore(sep, popup.firstChild);
     popup.insertBefore(menuitem, sep);
   },
 
 
   // Functions called by observers
   onActivityStart: function SUI_onActivityStart() {
-    //XXXzpao Followup: Do this with a class. (bug 583384)
-    if (gBrowser)
-      document.getElementById("sync-button").setAttribute("status", "active");
+    if (!gBrowser)
+      return;
+
+    let button = document.getElementById("sync-button");
+    if (!button)
+      return;
+
+    button.setAttribute("status", "active");
   },
 
   onSyncFinish: function SUI_onSyncFinish() {
     this._onSyncEnd(true);
   },
 
   onSyncError: function SUI_onSyncError() {
     this._onSyncEnd(false);
@@ -307,16 +316,19 @@ let gSyncUI = {
 
 
   // Helpers
   _updateLastSyncTime: function SUI__updateLastSyncTime() {
     if (!gBrowser)
       return;
 
     let syncButton = document.getElementById("sync-button");
+    if (!syncButton)
+      return;
+
     let lastSync;
     try {
       lastSync = Services.prefs.getCharPref("services.sync.lastSync");
     }
     catch (e) { };
     if (!lastSync || this._needsSetup()) {
       syncButton.removeAttribute("tooltiptext");
       return;
--- a/browser/themes/browserShared.inc
+++ b/browser/themes/browserShared.inc
@@ -1,3 +1,3 @@
 %filter substitution
 
-%define primaryToolbarButtons #back-button, #forward-button, #reload-button, #stop-button, #home-button, #print-button, #downloads-button, #history-button, #bookmarks-button, #bookmarks-menu-button, #new-tab-button, #new-window-button, #cut-button, #copy-button, #paste-button, #fullscreen-button, #zoom-out-button, #zoom-in-button, #sync-buttons
+%define primaryToolbarButtons #back-button, #forward-button, #reload-button, #stop-button, #home-button, #print-button, #downloads-button, #history-button, #bookmarks-button, #bookmarks-menu-button, #new-tab-button, #new-window-button, #cut-button, #copy-button, #paste-button, #fullscreen-button, #zoom-out-button, #zoom-in-button, #sync-button