|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 var prefsBranch = Cc["@mozilla.org/preferences-service;1"]. |
|
5 getService(Ci.nsIPrefService). |
|
6 getBranch("browser.panorama."); |
|
7 |
|
8 function animateZoom() prefsBranch.getBoolPref("animate_zoom"); |
|
9 |
|
10 let contentWindow = null; |
|
11 |
|
12 registerCleanupFunction(function() { |
|
13 // reset to default: true |
|
14 prefsBranch.setBoolPref("animate_zoom", true); |
|
15 }); |
|
16 |
|
17 function test() { |
|
18 requestLongerTimeout(2); |
|
19 waitForExplicitFinish(); |
|
20 |
|
21 ok(!TabView.isVisible(), "Tab View is not visible"); |
|
22 |
|
23 window.addEventListener("tabviewshown", startTesting, false); |
|
24 TabView.toggle(); |
|
25 } |
|
26 |
|
27 function startTesting() { |
|
28 window.removeEventListener("tabviewshown", startTesting, false); |
|
29 |
|
30 contentWindow = document.getElementById("tab-view").contentWindow; |
|
31 |
|
32 ok(TabView.isVisible(), "Tab View is visible"); |
|
33 |
|
34 ok(animateZoom(), "By default, we want to animate"); |
|
35 |
|
36 function finishOnHidden() { |
|
37 contentWindow.removeEventListener("tabviewhidden", finishOnHidden, false); |
|
38 ok(!TabView.isVisible(), "Tab View is not visible"); |
|
39 finish(); |
|
40 } |
|
41 |
|
42 function wrapup() { |
|
43 contentWindow.addEventListener("tabviewhidden", finishOnHidden, false); |
|
44 TabView.hide(); |
|
45 } |
|
46 |
|
47 function part2() { |
|
48 prefsBranch.setBoolPref("animate_zoom", false); |
|
49 ok(!animateZoom(), "animate_zoom = false"); |
|
50 zoomInAndOut(false, wrapup); |
|
51 } |
|
52 |
|
53 function part1() { |
|
54 prefsBranch.setBoolPref("animate_zoom",true); |
|
55 ok(animateZoom(), "animate_zoom = true"); |
|
56 zoomInAndOut(true, part2); |
|
57 } |
|
58 |
|
59 // start it up! |
|
60 part1(); |
|
61 } |
|
62 |
|
63 function zoomInAndOut(transitionsExpected, callback) { |
|
64 let transitioned = 0; |
|
65 |
|
66 contentWindow.document.addEventListener("transitionend", onTransitionEnd, false); |
|
67 function onTransitionEnd(event) { |
|
68 transitioned++; |
|
69 } |
|
70 |
|
71 let onHidden = function() { |
|
72 contentWindow.removeEventListener("tabviewhidden", onHidden, false); |
|
73 if (transitionsExpected) |
|
74 ok(transitioned >= 0, "There can be transitions"); |
|
75 else |
|
76 ok(!transitioned, "There should have been no transitions"); |
|
77 TabView.toggle(); |
|
78 }; |
|
79 |
|
80 let onShownAgain = function() { |
|
81 contentWindow.removeEventListener("tabviewshown", onShownAgain, false); |
|
82 if (transitionsExpected) |
|
83 ok(transitioned >= 0, "There can be transitions"); |
|
84 else |
|
85 ok(!transitioned, "There should have been no transitions"); |
|
86 |
|
87 contentWindow.document.removeEventListener("transitionend", onTransitionEnd, false); |
|
88 callback(); |
|
89 }; |
|
90 |
|
91 contentWindow.addEventListener("tabviewhidden", onHidden, false); |
|
92 contentWindow.addEventListener("tabviewshown", onShownAgain, false); |
|
93 |
|
94 // get this party started by hiding tab view |
|
95 TabView.toggle(); |
|
96 } |