1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug719271.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +"use strict"; 1.8 + 1.9 +const TEST_PAGE = "http://example.org/browser/browser/base/content/test/general/zoom_test.html"; 1.10 +const TEST_VIDEO = "http://example.org/browser/browser/base/content/test/general/video.ogg"; 1.11 + 1.12 +var gTab1, gTab2, gLevel1, gLevel2; 1.13 + 1.14 +function test() { 1.15 + waitForExplicitFinish(); 1.16 + 1.17 + Task.spawn(function () { 1.18 + gTab1 = gBrowser.addTab(); 1.19 + gTab2 = gBrowser.addTab(); 1.20 + 1.21 + yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); 1.22 + yield FullZoomHelper.load(gTab1, TEST_PAGE); 1.23 + yield FullZoomHelper.load(gTab2, TEST_VIDEO); 1.24 + }).then(zoomTab1, FullZoomHelper.failAndContinue(finish)); 1.25 +} 1.26 + 1.27 +function zoomTab1() { 1.28 + Task.spawn(function () { 1.29 + is(gBrowser.selectedTab, gTab1, "Tab 1 is selected"); 1.30 + FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1"); 1.31 + FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1"); 1.32 + 1.33 + FullZoom.enlarge(); 1.34 + gLevel1 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1)); 1.35 + 1.36 + ok(gLevel1 > 1, "New zoom for tab 1 should be greater than 1"); 1.37 + FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2"); 1.38 + 1.39 + yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); 1.40 + FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 is still unzoomed after it is selected"); 1.41 + FullZoomHelper.zoomTest(gTab1, gLevel1, "Tab 1 is still zoomed"); 1.42 + }).then(zoomTab2, FullZoomHelper.failAndContinue(finish)); 1.43 +} 1.44 + 1.45 +function zoomTab2() { 1.46 + Task.spawn(function () { 1.47 + is(gBrowser.selectedTab, gTab2, "Tab 2 is selected"); 1.48 + 1.49 + FullZoom.reduce(); 1.50 + let gLevel2 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab2)); 1.51 + 1.52 + ok(gLevel2 < 1, "New zoom for tab 2 should be less than 1"); 1.53 + FullZoomHelper.zoomTest(gTab1, gLevel1, "Zooming tab 2 should not affect tab 1"); 1.54 + 1.55 + yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); 1.56 + FullZoomHelper.zoomTest(gTab1, gLevel1, "Tab 1 should have the same zoom after it's selected"); 1.57 + }).then(testNavigation, FullZoomHelper.failAndContinue(finish)); 1.58 +} 1.59 + 1.60 +function testNavigation() { 1.61 + Task.spawn(function () { 1.62 + yield FullZoomHelper.load(gTab1, TEST_VIDEO); 1.63 + FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 when a video was loaded"); 1.64 + yield waitForNextTurn(); // trying to fix orange bug 806046 1.65 + yield FullZoomHelper.navigate(FullZoomHelper.BACK); 1.66 + FullZoomHelper.zoomTest(gTab1, gLevel1, "Zoom should be restored when a page is loaded"); 1.67 + yield waitForNextTurn(); // trying to fix orange bug 806046 1.68 + yield FullZoomHelper.navigate(FullZoomHelper.FORWARD); 1.69 + FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 again when navigating back to a video"); 1.70 + }).then(finishTest, FullZoomHelper.failAndContinue(finish)); 1.71 +} 1.72 + 1.73 +function waitForNextTurn() { 1.74 + let deferred = Promise.defer(); 1.75 + setTimeout(function () deferred.resolve(), 0); 1.76 + return deferred.promise; 1.77 +} 1.78 + 1.79 +var finishTestStarted = false; 1.80 +function finishTest() { 1.81 + Task.spawn(function () { 1.82 + ok(!finishTestStarted, "finishTest called more than once"); 1.83 + finishTestStarted = true; 1.84 + 1.85 + yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); 1.86 + FullZoom.reset(); 1.87 + yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); 1.88 + yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); 1.89 + FullZoom.reset(); 1.90 + yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); 1.91 + }).then(finish, FullZoomHelper.failAndContinue(finish)); 1.92 +}