michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let win; michael@0: let contentWindow; michael@0: let originalTab; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: newWindowWithTabView( michael@0: function() { michael@0: ok(win.TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: contentWindow = win.document.getElementById("tab-view").contentWindow; michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "There is one group"); michael@0: is(contentWindow.GroupItems.groupItems[0].getChildren().length, 1, michael@0: "The group has only one tab item"); michael@0: michael@0: // show the undo close group button michael@0: let group = contentWindow.GroupItems.groupItems[0]; michael@0: hideGroupItem(group, function () restore(group.id)); michael@0: }, michael@0: function(newWin) { michael@0: win = newWin; michael@0: originalTab = win.gBrowser.visibleTabs[0]; michael@0: win.gBrowser.addTab(); michael@0: win.gBrowser.pinTab(originalTab); michael@0: } michael@0: ); michael@0: } michael@0: michael@0: function restore(groupId) { michael@0: // window state ready michael@0: let handleSSWindowStateReady = function() { michael@0: win.removeEventListener("SSWindowStateReady", handleSSWindowStateReady, false); michael@0: michael@0: executeSoon(function() { michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "There is one group"); michael@0: michael@0: let group = contentWindow.GroupItems.groupItems[0]; michael@0: ok(!group.hidden, "The group is visible"); michael@0: is(group.getChildren().length, 2, "This group has two tab items"); michael@0: michael@0: // check the position of the group item and the tab items. michael@0: let tabItemOne = group.getChildren()[0]; michael@0: let tabItemTwo = group.getChildren()[1]; michael@0: michael@0: let groupBounds = group.getBounds(); michael@0: let tabItemOneBounds = tabItemOne.getBounds(); michael@0: let tabItemTwoBounds = tabItemTwo.getBounds(); michael@0: michael@0: ok(groupBounds.left < tabItemOneBounds.left && michael@0: (groupBounds.right) > (tabItemOneBounds.right) && michael@0: groupBounds.top < tabItemOneBounds.top && michael@0: (groupBounds.bottom) > (tabItemOneBounds.bottom), michael@0: "Tab item one is within the group"); michael@0: michael@0: ok(groupBounds.left < tabItemOneBounds.left && michael@0: (groupBounds.right) > (tabItemTwoBounds.right) && michael@0: groupBounds.top < tabItemOneBounds.top && michael@0: (groupBounds.bottom) > (tabItemTwoBounds.bottom), michael@0: "Tab item two is within the group"); michael@0: michael@0: win.close(); michael@0: finish(); michael@0: }); michael@0: } michael@0: win.addEventListener("SSWindowStateReady", handleSSWindowStateReady, false); michael@0: michael@0: // simulate restoring previous session (one group and two tab items) michael@0: const DUMMY_PAGE_URL = "http://example.com/"; michael@0: let newState = { michael@0: windows: [{ michael@0: tabs: [{ michael@0: entries: [{ url: DUMMY_PAGE_URL }], michael@0: index: 2, michael@0: hidden: false, michael@0: attributes: {}, michael@0: extData: { michael@0: "tabview-tab": michael@0: '{"bounds":{"left":208,"top":54,"width":205,"height":169},' + michael@0: '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":' + michael@0: groupId + ',"imageData":null,"title":null}' michael@0: }}, { michael@0: entries: [{ url: DUMMY_PAGE_URL }], michael@0: index: 1, michael@0: hidden: false, michael@0: attributes: {}, michael@0: extData: { michael@0: "tabview-tab": michael@0: '{"bounds":{"left":429,"top":54,"width":205,"height":169},' + michael@0: '"userSize":null,"url":"' + DUMMY_PAGE_URL + '","groupID":' + michael@0: groupId + ',"imageData":null,"title":null}' michael@0: } michael@0: }], michael@0: extData: { michael@0: "tabview-groups": '{"nextID":' + (groupId + 1) + ',"activeGroupId":' + groupId + '}', michael@0: "tabview-group": michael@0: '{"' + groupId + '":{"bounds":{"left":202,"top":30,"width":455,"height":249},' + michael@0: '"userSize":null,"locked":{},"title":"","id":' + groupId +'}}', michael@0: "tabview-ui": '{"pageBounds":{"left":0,"top":0,"width":788,"height":548}}' michael@0: }, sizemode:"normal" michael@0: }] michael@0: }; michael@0: let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); michael@0: ss.setWindowState(win, JSON.stringify(newState), true); michael@0: } michael@0: