browser/components/tabview/test/browser_tabview_bug595518.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 function test() {
     5   waitForExplicitFinish();
     7   // show tab view
     8   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
     9   TabView.toggle();
    10 }
    12 function onTabViewWindowLoaded() {
    13   window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
    14   ok(TabView.isVisible(), "Tab View is visible");
    16   let contentWindow = document.getElementById("tab-view").contentWindow;
    18   let onTabViewHidden = function() {
    19     window.removeEventListener("tabviewhidden", onTabViewHidden, false);
    21     // verify exit button worked
    22     ok(!TabView.isVisible(), "Tab View is hidden");
    24     // verify that the exit button no longer has focus
    25     is(contentWindow.iQ("#exit-button:focus").length, 0, 
    26        "The exit button doesn't have the focus");
    28     // verify that the keyboard combo works (this is the crux of bug 595518)
    29     // Prepare the key combo
    30     window.addEventListener("tabviewshown", onTabViewShown, false);
    31     EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, contentWindow);
    32   }
    34   let onTabViewShown = function() {
    35     window.removeEventListener("tabviewshown", onTabViewShown, false);
    37     // test if the key combo worked
    38     ok(TabView.isVisible(), "Tab View is visible");
    40     // clean up
    41     let endGame = function() {
    42       window.removeEventListener("tabviewhidden", endGame, false);
    44       ok(!TabView.isVisible(), "Tab View is hidden");
    45       finish();
    46     }
    47     window.addEventListener("tabviewhidden", endGame, false);
    48     TabView.toggle();
    49   }
    51   window.addEventListener("tabviewhidden", onTabViewHidden, false);
    53   // locate exit button
    54   let button = contentWindow.document.getElementById("exit-button");
    55   ok(button, "Exit button exists");
    57   // click exit button
    58   button.focus();
    59   EventUtils.sendMouseEvent({ type: "click" }, button, contentWindow);
    60 }

mercurial