1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_startup_transitions.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,59 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +var prefsBranch = Cc["@mozilla.org/preferences-service;1"]. 1.8 + getService(Ci.nsIPrefService). 1.9 + getBranch("browser.panorama."); 1.10 + 1.11 +function animateZoom() prefsBranch.getBoolPref("animate_zoom"); 1.12 + 1.13 +function test() { 1.14 + waitForExplicitFinish(); 1.15 + 1.16 + let charsetArg = "charset=" + window.content.document.characterSet; 1.17 + let win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", 1.18 + "about:blank", charsetArg, null, null, true); 1.19 + 1.20 + registerCleanupFunction(function() { 1.21 + prefsBranch.setBoolPref("animate_zoom", true); 1.22 + win.close(); 1.23 + }); 1.24 + 1.25 + ok(animateZoom(), "By default, we animate on zoom."); 1.26 + prefsBranch.setBoolPref("animate_zoom", false); 1.27 + ok(!animateZoom(), "animate_zoom = false"); 1.28 + 1.29 + let onLoad = function() { 1.30 + win.removeEventListener("load", onLoad, false); 1.31 + 1.32 + // a few shared references 1.33 + let tabViewWindow = null; 1.34 + let transitioned = 0; 1.35 + 1.36 + let initCallback = function() { 1.37 + tabViewWindow = win.TabView.getContentWindow(); 1.38 + function onTransitionEnd(event) { 1.39 + transitioned++; 1.40 + info(transitioned); 1.41 + } 1.42 + tabViewWindow.document.addEventListener("transitionend", onTransitionEnd, false); 1.43 + 1.44 + // don't use showTabView() here because we only want to check whether 1.45 + // zoom out animation happens. Other animations would happen before 1.46 + // the callback as waitForFocus() was added to showTabView() in head.js 1.47 + let onTabViewShown = function() { 1.48 + tabViewWindow.removeEventListener("tabviewshown", onTabViewShown, false); 1.49 + tabViewWindow.document.removeEventListener("transitionend", onTransitionEnd, false); 1.50 + 1.51 + ok(!transitioned, "There should be no transitions"); 1.52 + 1.53 + finish(); 1.54 + }; 1.55 + tabViewWindow.addEventListener("tabviewshown", onTabViewShown, false); 1.56 + win.TabView.toggle(); 1.57 + }; 1.58 + 1.59 + win.TabView._initFrame(initCallback); 1.60 + } 1.61 + win.addEventListener("load", onLoad, false); 1.62 +}