michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: function onTabViewWindowLoaded() { michael@0: window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: let [originalTab] = gBrowser.visibleTabs; michael@0: let contentWindow = document.getElementById("tab-view").contentWindow; michael@0: michael@0: // create group which we'll close michael@0: let box1 = new contentWindow.Rect(310, 10, 300, 300); michael@0: let group1 = new contentWindow.GroupItem([], { bounds: box1 }); michael@0: ok(group1.isEmpty(), "This group is empty"); michael@0: contentWindow.UI.setActive(group1); michael@0: let tab1 = gBrowser.loadOneTab("about:blank#1", {inBackground: true}); michael@0: let tab1Item = tab1._tabViewTabItem; michael@0: ok(group1.getChildren().some(function(child) child == tab1Item), "The tab was made in our new group"); michael@0: is(group1.getChildren().length, 1, "Only one tab in the first group"); michael@0: michael@0: group1.addSubscriber("close", function onClose() { michael@0: group1.removeSubscriber("close", onClose); michael@0: michael@0: let onTabViewHidden = function() { michael@0: window.removeEventListener("tabviewhidden", onTabViewHidden, false); michael@0: // assert that we're no longer in tab view michael@0: ok(!TabView.isVisible(), "Tab View is hidden"); michael@0: finish(); michael@0: }; michael@0: window.addEventListener("tabviewhidden", onTabViewHidden, false); michael@0: michael@0: // delay to give time for hidden group DOM element to be removed so michael@0: // the appropriate group would get selected when the key michael@0: // combination is pressed michael@0: executeSoon(function() { michael@0: EventUtils.synthesizeKey("e", {accelKey : true, shiftKey: true}, contentWindow); michael@0: }); michael@0: }); michael@0: michael@0: hideGroupItem(group1, function () { michael@0: // close undo group michael@0: let closeButton = group1.$undoContainer.find(".close"); michael@0: EventUtils.sendMouseEvent( michael@0: { type: "click" }, closeButton[0], contentWindow); michael@0: }); michael@0: } michael@0: