summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_tabs_owner.js
blob: 300d783baa6e5bf2a1d48351b61c3cabaea3e2c1 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Whitelisting this test.
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
//
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: gBrowser._finalizeTabSwitch is not a function");

//
// Whitelisting this test.
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
//
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: gBrowser._finalizeTabSwitch is not a function");

function test() {
  gBrowser.addTab();
  gBrowser.addTab();
  gBrowser.addTab();

  var tabs = gBrowser.tabs;
  var owner;

  is(tabs.length, 4, "4 tabs are open");

  owner = gBrowser.selectedTab = tabs[2];
  BrowserOpenTab();
  is(gBrowser.selectedTab, tabs[4], "newly opened tab is selected");
  gBrowser.removeCurrentTab();
  is(gBrowser.selectedTab, owner, "owner is selected");

  owner = gBrowser.selectedTab;
  BrowserOpenTab();
  gBrowser.selectedTab = tabs[1];
  gBrowser.selectedTab = tabs[4];
  gBrowser.removeCurrentTab();
  isnot(gBrowser.selectedTab, owner, "selecting a different tab clears the owner relation");

  owner = gBrowser.selectedTab;
  BrowserOpenTab();
  gBrowser.moveTabTo(gBrowser.selectedTab, 0);
  gBrowser.removeCurrentTab();
  is(gBrowser.selectedTab, owner, "owner relatitionship persists when tab is moved");

  while (tabs.length > 1)
    gBrowser.removeCurrentTab();
}