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: let tContextMenu = document.getElementById("tabContextMenu"); michael@0: let tvMenuPopup = document.getElementById("context_tabViewMenuPopup"); michael@0: let group1; michael@0: let group2; michael@0: michael@0: function openMoveToGroupPopup() { michael@0: let tab = gBrowser.selectedTab; michael@0: let tvMenu = document.getElementById("context_tabViewMenu"); michael@0: let tvMenuPopup = document.getElementById("context_tabViewMenuPopup"); michael@0: let tvEvent = new Event(""); michael@0: michael@0: tab.dispatchEvent(tvEvent); michael@0: tContextMenu.openPopup(tab, "end_after", 0, 0, true, false, tvEvent); michael@0: tvMenuPopup.openPopup(tvMenu, "end_after", 0, 0, true, false); michael@0: } michael@0: michael@0: function hideMoveToGroupPopup() { michael@0: tvMenuPopup.hidePopup(); michael@0: tContextMenu.hidePopup(); michael@0: } michael@0: michael@0: function createGroups() { michael@0: let cw = TabView.getContentWindow(); michael@0: michael@0: group1 = createGroupItemWithTabs(window, 200, 200, 20, ["about:blank"]); michael@0: group1.setTitle("group with items and title"); michael@0: group2 = createEmptyGroupItem(cw, 200, 200, 20); michael@0: cw.UI.setActive(cw.GroupItems.groupItems[0]); michael@0: michael@0: // Check the group count. michael@0: is(cw.GroupItems.groupItems.length, 3, "Validate group count in tab view."); michael@0: michael@0: hideTabView(checkGroupMenuItems); michael@0: } michael@0: michael@0: // The group count includes the separator and the 'new group' menu item. michael@0: function checkGroupMenuItems() { michael@0: // First test with an empty untitled group. michael@0: openMoveToGroupPopup(); michael@0: is(tvMenuPopup.childNodes.length, 3, "Validate group item count in move to group popup."); michael@0: hideMoveToGroupPopup(); michael@0: michael@0: // Then test with an empty but titled group. michael@0: group2.setTitle("empty group with title"); michael@0: openMoveToGroupPopup(); michael@0: is(tvMenuPopup.childNodes.length, 4, "Validate group item count in move to group popup."); michael@0: hideMoveToGroupPopup(); michael@0: michael@0: // Clean michael@0: closeGroupItem(group1, function() { closeGroupItem(group2, finish); }); michael@0: } michael@0: michael@0: showTabView(createGroups); michael@0: } michael@0: