michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: let oldState = { michael@0: windows: [{ michael@0: tabs: [ michael@0: { entries: [{ url: "about:mozilla" }], hidden: true }, michael@0: { entries: [{ url: "about:blank" }], hidden: false } michael@0: ] michael@0: }] michael@0: }; michael@0: let pageData = { michael@0: url: "about:sessionrestore", michael@0: formdata: { id: { "sessionData": oldState } } michael@0: }; michael@0: let state = { windows: [{ tabs: [{ entries: [pageData] }] }] }; michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: newWindowWithState(state, function (win) { michael@0: registerCleanupFunction(function () win.close()); michael@0: michael@0: is(gBrowser.tabs.length, 1, "The total number of tabs should be 1"); michael@0: is(gBrowser.visibleTabs.length, 1, "The total number of visible tabs should be 1"); michael@0: michael@0: executeSoon(function () { michael@0: waitForFocus(function () { michael@0: middleClickTest(win); michael@0: finish(); michael@0: }, win); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function middleClickTest(win) { michael@0: let browser = win.gBrowser.selectedBrowser; michael@0: let tree = browser.contentDocument.getElementById("tabList"); michael@0: is(tree.view.rowCount, 3, "There should be three items"); michael@0: michael@0: let x = {}, y = {}, width = {}, height = {}; michael@0: michael@0: // click on the first tab item michael@0: tree.treeBoxObject.getCoordsForCellItem(1, tree.columns[1], "text", x, y, width, height); michael@0: EventUtils.synthesizeMouse(tree.body, x.value, y.value, { button: 1 }, michael@0: browser.contentWindow); michael@0: // click on the second tab item michael@0: tree.treeBoxObject.getCoordsForCellItem(2, tree.columns[1], "text", x, y, width, height); michael@0: EventUtils.synthesizeMouse(tree.body, x.value, y.value, { button: 1 }, michael@0: browser.contentWindow); michael@0: michael@0: is(win.gBrowser.tabs.length, 3, michael@0: "The total number of tabs should be 3 after restoring 2 tabs by middle click."); michael@0: is(win.gBrowser.visibleTabs.length, 3, michael@0: "The total number of visible tabs should be 3 after restoring 2 tabs by middle click"); michael@0: } michael@0: michael@0: function newWindowWithState(state, callback) { michael@0: let opts = "chrome,all,dialog=no,height=800,width=800"; michael@0: let win = window.openDialog(getBrowserURL(), "_blank", opts); michael@0: michael@0: win.addEventListener("load", function onLoad() { michael@0: win.removeEventListener("load", onLoad, false); michael@0: michael@0: let tab = win.gBrowser.selectedTab; michael@0: michael@0: // The form data will be restored before SSTabRestored, so we want to listen michael@0: // for that on the currently selected tab (it will be reused) michael@0: tab.addEventListener("SSTabRestored", function onRestored() { michael@0: tab.removeEventListener("SSTabRestored", onRestored, true); michael@0: callback(win); michael@0: }, true); michael@0: michael@0: executeSoon(function () { michael@0: ss.setWindowState(win, JSON.stringify(state), true); michael@0: }); michael@0: }, false); michael@0: }