browser/base/content/test/general/browser_hide_removing.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/browser_hide_removing.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +// Bug 587922: tabs don't get removed if they're hidden
     1.9 +
    1.10 +function test() {
    1.11 +  waitForExplicitFinish();
    1.12 +
    1.13 +  // Add a tab that will get removed and hidden
    1.14 +  let testTab = gBrowser.addTab("about:blank", {skipAnimation: true});
    1.15 +  is(gBrowser.visibleTabs.length, 2, "just added a tab, so 2 tabs");
    1.16 +  gBrowser.selectedTab = testTab;
    1.17 +
    1.18 +  let numVisBeforeHide, numVisAfterHide;
    1.19 +  gBrowser.tabContainer.addEventListener("TabSelect", function() {
    1.20 +    gBrowser.tabContainer.removeEventListener("TabSelect", arguments.callee, false);
    1.21 +
    1.22 +    // While the next tab is being selected, hide the removing tab
    1.23 +    numVisBeforeHide = gBrowser.visibleTabs.length;
    1.24 +    gBrowser.hideTab(testTab);
    1.25 +    numVisAfterHide = gBrowser.visibleTabs.length;
    1.26 +  }, false);
    1.27 +  gBrowser.removeTab(testTab, {animate: true});
    1.28 +
    1.29 +  // Make sure the tab gets removed at the end of the animation by polling
    1.30 +  (function checkRemoved() setTimeout(function() {
    1.31 +    if (gBrowser.tabs.length != 1)
    1.32 +      return checkRemoved();
    1.33 +
    1.34 +    is(numVisBeforeHide, 1, "animated remove has in 1 tab left");
    1.35 +    is(numVisAfterHide, 1, "hiding a removing tab is also has 1 tab");
    1.36 +    finish();
    1.37 +  }, 50))();
    1.38 +}

mercurial