gecko/browser/base/content/test/tabview/browser_tabview_bug595930.js
Raymond Lee 1f8228e780 Bug 587276 - KeyEvent in TabCandy window affect browser [r=ian]
--HG--
extra : rebase_source : 9076dbf84083b547498e997fa3ceaa9d7fa04b7e
2011-03-29 10:51:26 +08:00

61 lines
2.1 KiB
JavaScript

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