summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_bug462673.js
blob: fb550cb2b5a65deeea715f4ea0ef1673f4e28c09 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
add_task(async function () {
  var win = openDialog(
    AppConstants.BROWSER_CHROME_URL,
    "_blank",
    "chrome,all,dialog=no"
  );
  await SimpleTest.promiseFocus(win);

  let tab = win.gBrowser.tabs[0];
  await promiseTabLoadEvent(
    tab,
    getRootDirectory(gTestPath) + "test_bug462673.html"
  );

  is(
    win.gBrowser.browsers.length,
    2,
    "test_bug462673.html has opened a second tab"
  );
  is(
    win.gBrowser.selectedTab,
    tab.nextElementSibling,
    "dependent tab is selected"
  );
  win.gBrowser.removeTab(tab);

  // Closing a tab will also close its parent chrome window, but async
  await BrowserTestUtils.domWindowClosed(win);
});

add_task(async function () {
  var win = openDialog(
    AppConstants.BROWSER_CHROME_URL,
    "_blank",
    "chrome,all,dialog=no"
  );
  await SimpleTest.promiseFocus(win);

  let tab = win.gBrowser.tabs[0];
  await promiseTabLoadEvent(
    tab,
    getRootDirectory(gTestPath) + "test_bug462673.html"
  );

  var newTab = BrowserTestUtils.addTab(win.gBrowser);
  var newBrowser = newTab.linkedBrowser;
  win.gBrowser.removeTab(tab);
  ok(!win.closed, "Window stays open");
  if (!win.closed) {
    is(win.gBrowser.tabs.length, 1, "Window has one tab");
    is(win.gBrowser.browsers.length, 1, "Window has one browser");
    is(win.gBrowser.selectedTab, newTab, "Remaining tab is selected");
    is(
      win.gBrowser.selectedBrowser,
      newBrowser,
      "Browser for remaining tab is selected"
    );
    is(
      win.gBrowser.tabbox.selectedPanel,
      newBrowser.parentNode.parentNode.parentNode,
      "Panel for remaining tab is selected"
    );
  }

  await promiseWindowClosed(win);
});