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