browser/base/content/test/general/browser_tabs_isActive.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_tabs_isActive.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,29 @@
     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 +  test_tab("about:blank");
     1.9 +  test_tab("about:license");
    1.10 +}
    1.11 +
    1.12 +function test_tab(url) {
    1.13 +  let originalTab = gBrowser.selectedTab;
    1.14 +  let newTab = gBrowser.addTab(url, {skipAnimation: true});
    1.15 +  is(tabIsActive(newTab), false, "newly added " + url + " tab is not active");
    1.16 +  is(tabIsActive(originalTab), true, "original tab is active initially");
    1.17 +
    1.18 +  gBrowser.selectedTab = newTab;
    1.19 +  is(tabIsActive(newTab), true, "newly added " + url + " tab is active after selection");
    1.20 +  is(tabIsActive(originalTab), false, "original tab is not active while unselected");
    1.21 +
    1.22 +  gBrowser.selectedTab = originalTab;
    1.23 +  is(tabIsActive(newTab), false, "newly added " + url + " tab is not active after switch back");
    1.24 +  is(tabIsActive(originalTab), true, "original tab is active again after switch back");
    1.25 +  
    1.26 +  gBrowser.removeTab(newTab);
    1.27 +}
    1.28 +
    1.29 +function tabIsActive(tab) {
    1.30 +  let browser = tab.linkedBrowser;
    1.31 +  return browser.docShell.isActive;
    1.32 +}

mercurial