diff --git a/browser/base/content/tabview/modules/AllTabs.jsm b/browser/base/content/tabview/modules/AllTabs.jsm index e1f36ccdf06..22ed7b2e813 100644 --- a/browser/base/content/tabview/modules/AllTabs.jsm +++ b/browser/base/content/tabview/modules/AllTabs.jsm @@ -57,7 +57,10 @@ let AllTabs = { get tabs() { // Get tabs from each browser window and flatten them into one array return Array.concat.apply(null, browserWindows.map(function(browserWindow) { - return Array.slice(browserWindow.gBrowser.tabs); + let removingTabs = browserWindow.gBrowser._removingTabs; + return Array.filter(browserWindow.gBrowser.tabs, function (tab) { + return removingTabs.indexOf(tab) == -1; + }); })); }, diff --git a/browser/base/content/test/tabview/Makefile.in b/browser/base/content/test/tabview/Makefile.in index 8626987df1f..06b8159500c 100644 --- a/browser/base/content/test/tabview/Makefile.in +++ b/browser/base/content/test/tabview/Makefile.in @@ -131,6 +131,7 @@ _BROWSER_FILES = \ browser_tabview_bug640765.js \ browser_tabview_bug641802.js \ browser_tabview_bug642793.js \ + browser_tabview_bug643392.js \ browser_tabview_bug644097.js \ browser_tabview_bug645653.js \ browser_tabview_bug648882.js \ diff --git a/browser/base/content/test/tabview/browser_tabview_bug643392.js b/browser/base/content/test/tabview/browser_tabview_bug643392.js new file mode 100644 index 00000000000..5980cf24fbe --- /dev/null +++ b/browser/base/content/test/tabview/browser_tabview_bug643392.js @@ -0,0 +1,56 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); + +let state = { + windows: [{ + tabs: [{ + entries: [{ url: "about:home" }], + hidden: true, + extData: {"tabview-tab": '{"url":"about:home","groupID":1,"bounds":{"left":20,"top":20,"width":20,"height":20}}'} + },{ + entries: [{ url: "about:home" }], + hidden: false, + extData: {"tabview-tab": '{"url":"about:home","groupID":2,"bounds":{"left":20,"top":20,"width":20,"height":20}}'}, + }], + selected: 2, + extData: { + "tabview-groups": '{"nextID":3,"activeGroupId":2}', + "tabview-group": + '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},"id":1},' + + '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},"id":2}}' + } + }] +}; + +function test() { + waitForExplicitFinish(); + + newWindowWithState(state, function (win) { + registerCleanupFunction(function () win.close()); + + is(win.gBrowser.tabs.length, 2, "two tabs"); + + let opts = {animate: true, byMouse: true}; + win.gBrowser.removeTab(win.gBrowser.visibleTabs[0], opts); + + let checkTabCount = function () { + if (win.gBrowser.tabs.length > 1) { + executeSoon(checkTabCount); + return; + } + + is(win.gBrowser.tabs.length, 1, "one tab"); + + showTabView(function () { + let cw = win.TabView.getContentWindow(); + is(cw.TabItems.items.length, 1, "one tabItem"); + + waitForFocus(finish); + }, win); + }; + + checkTabCount(); + }); +} diff --git a/browser/base/content/test/tabview/head.js b/browser/base/content/test/tabview/head.js index 83e0c1517de..c772791f54c 100644 --- a/browser/base/content/test/tabview/head.js +++ b/browser/base/content/test/tabview/head.js @@ -261,3 +261,33 @@ function unhideGroupItem(groupItem, callback) { }); groupItem._unhide(); } + +// ---------- +function whenWindowLoaded(win, callback) { + win.addEventListener("load", function onLoad() { + win.removeEventListener("load", onLoad, false); + executeSoon(callback); + }, false); +} + +// ---------- +function whenWindowStateReady(win, callback) { + win.addEventListener("SSWindowStateReady", function onReady() { + win.removeEventListener("SSWindowStateReady", onReady, false); + executeSoon(callback); + }, false); +} + +// ---------- +function newWindowWithState(state, callback) { + let opts = "chrome,all,dialog=no,height=800,width=800"; + let win = window.openDialog(getBrowserURL(), "_blank", opts); + + whenWindowLoaded(win, function () { + ss.setWindowState(win, JSON.stringify(state), true); + }); + + whenWindowStateReady(win, function () { + afterAllTabsLoaded(function () callback(win), win); + }); +}