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: let win, cw, groupItem; michael@0: michael@0: function checkNumberOfGroupItems(num) { michael@0: is(cw.GroupItems.groupItems.length, num, "there are " + num + " groupItems"); michael@0: } michael@0: michael@0: function next() { michael@0: if (tests.length) michael@0: tests.shift()(); michael@0: else michael@0: finish(); michael@0: } michael@0: michael@0: // Empty groups should not be closed when toggling Panorama on and off. michael@0: function test1() { michael@0: hideTabView(function () { michael@0: showTabView(function () { michael@0: checkNumberOfGroupItems(2); michael@0: next(); michael@0: }, win); michael@0: }, win); michael@0: } michael@0: michael@0: // Groups should not be closed when their last tab is closed outside of Panorama. michael@0: function test2() { michael@0: whenTabViewIsHidden(function () { michael@0: whenTabViewIsShown(function () { michael@0: checkNumberOfGroupItems(2); michael@0: next(); michael@0: }, win); michael@0: michael@0: win.gBrowser.removeTab(win.gBrowser.selectedTab); michael@0: }, win); michael@0: michael@0: groupItem.newTab(); michael@0: } michael@0: michael@0: // Groups should be closed when their last tab is closed. michael@0: function test3() { michael@0: whenTabViewIsHidden(function () { michael@0: showTabView(function () { michael@0: let tab = win.gBrowser.tabs[1]; michael@0: tab._tabViewTabItem.close(); michael@0: checkNumberOfGroupItems(1); michael@0: next(); michael@0: }, win); michael@0: }, win); michael@0: michael@0: win.gBrowser.addTab(); michael@0: } michael@0: michael@0: // Groups should be closed when their last tab is dragged out. michael@0: function test4() { michael@0: groupItem = createGroupItemWithBlankTabs(win, 200, 200, 20, 1); michael@0: checkNumberOfGroupItems(2); michael@0: michael@0: let tab = win.gBrowser.tabs[1]; michael@0: let target = tab._tabViewTabItem.container; michael@0: michael@0: waitForFocus(function () { michael@0: EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); michael@0: EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw); michael@0: EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw); michael@0: michael@0: checkNumberOfGroupItems(2); michael@0: closeGroupItem(cw.GroupItems.groupItems[1], next); michael@0: }, win); michael@0: } michael@0: michael@0: let tests = [test1, test2, test3, test4]; michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: newWindowWithTabView(function (aWin) { michael@0: registerCleanupFunction(function () aWin.close()); michael@0: michael@0: win = aWin; michael@0: cw = win.TabView.getContentWindow(); michael@0: groupItem = createEmptyGroupItem(cw, 200, 200, 20); michael@0: michael@0: checkNumberOfGroupItems(2); michael@0: next(); michael@0: }); michael@0: }