browser/base/content/test/general/browser_bug719271.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 "use strict";
michael@0 5
michael@0 6 const TEST_PAGE = "http://example.org/browser/browser/base/content/test/general/zoom_test.html";
michael@0 7 const TEST_VIDEO = "http://example.org/browser/browser/base/content/test/general/video.ogg";
michael@0 8
michael@0 9 var gTab1, gTab2, gLevel1, gLevel2;
michael@0 10
michael@0 11 function test() {
michael@0 12 waitForExplicitFinish();
michael@0 13
michael@0 14 Task.spawn(function () {
michael@0 15 gTab1 = gBrowser.addTab();
michael@0 16 gTab2 = gBrowser.addTab();
michael@0 17
michael@0 18 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
michael@0 19 yield FullZoomHelper.load(gTab1, TEST_PAGE);
michael@0 20 yield FullZoomHelper.load(gTab2, TEST_VIDEO);
michael@0 21 }).then(zoomTab1, FullZoomHelper.failAndContinue(finish));
michael@0 22 }
michael@0 23
michael@0 24 function zoomTab1() {
michael@0 25 Task.spawn(function () {
michael@0 26 is(gBrowser.selectedTab, gTab1, "Tab 1 is selected");
michael@0 27 FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1");
michael@0 28 FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1");
michael@0 29
michael@0 30 FullZoom.enlarge();
michael@0 31 gLevel1 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1));
michael@0 32
michael@0 33 ok(gLevel1 > 1, "New zoom for tab 1 should be greater than 1");
michael@0 34 FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2");
michael@0 35
michael@0 36 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
michael@0 37 FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 is still unzoomed after it is selected");
michael@0 38 FullZoomHelper.zoomTest(gTab1, gLevel1, "Tab 1 is still zoomed");
michael@0 39 }).then(zoomTab2, FullZoomHelper.failAndContinue(finish));
michael@0 40 }
michael@0 41
michael@0 42 function zoomTab2() {
michael@0 43 Task.spawn(function () {
michael@0 44 is(gBrowser.selectedTab, gTab2, "Tab 2 is selected");
michael@0 45
michael@0 46 FullZoom.reduce();
michael@0 47 let gLevel2 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab2));
michael@0 48
michael@0 49 ok(gLevel2 < 1, "New zoom for tab 2 should be less than 1");
michael@0 50 FullZoomHelper.zoomTest(gTab1, gLevel1, "Zooming tab 2 should not affect tab 1");
michael@0 51
michael@0 52 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
michael@0 53 FullZoomHelper.zoomTest(gTab1, gLevel1, "Tab 1 should have the same zoom after it's selected");
michael@0 54 }).then(testNavigation, FullZoomHelper.failAndContinue(finish));
michael@0 55 }
michael@0 56
michael@0 57 function testNavigation() {
michael@0 58 Task.spawn(function () {
michael@0 59 yield FullZoomHelper.load(gTab1, TEST_VIDEO);
michael@0 60 FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 when a video was loaded");
michael@0 61 yield waitForNextTurn(); // trying to fix orange bug 806046
michael@0 62 yield FullZoomHelper.navigate(FullZoomHelper.BACK);
michael@0 63 FullZoomHelper.zoomTest(gTab1, gLevel1, "Zoom should be restored when a page is loaded");
michael@0 64 yield waitForNextTurn(); // trying to fix orange bug 806046
michael@0 65 yield FullZoomHelper.navigate(FullZoomHelper.FORWARD);
michael@0 66 FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 again when navigating back to a video");
michael@0 67 }).then(finishTest, FullZoomHelper.failAndContinue(finish));
michael@0 68 }
michael@0 69
michael@0 70 function waitForNextTurn() {
michael@0 71 let deferred = Promise.defer();
michael@0 72 setTimeout(function () deferred.resolve(), 0);
michael@0 73 return deferred.promise;
michael@0 74 }
michael@0 75
michael@0 76 var finishTestStarted = false;
michael@0 77 function finishTest() {
michael@0 78 Task.spawn(function () {
michael@0 79 ok(!finishTestStarted, "finishTest called more than once");
michael@0 80 finishTestStarted = true;
michael@0 81
michael@0 82 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
michael@0 83 FullZoom.reset();
michael@0 84 yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
michael@0 85 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
michael@0 86 FullZoom.reset();
michael@0 87 yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
michael@0 88 }).then(finish, FullZoomHelper.failAndContinue(finish));
michael@0 89 }

mercurial