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 var gTestPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
2 var gTestImage = "http://example.org/browser/browser/base/content/test/general/moz.png";
3 var gTab1, gTab2, gTab3;
4 var gLevel;
5 const BACK = 0;
6 const FORWARD = 1;
8 function test() {
9 waitForExplicitFinish();
11 Task.spawn(function () {
12 gTab1 = gBrowser.addTab(gTestPage);
13 gTab2 = gBrowser.addTab();
14 gTab3 = gBrowser.addTab();
16 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
17 yield FullZoomHelper.load(gTab1, gTestPage);
18 yield FullZoomHelper.load(gTab2, gTestPage);
19 }).then(secondPageLoaded, FullZoomHelper.failAndContinue(finish));
20 }
22 function secondPageLoaded() {
23 Task.spawn(function () {
24 FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1");
25 FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1");
26 FullZoomHelper.zoomTest(gTab3, 1, "Initial zoom of tab 3 should be 1");
28 // Now have three tabs, two with the test page, one blank. Tab 1 is selected
29 // Zoom tab 1
30 FullZoom.enlarge();
31 gLevel = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1));
33 ok(gLevel > 1, "New zoom for tab 1 should be greater than 1");
34 FullZoomHelper.zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2");
35 FullZoomHelper.zoomTest(gTab3, 1, "Zooming tab 1 should not affect tab 3");
37 yield FullZoomHelper.load(gTab3, gTestPage);
38 }).then(thirdPageLoaded, FullZoomHelper.failAndContinue(finish));
39 }
41 function thirdPageLoaded() {
42 Task.spawn(function () {
43 FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed");
44 FullZoomHelper.zoomTest(gTab2, 1, "Tab 2 should still not be affected");
45 FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should have zoomed as it was loading in the background");
47 // Switching to tab 2 should update its zoom setting.
48 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
49 FullZoomHelper.zoomTest(gTab1, gLevel, "Tab 1 should still be zoomed");
50 FullZoomHelper.zoomTest(gTab2, gLevel, "Tab 2 should be zoomed now");
51 FullZoomHelper.zoomTest(gTab3, gLevel, "Tab 3 should still be zoomed");
53 yield FullZoomHelper.load(gTab1, gTestImage);
54 }).then(imageLoaded, FullZoomHelper.failAndContinue(finish));
55 }
57 function imageLoaded() {
58 Task.spawn(function () {
59 FullZoomHelper.zoomTest(gTab1, 1, "Zoom should be 1 when image was loaded in the background");
60 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
61 FullZoomHelper.zoomTest(gTab1, 1, "Zoom should still be 1 when tab with image is selected");
62 }).then(imageZoomSwitch, FullZoomHelper.failAndContinue(finish));
63 }
65 function imageZoomSwitch() {
66 Task.spawn(function () {
67 yield FullZoomHelper.navigate(BACK);
68 yield FullZoomHelper.navigate(FORWARD);
69 FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should not be zoomed when an image loads");
71 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab2);
72 FullZoomHelper.zoomTest(gTab1, 1, "Tab 1 should still not be zoomed when deselected");
73 }).then(finishTest, FullZoomHelper.failAndContinue(finish));
74 }
76 var finishTestStarted = false;
77 function finishTest() {
78 Task.spawn(function () {
79 ok(!finishTestStarted, "finishTest called more than once");
80 finishTestStarted = true;
81 yield FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
82 FullZoom.reset();
83 yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
84 FullZoom.reset();
85 yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
86 FullZoom.reset();
87 yield FullZoomHelper.removeTabAndWaitForLocationChange(gTab3);
88 }).then(finish, FullZoomHelper.failAndContinue(finish));
89 }