Bug 897410 - don't call into the zoom manager if we don't (yet) have a docshell, r=mikedeboer
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 24 Jul 2013 15:29:29 +0200
changeset 155588 cd2ff8dd3bb8ce92b7f656880908108aa2fe192b
parent 155587 82bb645b4c13eca3287729839de493d086b16dc9
child 155589 e6ff8814ce58241866020122283d30a0876d9cf0
push id25666
push userjwein@mozilla.com
push dateMon, 18 Nov 2013 15:56:58 +0000
treeherdermozilla-central@f2adb62d07eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs897410
milestone25.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 897410 - don't call into the zoom manager if we don't (yet) have a docshell, r=mikedeboer
browser/components/customizableui/src/CustomizableWidgets.jsm
--- a/browser/components/customizableui/src/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/src/CustomizableWidgets.jsm
@@ -322,18 +322,24 @@ const CustomizableWidgets = [{
           btnNode.setAttribute("tabindex", "0");
         node.appendChild(btnNode);
       });
 
       // The middle node is the 'Reset Zoom' button.
       let zoomResetButton = node.childNodes[1];
       let window = aDocument.defaultView;
       function updateZoomResetButton() {
+        //XXXgijs in some tests we get called very early, and there's no docShell on the
+        // tabbrowser. This breaks the zoom toolkit code (see bug 897410). Don't let that happen:
+        let zoomFactor = 100;
+        if (window.gBrowser.docShell) {
+          zoomFactor = Math.floor(window.ZoomManager.zoom * 100);
+        }
         zoomResetButton.setAttribute("label", CustomizableUI.getLocalizedProperty(
-          buttons[1], "label", [Math.floor(window.ZoomManager.zoom * 100)]
+          buttons[1], "label", [zoomFactor]
         ));
       };
 
       // Register ourselves with the service so we know when the zoom prefs change.
       Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:zoomChange", false);
       Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:zoomReset", false);
       Services.obs.addObserver(updateZoomResetButton, "browser-fullZoom:locationChange", false);