browser/components/tabview/test/browser_tabview_bug595191.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/tabview/test/browser_tabview_bug595191.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function test() {
     1.8 +  waitForExplicitFinish();
     1.9 +
    1.10 +  // show the tab view
    1.11 +  window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
    1.12 +  ok(!TabView.isVisible(), "Tab View is hidden");
    1.13 +  TabView.toggle();
    1.14 +}
    1.15 +
    1.16 +function onTabViewWindowLoaded() {
    1.17 +  window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
    1.18 +
    1.19 +  ok(TabView.isVisible(), "Tab View is visible");
    1.20 +
    1.21 +  let contentWindow = document.getElementById("tab-view").contentWindow;
    1.22 +  let searchButton = contentWindow.document.getElementById("searchbutton");
    1.23 +
    1.24 +  ok(searchButton, "Search button exists");
    1.25 +  
    1.26 +  let onSearchEnabled = function() {
    1.27 +    contentWindow.removeEventListener(
    1.28 +      "tabviewsearchenabled", onSearchEnabled, false);
    1.29 +    let search = contentWindow.document.getElementById("search");
    1.30 +    ok(search.style.display != "none", "Search is enabled");
    1.31 +    escapeTest(contentWindow);
    1.32 +  }
    1.33 +  contentWindow.addEventListener("tabviewsearchenabled", onSearchEnabled, 
    1.34 +    false);
    1.35 +  // enter search mode
    1.36 +  EventUtils.sendMouseEvent({ type: "mousedown" }, searchButton, 
    1.37 +    contentWindow);
    1.38 +}
    1.39 +
    1.40 +function escapeTest(contentWindow) {  
    1.41 +  let onSearchDisabled = function() {
    1.42 +    contentWindow.removeEventListener(
    1.43 +      "tabviewsearchdisabled", onSearchDisabled, false);
    1.44 +
    1.45 +    let search = contentWindow.document.getElementById("search");
    1.46 +    ok(search.style.display == "none", "Search is disabled");
    1.47 +    toggleTabViewTest(contentWindow);
    1.48 +  }
    1.49 +  contentWindow.addEventListener("tabviewsearchdisabled", onSearchDisabled, 
    1.50 +    false);
    1.51 +  EventUtils.synthesizeKey("VK_ESCAPE", { }, contentWindow);
    1.52 +}
    1.53 +
    1.54 +function toggleTabViewTest(contentWindow) {
    1.55 +  let onTabViewHidden = function() {
    1.56 +    contentWindow.removeEventListener("tabviewhidden", onTabViewHidden, false);
    1.57 +
    1.58 +    ok(!TabView.isVisible(), "Tab View is hidden");
    1.59 +    finish();
    1.60 +  }
    1.61 +  contentWindow.addEventListener("tabviewhidden", onTabViewHidden, false);
    1.62 +  // Use keyboard shortcut to toggle back to browser view
    1.63 +  EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true });
    1.64 +}

mercurial