browser/base/content/test/general/browser_bug533232.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_bug533232.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,36 @@
     1.4 +function test() {
     1.5 +  var tab1 = gBrowser.selectedTab;
     1.6 +  var tab2 = gBrowser.addTab();
     1.7 +  var childTab1;
     1.8 +  var childTab2;
     1.9 +
    1.10 +  childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
    1.11 +  gBrowser.selectedTab = childTab1;
    1.12 +  gBrowser.removeCurrentTab();
    1.13 +  is(idx(gBrowser.selectedTab), idx(tab1),
    1.14 +     "closing a tab next to its parent selects the parent");
    1.15 +
    1.16 +  childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
    1.17 +  gBrowser.selectedTab = tab2;
    1.18 +  gBrowser.selectedTab = childTab1;
    1.19 +  gBrowser.removeCurrentTab();
    1.20 +  is(idx(gBrowser.selectedTab), idx(tab2),
    1.21 +     "closing a tab next to its parent doesn't select the parent if another tab had been selected ad interim");
    1.22 +
    1.23 +  gBrowser.selectedTab = tab1;
    1.24 +  childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
    1.25 +  childTab2 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
    1.26 +  gBrowser.selectedTab = childTab1;
    1.27 +  gBrowser.removeCurrentTab();
    1.28 +  is(idx(gBrowser.selectedTab), idx(childTab2),
    1.29 +     "closing a tab next to its parent selects the next tab with the same parent");
    1.30 +  gBrowser.removeCurrentTab();
    1.31 +  is(idx(gBrowser.selectedTab), idx(tab2),
    1.32 +     "closing the last tab in a set of child tabs doesn't go back to the parent");
    1.33 +
    1.34 +  gBrowser.removeTab(tab2);
    1.35 +}
    1.36 +
    1.37 +function idx(tab) {
    1.38 +  return Array.indexOf(gBrowser.tabs, tab);
    1.39 +}

mercurial