browser/base/content/test/general/browser_bug462673.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d78150d85b04
1 var runs = [
2 function (win, tabbrowser, tab) {
3 is(tabbrowser.browsers.length, 2, "test_bug462673.html has opened a second tab");
4 is(tabbrowser.selectedTab, tab.nextSibling, "dependent tab is selected");
5 tabbrowser.removeTab(tab);
6 // Closing a tab will also close its parent chrome window, but async
7 executeSoon(function() {
8 ok(win.closed, "Window is closed");
9 testComplete(win);
10 });
11 },
12 function (win, tabbrowser, tab) {
13 var newTab = tabbrowser.addTab();
14 var newBrowser = newTab.linkedBrowser;
15 tabbrowser.removeTab(tab);
16 ok(!win.closed, "Window stays open");
17 if (!win.closed) {
18 is(tabbrowser.tabContainer.childElementCount, 1, "Window has one tab");
19 is(tabbrowser.browsers.length, 1, "Window has one browser");
20 is(tabbrowser.selectedTab, newTab, "Remaining tab is selected");
21 is(tabbrowser.selectedBrowser, newBrowser, "Browser for remaining tab is selected");
22 is(tabbrowser.mTabBox.selectedPanel, newBrowser.parentNode.parentNode.parentNode.parentNode, "Panel for remaining tab is selected");
23 }
24 testComplete(win);
25 }
26 ];
27
28 function test() {
29 waitForExplicitFinish();
30 runOneTest();
31 }
32
33 function testComplete(win) {
34 win.close();
35 if (runs.length)
36 runOneTest();
37 else
38 finish();
39 }
40
41 function runOneTest() {
42 var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no");
43
44 win.addEventListener("load", function () {
45 win.removeEventListener("load", arguments.callee, false);
46
47 var tab = win.gBrowser.tabContainer.firstChild;
48 var browser = tab.linkedBrowser;
49
50 browser.addEventListener("load", function () {
51 browser.removeEventListener("load", arguments.callee, true);
52
53 executeSoon(function () {
54 runs.shift()(win, win.gBrowser, tab);
55 });
56 }, true);
57
58 var rootDir = getRootDirectory(gTestPath);
59 browser.contentWindow.location = rootDir + "test_bug462673.html"
60 }, false);
61 }

mercurial