browser/components/tabview/test/browser_tabview_bug641802.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_bug641802.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,65 @@
     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 +  let openMoveToGroupPopup = function () {
     1.9 +    let tab = gBrowser.selectedTab;
    1.10 +    var evt = new Event("");
    1.11 +    tab.dispatchEvent(evt);
    1.12 +    contextMenu.openPopup(tab, "end_after", 0, 0, true, false, evt);
    1.13 +    tvMenuPopup.openPopup(tvMenu, "end_after", 0, 0, true, false);
    1.14 +  }
    1.15 +
    1.16 +  let hideMoveToGroupPopup = function () {
    1.17 +    tvMenuPopup.hidePopup();
    1.18 +    contextMenu.hidePopup();
    1.19 +  }
    1.20 +
    1.21 +  let assertValidPrerequisites = function (visible) {
    1.22 +    let cw = TabView.getContentWindow();
    1.23 +    is(cw.GroupItems.groupItems.length, 1, "there is one groupItem");
    1.24 +    is(gBrowser.tabs.length, 1, "there is one tab");
    1.25 +    is(TabView.isVisible(), visible, "tabview is visible");
    1.26 +  }
    1.27 +
    1.28 +  let tvMenu = document.getElementById("context_tabViewMenu");
    1.29 +  let contextMenu = document.getElementById("tabContextMenu");
    1.30 +  let tvMenuPopup = document.getElementById("context_tabViewMenuPopup");
    1.31 +
    1.32 +  waitForExplicitFinish();
    1.33 +
    1.34 +  registerCleanupFunction(function () {
    1.35 +    hideMoveToGroupPopup();
    1.36 +    hideTabView();
    1.37 +
    1.38 +    let groupItems = TabView.getContentWindow().GroupItems.groupItems;
    1.39 +    if (groupItems.length > 1)
    1.40 +      closeGroupItem(groupItems[0]);
    1.41 +  });
    1.42 +
    1.43 +  showTabView(function () {
    1.44 +    assertValidPrerequisites(true);
    1.45 +
    1.46 +    hideTabView(function () {
    1.47 +      let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1);
    1.48 +      groupItem.setTitle("group2");
    1.49 +
    1.50 +      gBrowser.selectedTab = gBrowser.tabs[0];
    1.51 +
    1.52 +      executeSoon(function () {
    1.53 +        openMoveToGroupPopup();
    1.54 +        is(tvMenuPopup.firstChild.getAttribute("label"), "group2", "menuItem is present");
    1.55 +        hideMoveToGroupPopup();
    1.56 +
    1.57 +        closeGroupItem(groupItem, function () {
    1.58 +          openMoveToGroupPopup();
    1.59 +          is(tvMenuPopup.firstChild.tagName, "menuseparator", "menuItem is not present");
    1.60 +          hideMoveToGroupPopup();
    1.61 +
    1.62 +          assertValidPrerequisites(false);
    1.63 +          finish();
    1.64 +        });
    1.65 +      });
    1.66 +    });
    1.67 +  });
    1.68 +}

mercurial