Bug 481391 - Image document test in FullZoom._applyPrefToSetting fails for background tabs. r=gavin
authorDão Gottwald <dao@mozilla.com>
Sun, 08 Mar 2009 07:42:54 +0100
changeset 25831 c9e0320499d99f233e87467b2d09ec79ac842319
parent 25830 633a58ff7cb32fc0ae9b916e542f4193c1b7b9be
child 25832 7db7d5ab702a23382662e10e488f2349332d5045
push idunknown
push userunknown
push dateunknown
reviewersgavin
bugs481391
milestone1.9.2a1pre
Bug 481391 - Image document test in FullZoom._applyPrefToSetting fails for background tabs. r=gavin
browser/base/content/browser-textZoom.js
browser/base/content/test/browser_bug386835.js
--- a/browser/base/content/browser-textZoom.js
+++ b/browser/base/content/browser-textZoom.js
@@ -322,27 +322,29 @@ var FullZoom = {
    * and perhaps the same is true for full zoom
    * (although DocumentViewerImpl::SetFullZoom doesn't mention it).
    *
    * So when we apply new zoom values to the browser, we simply set the zoom.
    * We don't check first to see if the new value is the same as the current
    * one.
    **/
   _applyPrefToSetting: function FullZoom__applyPrefToSetting(aValue, aBrowser) {
+    var browser = aBrowser || gBrowser.selectedBrowser;
+
     if (!this.siteSpecific || gInPrintPreviewMode ||
-        content.document instanceof Ci.nsIImageDocument)
+        browser.contentDocument instanceof Ci.nsIImageDocument)
       return;
 
     try {
       if (typeof aValue != "undefined")
-        ZoomManager.setZoomForBrowser(aBrowser || gBrowser, this._ensureValid(aValue));
+        ZoomManager.setZoomForBrowser(browser, this._ensureValid(aValue));
       else if (typeof this.globalValue != "undefined")
-        ZoomManager.setZoomForBrowser(aBrowser || gBrowser, this.globalValue);
+        ZoomManager.setZoomForBrowser(browser, this.globalValue);
       else
-        ZoomManager.setZoomForBrowser(aBrowser || gBrowser, 1);
+        ZoomManager.setZoomForBrowser(browser, 1);
     }
     catch(ex) {}
   },
 
   _applySettingToPref: function FullZoom__applySettingToPref() {
     if (!this.siteSpecific || gInPrintPreviewMode ||
         content.document instanceof Ci.nsIImageDocument)
       return;
--- a/browser/base/content/test/browser_bug386835.js
+++ b/browser/base/content/test/browser_bug386835.js
@@ -1,9 +1,10 @@
 var gTestPage = "http://example.org/browser/browser/base/content/test/dummy_page.html";
+var gTestImage = "http://example.org/browser/browser/base/content/test/moz.png";
 var gTab1, gTab2, gTab3;
 var gLevel;
 
 function test() {
   waitForExplicitFinish();
 
   gTab1 = gBrowser.addTab(gTestPage);
   gTab2 = gBrowser.addTab();
@@ -39,23 +40,33 @@ function thirdPageLoaded() {
 
   // Switching to tab 2 should update its zoom setting.
   gBrowser.selectedTab = gTab2;
 
   zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed");
   zoomTest(gTab2, gLevel, "Tab 2 should be zoomed now");
   zoomTest(gTab3, gLevel, "Tab 3 should still be zoomed");
 
+  load(gTab1, gTestImage, imageLoaded);
+}
+
+function imageLoaded() {
+  zoomTest(gTab1, 1, "Zoom should be 1 when image was loaded in the background");
+  gBrowser.selectedTab = gTab1;
+  zoomTest(gTab1, 1, "Zoom should still be 1 when tab with image is selected");
+
   finishTest();
 }
 
 function finishTest() {
   FullZoom.reset();
   gBrowser.removeTab(gTab1);
+  FullZoom.reset();
   gBrowser.removeTab(gTab2);
+  FullZoom.reset();
   gBrowser.removeTab(gTab3);
   finish();
 }
 
 function zoomTest(tab, val, msg) {
   is(ZoomManager.getZoomForBrowser(tab.linkedBrowser), val, msg);
 }