Bug 590563 - Manually restored tabs are not shown in the main browser view [r=paul, a=dietrich]

This commit is contained in:
Raymond Lee 2011-02-11 13:41:14 -05:00
parent e9548842cc
commit b4194883cc
3 changed files with 72 additions and 0 deletions

View File

@ -251,6 +251,8 @@ function restoreSingleTab(aIx, aShifted) {
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
var tabState = gStateObject.windows[item.parent.ix]
.tabs[aIx - gTreeData.indexOf(item.parent) - 1];
// ensure tab would be visible on the tabstrip.
tabState.hidden = false;
ss.setTabState(newTab, JSON.stringify(tabState));
// respect the preference as to whether to select the tab (the Shift key inverses)

View File

@ -125,6 +125,7 @@ _BROWSER_TEST_FILES = \
browser_586068-cascaded_restore.js \
browser_589246.js \
browser_590268.js \
browser_590563.js \
browser_597315.js \
browser_597315_index.html \
browser_597315_a.html \

View File

@ -0,0 +1,69 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Services.jsm");
let ss = Cc["@mozilla.org/browser/sessionstore;1"].
getService(Ci.nsISessionStore);
let stateBackup = ss.getBrowserState();
function test() {
waitForExplicitFinish();
let oldState = {
windows: [{
tabs: [
{ entries: [{ url: "about:robots" }], hidden: true },
{ entries: [{ url: "about:blank" }], hidden: false }
]
}]
};
let pageData = {
url: "about:sessionrestore",
formdata: { "#sessionData": "(" + JSON.stringify(oldState) + ")" }
};
let state = { windows: [{ tabs: [{ entries: [pageData] }] }] };
// The form data will be restored before SSTabRestored, so we want to listen
// for that on the currently selected tab (it will be reused)
gBrowser.selectedTab.addEventListener("SSTabRestored", onSSTabRestored, true);
ss.setBrowserState(JSON.stringify(state));
}
function onSSTabRestored(aEvent) {
gBrowser.selectedTab.removeEventListener("SSTabRestored", onSSTabRestored, true);
is(gBrowser.tabs.length, 1, "The total number of tabs should be 1");
is(gBrowser.visibleTabs.length, 1, "The total number of visible tabs should be 1");
executeSoon(middleClickTest);
}
function middleClickTest() {
let tree = gBrowser.selectedBrowser.contentDocument.getElementById("tabList");
is(tree.view.rowCount, 3, "There should be three items");
let x = {}, y = {}, width = {}, height = {};
// click on the first tab item
tree.treeBoxObject.getCoordsForCellItem(1, tree.columns[1], "text", x, y, width, height);
EventUtils.synthesizeMouse(tree.body, x.value, y.value, { button: 1 },
gBrowser.selectedBrowser.contentWindow);
// click on the second tab item
tree.treeBoxObject.getCoordsForCellItem(2, tree.columns[1], "text", x, y, width, height);
EventUtils.synthesizeMouse(tree.body, x.value, y.value, { button: 1 },
gBrowser.selectedBrowser.contentWindow);
is(gBrowser.tabs.length, 3,
"The total number of tabs should be 3 after restoring 2 tabs by middle click.");
is(gBrowser.visibleTabs.length, 3,
"The total number of visible tabs should be 3 after restoring 2 tabs by middle click");
cleanup();
}
function cleanup() {
ss.setBrowserState(stateBackup);
executeSoon(finish);
}