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: // verify initial state michael@0: ok(!TabView.isVisible(), "Tab View starts hidden"); michael@0: michael@0: window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: let originalGroupItem = null; michael@0: let originalTab = null; michael@0: let contentWindow = null; michael@0: michael@0: function onTabViewWindowLoaded() { michael@0: window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: contentWindow = document.getElementById("tab-view").contentWindow; michael@0: michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "There is one group item on startup"); michael@0: originalGroupItem = contentWindow.GroupItems.groupItems[0]; michael@0: is(originalGroupItem.getChildren().length, 1, "There should be one Tab Item in that group."); michael@0: contentWindow.UI.setActive(originalGroupItem); michael@0: michael@0: [originalTab] = gBrowser.visibleTabs; michael@0: michael@0: testEmptyGroupItem(contentWindow); michael@0: } michael@0: michael@0: function testEmptyGroupItem(contentWindow) { michael@0: let groupItemCount = contentWindow.GroupItems.groupItems.length; michael@0: michael@0: // Preparation michael@0: // michael@0: michael@0: // create empty group item michael@0: let emptyGroupItem = createEmptyGroupItem(contentWindow, 253, 335, 100); michael@0: ok(emptyGroupItem.isEmpty(), "This group is empty"); michael@0: michael@0: is(contentWindow.GroupItems.groupItems.length, ++groupItemCount, michael@0: "The number of groups is increased by 1"); michael@0: michael@0: // add four blank items michael@0: contentWindow.UI.setActive(emptyGroupItem); michael@0: michael@0: let numNewTabs = 4; michael@0: let items = []; michael@0: for(let t=0; t ibounds.top + ibounds.height) || michael@0: (jbounds.left+jbounds.width < ibounds.left) || michael@0: (jbounds.left > ibounds.left + ibounds.width), michael@0: "Items do not overlap: " michael@0: +jbounds.left+","+jbounds.top+","+jbounds.width+","+jbounds.height+" ; " michael@0: +ibounds.left+","+ibounds.top+","+ibounds.width+","+ibounds.height); michael@0: } michael@0: } michael@0: } michael@0: michael@0: // Shut down michael@0: emptyGroupItem.addSubscriber("close", function onClose() { michael@0: emptyGroupItem.removeSubscriber("close", onClose); michael@0: michael@0: // check the number of groups. michael@0: is(contentWindow.GroupItems.groupItems.length, --groupItemCount, michael@0: "The number of groups is decreased by 1"); 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: TabView.toggle(); michael@0: }); michael@0: michael@0: let closeButton = emptyGroupItem.container.getElementsByClassName("close"); michael@0: ok(closeButton[0], "Group close button exists"); michael@0: michael@0: // click the close button michael@0: EventUtils.synthesizeMouse(closeButton[0], 1, 1, {}, contentWindow); michael@0: }; michael@0: michael@0: mainTestFunc(); michael@0: }