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