michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: var prefsBranch = Cc["@mozilla.org/preferences-service;1"]. michael@0: getService(Ci.nsIPrefService). michael@0: getBranch("browser.panorama."); michael@0: michael@0: function animateZoom() prefsBranch.getBoolPref("animate_zoom"); michael@0: michael@0: let contentWindow = null; michael@0: michael@0: registerCleanupFunction(function() { michael@0: // reset to default: true michael@0: prefsBranch.setBoolPref("animate_zoom", true); michael@0: }); michael@0: michael@0: function test() { michael@0: requestLongerTimeout(2); michael@0: waitForExplicitFinish(); michael@0: michael@0: ok(!TabView.isVisible(), "Tab View is not visible"); michael@0: michael@0: window.addEventListener("tabviewshown", startTesting, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: function startTesting() { michael@0: window.removeEventListener("tabviewshown", startTesting, false); michael@0: michael@0: contentWindow = document.getElementById("tab-view").contentWindow; michael@0: michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: ok(animateZoom(), "By default, we want to animate"); michael@0: michael@0: function finishOnHidden() { michael@0: contentWindow.removeEventListener("tabviewhidden", finishOnHidden, false); michael@0: ok(!TabView.isVisible(), "Tab View is not visible"); michael@0: finish(); michael@0: } michael@0: michael@0: function wrapup() { michael@0: contentWindow.addEventListener("tabviewhidden", finishOnHidden, false); michael@0: TabView.hide(); michael@0: } michael@0: michael@0: function part2() { michael@0: prefsBranch.setBoolPref("animate_zoom", false); michael@0: ok(!animateZoom(), "animate_zoom = false"); michael@0: zoomInAndOut(false, wrapup); michael@0: } michael@0: michael@0: function part1() { michael@0: prefsBranch.setBoolPref("animate_zoom",true); michael@0: ok(animateZoom(), "animate_zoom = true"); michael@0: zoomInAndOut(true, part2); michael@0: } michael@0: michael@0: // start it up! michael@0: part1(); michael@0: } michael@0: michael@0: function zoomInAndOut(transitionsExpected, callback) { michael@0: let transitioned = 0; michael@0: michael@0: contentWindow.document.addEventListener("transitionend", onTransitionEnd, false); michael@0: function onTransitionEnd(event) { michael@0: transitioned++; michael@0: } michael@0: michael@0: let onHidden = function() { michael@0: contentWindow.removeEventListener("tabviewhidden", onHidden, false); michael@0: if (transitionsExpected) michael@0: ok(transitioned >= 0, "There can be transitions"); michael@0: else michael@0: ok(!transitioned, "There should have been no transitions"); michael@0: TabView.toggle(); michael@0: }; michael@0: michael@0: let onShownAgain = function() { michael@0: contentWindow.removeEventListener("tabviewshown", onShownAgain, false); michael@0: if (transitionsExpected) michael@0: ok(transitioned >= 0, "There can be transitions"); michael@0: else michael@0: ok(!transitioned, "There should have been no transitions"); michael@0: michael@0: contentWindow.document.removeEventListener("transitionend", onTransitionEnd, false); michael@0: callback(); michael@0: }; michael@0: michael@0: contentWindow.addEventListener("tabviewhidden", onHidden, false); michael@0: contentWindow.addEventListener("tabviewshown", onShownAgain, false); michael@0: michael@0: // get this party started by hiding tab view michael@0: TabView.toggle(); michael@0: }