browser/components/tabview/test/browser_tabview_bug766597.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/tabview/test/browser_tabview_bug766597.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function test() {
     1.8 +  waitForExplicitFinish();
     1.9 +
    1.10 +  let tContextMenu = document.getElementById("tabContextMenu");
    1.11 +  let tvMenuPopup = document.getElementById("context_tabViewMenuPopup");
    1.12 +  let group1;
    1.13 +  let group2;
    1.14 +
    1.15 +  function openMoveToGroupPopup() {
    1.16 +    let tab = gBrowser.selectedTab;
    1.17 +    let tvMenu = document.getElementById("context_tabViewMenu");
    1.18 +    let tvMenuPopup = document.getElementById("context_tabViewMenuPopup");
    1.19 +    let tvEvent = new Event("");
    1.20 +
    1.21 +    tab.dispatchEvent(tvEvent);
    1.22 +    tContextMenu.openPopup(tab, "end_after", 0, 0, true, false, tvEvent);
    1.23 +    tvMenuPopup.openPopup(tvMenu, "end_after", 0, 0, true, false);
    1.24 +  }
    1.25 +
    1.26 +  function hideMoveToGroupPopup() {
    1.27 +    tvMenuPopup.hidePopup();
    1.28 +    tContextMenu.hidePopup();
    1.29 +  }
    1.30 +
    1.31 +  function createGroups() {
    1.32 +    let cw = TabView.getContentWindow();
    1.33 +
    1.34 +    group1 = createGroupItemWithTabs(window, 200, 200, 20, ["about:blank"]);
    1.35 +    group1.setTitle("group with items and title");
    1.36 +    group2 = createEmptyGroupItem(cw, 200, 200, 20);
    1.37 +    cw.UI.setActive(cw.GroupItems.groupItems[0]);
    1.38 +
    1.39 +    // Check the group count.
    1.40 +    is(cw.GroupItems.groupItems.length, 3, "Validate group count in tab view.");
    1.41 +
    1.42 +    hideTabView(checkGroupMenuItems);
    1.43 +  }
    1.44 +
    1.45 +  // The group count includes the separator and the 'new group' menu item.
    1.46 +  function checkGroupMenuItems() {
    1.47 +    // First test with an empty untitled group.
    1.48 +    openMoveToGroupPopup();
    1.49 +    is(tvMenuPopup.childNodes.length, 3, "Validate group item count in move to group popup.");
    1.50 +    hideMoveToGroupPopup();
    1.51 +
    1.52 +    // Then test with an empty but titled group.
    1.53 +    group2.setTitle("empty group with title");
    1.54 +    openMoveToGroupPopup();
    1.55 +    is(tvMenuPopup.childNodes.length, 4, "Validate group item count in move to group popup.");
    1.56 +    hideMoveToGroupPopup();
    1.57 +
    1.58 +    // Clean 
    1.59 +    closeGroupItem(group1, function() { closeGroupItem(group2, finish); });
    1.60 +  }
    1.61 +
    1.62 +  showTabView(createGroups);
    1.63 +}
    1.64 +

mercurial