browser/components/tabview/test/browser_tabview_bug595930.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_bug595930.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     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 +  window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
    1.11 +  TabView.toggle();
    1.12 +}
    1.13 +
    1.14 +function onTabViewWindowLoaded() {
    1.15 +  window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
    1.16 +
    1.17 +  ok(TabView.isVisible(), "Tab View is visible");
    1.18 +
    1.19 +  let [originalTab] = gBrowser.visibleTabs;
    1.20 +  let contentWindow = document.getElementById("tab-view").contentWindow;
    1.21 +
    1.22 +  // create group which we'll close
    1.23 +  let box1 = new contentWindow.Rect(310, 10, 300, 300);
    1.24 +  let group1 = new contentWindow.GroupItem([], { bounds: box1 });
    1.25 +  ok(group1.isEmpty(), "This group is empty");
    1.26 +  contentWindow.UI.setActive(group1);
    1.27 +  let tab1 = gBrowser.loadOneTab("about:blank#1", {inBackground: true});
    1.28 +  let tab1Item = tab1._tabViewTabItem;
    1.29 +  ok(group1.getChildren().some(function(child) child == tab1Item), "The tab was made in our new group");
    1.30 +  is(group1.getChildren().length, 1, "Only one tab in the first group");
    1.31 +
    1.32 +  group1.addSubscriber("close", function onClose() {
    1.33 +    group1.removeSubscriber("close", onClose);
    1.34 +
    1.35 +    let onTabViewHidden = function() {
    1.36 +      window.removeEventListener("tabviewhidden", onTabViewHidden, false);
    1.37 +      // assert that we're no longer in tab view
    1.38 +      ok(!TabView.isVisible(), "Tab View is hidden");
    1.39 +      finish();
    1.40 +    };
    1.41 +    window.addEventListener("tabviewhidden", onTabViewHidden, false);
    1.42 +
    1.43 +    // delay to give time for hidden group DOM element to be removed so
    1.44 +    // the appropriate group would get selected when the key
    1.45 +    // combination is pressed
    1.46 +    executeSoon(function() { 
    1.47 +      EventUtils.synthesizeKey("e", {accelKey : true, shiftKey: true}, contentWindow);
    1.48 +    });
    1.49 +  });
    1.50 +
    1.51 +  hideGroupItem(group1, function () {
    1.52 +    // close undo group
    1.53 +    let closeButton = group1.$undoContainer.find(".close");
    1.54 +    EventUtils.sendMouseEvent(
    1.55 +      { type: "click" }, closeButton[0], contentWindow);
    1.56 +  });
    1.57 +}
    1.58 +

mercurial