[tbb-commits] [tor-browser/tor-browser-38.4.0esr-5.5-1] Bug 16863: console.error on new Tor Browser window

gk at torproject.org gk at torproject.org
Wed Dec 9 20:40:06 UTC 2015


commit c2ce09f61101f3ac2d16d644d7fb56c035bec9ba
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Wed Dec 9 11:47:08 2015 -0500

    Bug 16863: console.error on new Tor Browser window
    
    Improve error handling and avoid confusing error log messages
    when loop.enabled is false.
---
 browser/components/customizableui/CustomizableUI.jsm      |    8 ++++++++
 browser/components/customizableui/CustomizableWidgets.jsm |    8 +++-----
 browser/components/loop/MozLoopService.jsm                |    2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm
index 54c2ede..a43404e 100644
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -1186,6 +1186,11 @@ let CustomizableUIInternal = {
       throw new Error("buildWidget was passed a non-widget to build.");
     }
 
+    if (aWidget.onIsHidden && aWidget.onIsHidden()) {
+      LOG("Skipping hidden widget " + aWidget.id + " of type " + aWidget.type);
+      return undefined;
+    }
+
     LOG("Building " + aWidget.id + " of type " + aWidget.type);
 
     let node;
@@ -2180,6 +2185,7 @@ let CustomizableUIInternal = {
       widget._introducedInVersion = aData.introducedInVersion || 0;
     }
 
+    this.wrapWidgetEventHandler("onIsHidden", widget);
     this.wrapWidgetEventHandler("onBeforeCreated", widget);
     this.wrapWidgetEventHandler("onClick", widget);
     this.wrapWidgetEventHandler("onCreated", widget);
@@ -3015,6 +3021,8 @@ this.CustomizableUI = {
    *                             of the widget.
    * - viewId:        Only useful for views (and required there): the id of the
    *                  <panelview> that should be shown when clicking the widget.
+   * - onIsHidden():  Called to check whether a widget should be hidden
+   *                  (optional; returns a Boolean value).
    * - onBuild(aDoc): Only useful for custom widgets (and required there); a
    *                  function that will be invoked with the document in which
    *                  to build a widget. Should return the DOM node that has
diff --git a/browser/components/customizableui/CustomizableWidgets.jsm b/browser/components/customizableui/CustomizableWidgets.jsm
index 75f69dd..4a8bacf 100644
--- a/browser/components/customizableui/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/CustomizableWidgets.jsm
@@ -933,12 +933,10 @@ const CustomizableWidgets = [
     // Not in private browsing, see bug 1108187.
     showInPrivateBrowsing: false,
     introducedInVersion: 4,
+    onIsHidden: function() {
+      return !Services.prefs.getBoolPref("loop.enabled");
+    },
     onBuild: function(aDocument) {
-      // If we're not supposed to see the button, return zip.
-      if (!Services.prefs.getBoolPref("loop.enabled")) {
-        return null;
-      }
-
       let node = aDocument.createElementNS(kNSXUL, "toolbarbutton");
       node.setAttribute("id", this.id);
       node.classList.add("toolbarbutton-1");
diff --git a/browser/components/loop/MozLoopService.jsm b/browser/components/loop/MozLoopService.jsm
index 3f6a77c..d915070 100644
--- a/browser/components/loop/MozLoopService.jsm
+++ b/browser/components/loop/MozLoopService.jsm
@@ -1107,7 +1107,7 @@ this.MozLoopService = {
 
     // Don't do anything if loop is not enabled.
     if (!Services.prefs.getBoolPref("loop.enabled")) {
-      return Promise.reject(new Error("loop is not enabled"));
+      return Promise.resolve();
     }
 
     if (Services.prefs.getPrefType("loop.fxa.enabled") == Services.prefs.PREF_BOOL) {



More information about the tbb-commits mailing list