browser/components/tabview/test/browser_tabview_bug641802.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function test() {
     5   let openMoveToGroupPopup = function () {
     6     let tab = gBrowser.selectedTab;
     7     var evt = new Event("");
     8     tab.dispatchEvent(evt);
     9     contextMenu.openPopup(tab, "end_after", 0, 0, true, false, evt);
    10     tvMenuPopup.openPopup(tvMenu, "end_after", 0, 0, true, false);
    11   }
    13   let hideMoveToGroupPopup = function () {
    14     tvMenuPopup.hidePopup();
    15     contextMenu.hidePopup();
    16   }
    18   let assertValidPrerequisites = function (visible) {
    19     let cw = TabView.getContentWindow();
    20     is(cw.GroupItems.groupItems.length, 1, "there is one groupItem");
    21     is(gBrowser.tabs.length, 1, "there is one tab");
    22     is(TabView.isVisible(), visible, "tabview is visible");
    23   }
    25   let tvMenu = document.getElementById("context_tabViewMenu");
    26   let contextMenu = document.getElementById("tabContextMenu");
    27   let tvMenuPopup = document.getElementById("context_tabViewMenuPopup");
    29   waitForExplicitFinish();
    31   registerCleanupFunction(function () {
    32     hideMoveToGroupPopup();
    33     hideTabView();
    35     let groupItems = TabView.getContentWindow().GroupItems.groupItems;
    36     if (groupItems.length > 1)
    37       closeGroupItem(groupItems[0]);
    38   });
    40   showTabView(function () {
    41     assertValidPrerequisites(true);
    43     hideTabView(function () {
    44       let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1);
    45       groupItem.setTitle("group2");
    47       gBrowser.selectedTab = gBrowser.tabs[0];
    49       executeSoon(function () {
    50         openMoveToGroupPopup();
    51         is(tvMenuPopup.firstChild.getAttribute("label"), "group2", "menuItem is present");
    52         hideMoveToGroupPopup();
    54         closeGroupItem(groupItem, function () {
    55           openMoveToGroupPopup();
    56           is(tvMenuPopup.firstChild.tagName, "menuseparator", "menuItem is not present");
    57           hideMoveToGroupPopup();
    59           assertValidPrerequisites(false);
    60           finish();
    61         });
    62       });
    63     });
    64   });
    65 }

mercurial