1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug462673.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +var runs = [ 1.5 + function (win, tabbrowser, tab) { 1.6 + is(tabbrowser.browsers.length, 2, "test_bug462673.html has opened a second tab"); 1.7 + is(tabbrowser.selectedTab, tab.nextSibling, "dependent tab is selected"); 1.8 + tabbrowser.removeTab(tab); 1.9 + // Closing a tab will also close its parent chrome window, but async 1.10 + executeSoon(function() { 1.11 + ok(win.closed, "Window is closed"); 1.12 + testComplete(win); 1.13 + }); 1.14 + }, 1.15 + function (win, tabbrowser, tab) { 1.16 + var newTab = tabbrowser.addTab(); 1.17 + var newBrowser = newTab.linkedBrowser; 1.18 + tabbrowser.removeTab(tab); 1.19 + ok(!win.closed, "Window stays open"); 1.20 + if (!win.closed) { 1.21 + is(tabbrowser.tabContainer.childElementCount, 1, "Window has one tab"); 1.22 + is(tabbrowser.browsers.length, 1, "Window has one browser"); 1.23 + is(tabbrowser.selectedTab, newTab, "Remaining tab is selected"); 1.24 + is(tabbrowser.selectedBrowser, newBrowser, "Browser for remaining tab is selected"); 1.25 + is(tabbrowser.mTabBox.selectedPanel, newBrowser.parentNode.parentNode.parentNode.parentNode, "Panel for remaining tab is selected"); 1.26 + } 1.27 + testComplete(win); 1.28 + } 1.29 +]; 1.30 + 1.31 +function test() { 1.32 + waitForExplicitFinish(); 1.33 + runOneTest(); 1.34 +} 1.35 + 1.36 +function testComplete(win) { 1.37 + win.close(); 1.38 + if (runs.length) 1.39 + runOneTest(); 1.40 + else 1.41 + finish(); 1.42 +} 1.43 + 1.44 +function runOneTest() { 1.45 + var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no"); 1.46 + 1.47 + win.addEventListener("load", function () { 1.48 + win.removeEventListener("load", arguments.callee, false); 1.49 + 1.50 + var tab = win.gBrowser.tabContainer.firstChild; 1.51 + var browser = tab.linkedBrowser; 1.52 + 1.53 + browser.addEventListener("load", function () { 1.54 + browser.removeEventListener("load", arguments.callee, true); 1.55 + 1.56 + executeSoon(function () { 1.57 + runs.shift()(win, win.gBrowser, tab); 1.58 + }); 1.59 + }, true); 1.60 + 1.61 + var rootDir = getRootDirectory(gTestPath); 1.62 + browser.contentWindow.location = rootDir + "test_bug462673.html" 1.63 + }, false); 1.64 +}