browser/components/tabview/test/browser_tabview_bug595804.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 var prefsBranch = Cc["@mozilla.org/preferences-service;1"].
     5                   getService(Ci.nsIPrefService).
     6                   getBranch("browser.panorama.");
     8 function animateZoom() prefsBranch.getBoolPref("animate_zoom");
    10 let contentWindow = null;
    12 registerCleanupFunction(function() {
    13   // reset to default: true
    14   prefsBranch.setBoolPref("animate_zoom", true);
    15 });
    17 function test() {
    18   requestLongerTimeout(2);
    19   waitForExplicitFinish();
    21   ok(!TabView.isVisible(), "Tab View is not visible");
    23   window.addEventListener("tabviewshown", startTesting, false);
    24   TabView.toggle();
    25 }
    27 function startTesting() {
    28   window.removeEventListener("tabviewshown", startTesting, false);
    30   contentWindow = document.getElementById("tab-view").contentWindow;
    32   ok(TabView.isVisible(), "Tab View is visible");
    34   ok(animateZoom(), "By default, we want to animate");
    36   function finishOnHidden() {
    37     contentWindow.removeEventListener("tabviewhidden", finishOnHidden, false);
    38     ok(!TabView.isVisible(), "Tab View is not visible");
    39     finish();
    40   }
    42   function wrapup() {
    43     contentWindow.addEventListener("tabviewhidden", finishOnHidden, false);
    44     TabView.hide();
    45   }
    47   function part2() {
    48     prefsBranch.setBoolPref("animate_zoom", false);
    49     ok(!animateZoom(), "animate_zoom = false");
    50     zoomInAndOut(false, wrapup);
    51   }
    53   function part1() {
    54     prefsBranch.setBoolPref("animate_zoom",true);
    55     ok(animateZoom(), "animate_zoom = true");
    56     zoomInAndOut(true, part2);
    57   }
    59   // start it up!
    60   part1();
    61 }
    63 function zoomInAndOut(transitionsExpected, callback) {
    64   let transitioned = 0;
    66   contentWindow.document.addEventListener("transitionend", onTransitionEnd, false);
    67   function onTransitionEnd(event) {
    68     transitioned++;
    69   }
    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   };
    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");
    87     contentWindow.document.removeEventListener("transitionend", onTransitionEnd, false);
    88     callback();
    89   };
    91   contentWindow.addEventListener("tabviewhidden", onHidden, false);
    92   contentWindow.addEventListener("tabviewshown", onShownAgain, false);
    94   // get this party started by hiding tab view
    95   TabView.toggle();
    96 }

mercurial