browser/components/tabview/test/browser_tabview_bug587276.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_bug587276.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,106 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +let contentWindow;
     1.8 +
     1.9 +function test() {
    1.10 +  requestLongerTimeout(2);
    1.11 +  waitForExplicitFinish();
    1.12 +
    1.13 +  showTabView(test1);
    1.14 +}
    1.15 +
    1.16 +function test1() {
    1.17 +  ok(TabView.isVisible(), "Tab View is visible");
    1.18 +
    1.19 +  contentWindow = document.getElementById("tab-view").contentWindow;
    1.20 +  whenTabViewIsHidden(function() {
    1.21 +    ok(!TabView.isVisible(), "Tab View is not visible");
    1.22 +    showTabView(test2);
    1.23 +  });
    1.24 +  EventUtils.synthesizeKey("e", { accelKey: true, shiftKey: true }, contentWindow);
    1.25 +}
    1.26 +
    1.27 +function test2() {
    1.28 +  ok(TabView.isVisible(), "Tab View is visible");
    1.29 +
    1.30 +  whenSearchIsEnabled(function() {
    1.31 +    ok(contentWindow.Search.isEnabled(), "The search is enabled")
    1.32 +
    1.33 +    whenSearchIsDisabled(test3);
    1.34 +    hideSearch();
    1.35 +  });
    1.36 +  EventUtils.synthesizeKey("f", { accelKey: true }, contentWindow);
    1.37 +}
    1.38 +
    1.39 +function test3() {
    1.40 +  ok(!contentWindow.Search.isEnabled(), "The search is disabled")
    1.41 +
    1.42 +  is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + t is pressed");
    1.43 +
    1.44 +  whenTabViewIsHidden(function() { 
    1.45 +    is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + t is pressed");
    1.46 +
    1.47 +    gBrowser.tabs[0].linkedBrowser.loadURI("about:mozilla");
    1.48 +    gBrowser.tabs[1].linkedBrowser.loadURI("http://example.com/");
    1.49 +
    1.50 +    afterAllTabsLoaded(function () {
    1.51 +      showTabView(test4);
    1.52 +    });
    1.53 +  });
    1.54 +  EventUtils.synthesizeKey("t", { accelKey: true }, contentWindow);
    1.55 +}
    1.56 +
    1.57 +function test4() {
    1.58 +  is(gBrowser.tabs.length, 2, "There are two tabs");
    1.59 +
    1.60 +  let onTabClose = function() {
    1.61 +    gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, true);
    1.62 +    executeSoon(function() {
    1.63 +      is(gBrowser.tabs.length, 1, "There is one tab after removing one");
    1.64 +
    1.65 +      EventUtils.synthesizeKey("t", { accelKey: true, shiftKey: true }, contentWindow);
    1.66 +      is(gBrowser.tabs.length, 2, "There are two tabs after restoring one");
    1.67 +
    1.68 +      gBrowser.tabs[0].linkedBrowser.loadURI("about:blank");
    1.69 +      gBrowser.selectedTab = gBrowser.tabs[0];
    1.70 +      test8();
    1.71 +    });
    1.72 +  };
    1.73 +  gBrowser.tabContainer.addEventListener("TabClose", onTabClose, true);
    1.74 +  gBrowser.removeTab(gBrowser.tabs[1]);
    1.75 +}
    1.76 +
    1.77 +// below key combination shouldn't trigger actions in tabview UI
    1.78 +function test8() {
    1.79 +  showTabView(function() {
    1.80 +    is(gBrowser.tabs.length, 2, "There are two tabs before cmd/ctrl + w is pressed");
    1.81 +    EventUtils.synthesizeKey("w", { accelKey: true }, contentWindow);
    1.82 +    is(gBrowser.tabs.length, 2, "There are two tabs after cmd/ctrl + w is pressed");
    1.83 +
    1.84 +    gBrowser.removeTab(gBrowser.tabs[1]);
    1.85 +    test9();
    1.86 +  });
    1.87 +}
    1.88 +
    1.89 +function test9() {
    1.90 +  let zoomLevel = ZoomManager.zoom;
    1.91 +  EventUtils.synthesizeKey("+", { accelKey: true }, contentWindow);
    1.92 +  is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + + is pressed");
    1.93 +
    1.94 +  EventUtils.synthesizeKey("-", { accelKey: true }, contentWindow);
    1.95 +  is(ZoomManager.zoom, zoomLevel, "The zoom level remains unchanged after cmd/ctrl + - is pressed");
    1.96 +
    1.97 +  test10();
    1.98 +}
    1.99 +
   1.100 +function test10() {
   1.101 +  is(gBrowser.tabs.length, 1, "There is one tab before cmd/ctrl + shift + a is pressed");
   1.102 +  // it would open about:addons on a new tab if it passes through the white list.
   1.103 +  EventUtils.synthesizeKey("a", { accelKey: true, shiftKey: true }, contentWindow);
   1.104 +
   1.105 +  executeSoon(function() {
   1.106 +    is(gBrowser.tabs.length, 1, "There is still one tab after cmd/ctrl + shift + a is pressed");
   1.107 +    hideTabView(finish);
   1.108 +  })
   1.109 +}

mercurial