browser/components/tabview/test/browser_tabview_startup_transitions.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:9bdd6c88ab95
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 function test() {
11 waitForExplicitFinish();
12
13 let charsetArg = "charset=" + window.content.document.characterSet;
14 let win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
15 "about:blank", charsetArg, null, null, true);
16
17 registerCleanupFunction(function() {
18 prefsBranch.setBoolPref("animate_zoom", true);
19 win.close();
20 });
21
22 ok(animateZoom(), "By default, we animate on zoom.");
23 prefsBranch.setBoolPref("animate_zoom", false);
24 ok(!animateZoom(), "animate_zoom = false");
25
26 let onLoad = function() {
27 win.removeEventListener("load", onLoad, false);
28
29 // a few shared references
30 let tabViewWindow = null;
31 let transitioned = 0;
32
33 let initCallback = function() {
34 tabViewWindow = win.TabView.getContentWindow();
35 function onTransitionEnd(event) {
36 transitioned++;
37 info(transitioned);
38 }
39 tabViewWindow.document.addEventListener("transitionend", onTransitionEnd, false);
40
41 // don't use showTabView() here because we only want to check whether
42 // zoom out animation happens. Other animations would happen before
43 // the callback as waitForFocus() was added to showTabView() in head.js
44 let onTabViewShown = function() {
45 tabViewWindow.removeEventListener("tabviewshown", onTabViewShown, false);
46 tabViewWindow.document.removeEventListener("transitionend", onTransitionEnd, false);
47
48 ok(!transitioned, "There should be no transitions");
49
50 finish();
51 };
52 tabViewWindow.addEventListener("tabviewshown", onTabViewShown, false);
53 win.TabView.toggle();
54 };
55
56 win.TabView._initFrame(initCallback);
57 }
58 win.addEventListener("load", onLoad, false);
59 }

mercurial