michael@0: var gTestPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; michael@0: var gTestImage = "http://example.org/browser/browser/base/content/test/general/moz.png"; michael@0: var gTab1, gTab2, gTab3; michael@0: var gLevel; michael@0: const BACK = 0; michael@0: const FORWARD = 1; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: Task.spawn(function () { michael@0: gTab1 = gBrowser.addTab(gTestPage); michael@0: gTab2 = gBrowser.addTab(); michael@0: gTab3 = gBrowser.addTab(); michael@0: michael@0: yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); michael@0: yield FullZoomHelper.load(gTab1, gTestPage); michael@0: yield FullZoomHelper.load(gTab2, gTestPage); michael@0: }).then(secondPageLoaded, FullZoomHelper.failAndContinue(finish)); michael@0: } michael@0: michael@0: function secondPageLoaded() { michael@0: Task.spawn(function () { michael@0: FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1"); michael@0: FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1"); michael@0: FullZoomHelper.zoomTest(gTab3, 1, "Initial zoom of tab 3 should be 1"); michael@0: michael@0: // Now have three tabs, two with the test page, one blank. Tab 1 is selected michael@0: // Zoom tab 1 michael@0: FullZoom.enlarge(); michael@0: gLevel = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)); michael@0: michael@0: ok(gLevel > 1, "New zoom for tab 1 should be greater than 1"); michael@0: FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2"); michael@0: FullZoomHelper.zoomTest(gTab3, 1, "Zooming tab 1 should not affect tab 3"); michael@0: michael@0: yield FullZoomHelper.load(gTab3, gTestPage); michael@0: }).then(thirdPageLoaded, FullZoomHelper.failAndContinue(finish)); michael@0: } michael@0: michael@0: function thirdPageLoaded() { michael@0: Task.spawn(function () { michael@0: FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed"); michael@0: FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 should still not be affected"); michael@0: FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should have zoomed as it was loading in the background"); michael@0: michael@0: // Switching to tab 2 should update its zoom setting. michael@0: yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); michael@0: FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed"); michael@0: FullZoomHelper.zoomTest(gTab2, gLevel, "Tab 2 should be zoomed now"); michael@0: FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should still be zoomed"); michael@0: michael@0: yield FullZoomHelper.load(gTab1, gTestImage); michael@0: }).then(imageLoaded, FullZoomHelper.failAndContinue(finish)); michael@0: } michael@0: michael@0: function imageLoaded() { michael@0: Task.spawn(function () { michael@0: FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 when image was loaded in the background"); michael@0: yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); michael@0: FullZoomHelper.zoomTest(gTab1, 1, "Zoom should still be 1 when tab with image is selected"); michael@0: }).then(imageZoomSwitch, FullZoomHelper.failAndContinue(finish)); michael@0: } michael@0: michael@0: function imageZoomSwitch() { michael@0: Task.spawn(function () { michael@0: yield FullZoomHelper.navigate(BACK); michael@0: yield FullZoomHelper.navigate(FORWARD); michael@0: FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should not be zoomed when an image loads"); michael@0: michael@0: yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); michael@0: FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should still not be zoomed when deselected"); michael@0: }).then(finishTest, FullZoomHelper.failAndContinue(finish)); michael@0: } michael@0: michael@0: var finishTestStarted = false; michael@0: function finishTest() { michael@0: Task.spawn(function () { michael@0: ok(!finishTestStarted, "finishTest called more than once"); michael@0: finishTestStarted = true; michael@0: yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); michael@0: FullZoom.reset(); michael@0: yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); michael@0: FullZoom.reset(); michael@0: yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); michael@0: FullZoom.reset(); michael@0: yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab3); michael@0: }).then(finish, FullZoomHelper.failAndContinue(finish)); michael@0: }