summaryrefslogtreecommitdiff
path: root/browser/base/content/test/browser_tabs_isActive.js
blob: 57d86e821f0839b42b1339ea1d5b001761b0fa5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

function test() {
  test_tab("about:blank");
  test_tab("about:license");
}

function test_tab(url) {
  let originalTab = gBrowser.selectedTab;
  let newTab = gBrowser.addTab(url, {skipAnimation: true});
  is(tabIsActive(newTab), false, "newly added " + url + " tab is not active");
  is(tabIsActive(originalTab), true, "original tab is active initially");

  gBrowser.selectedTab = newTab;
  is(tabIsActive(newTab), true, "newly added " + url + " tab is active after selection");
  is(tabIsActive(originalTab), false, "original tab is not active while unselected");

  gBrowser.selectedTab = originalTab;
  is(tabIsActive(newTab), false, "newly added " + url + " tab is not active after switch back");
  is(tabIsActive(originalTab), true, "original tab is active again after switch back");
  
  gBrowser.removeTab(newTab);
}

function tabIsActive(tab) {
  let browser = tab.linkedBrowser;
  return browser.docShell.isActive;
}