summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_bug462673.js
blob: f5b090917fb4036d3979c14f468e4f494cad3a49 (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
add_task(function* () {
  var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
  yield SimpleTest.promiseFocus(win);

  let tab = win.gBrowser.tabContainer.firstChild;
  yield 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.nextSibling, "dependent tab is selected");
  win.gBrowser.removeTab(tab);

  // Closing a tab will also close its parent chrome window, but async
  yield promiseWindowWillBeClosed(win);
});

add_task(function* () {
  var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
  yield SimpleTest.promiseFocus(win);

  let tab = win.gBrowser.tabContainer.firstChild;
  yield promiseTabLoadEvent(tab, getRootDirectory(gTestPath) + "test_bug462673.html");

  var newTab = win.gBrowser.addTab();
  var newBrowser = newTab.linkedBrowser;
  win.gBrowser.removeTab(tab);
  ok(!win.closed, "Window stays open");
  if (!win.closed) {
    is(win.gBrowser.tabContainer.childElementCount, 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.mTabBox.selectedPanel, newBrowser.parentNode.parentNode.parentNode.parentNode, "Panel for remaining tab is selected");
  }

  yield promiseWindowClosed(win);
});