michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let state1 = { michael@0: windows: [{ michael@0: tabs: [{ michael@0: entries: [{ url: "about:blank#1" }], michael@0: hidden: true, michael@0: extData: {"tabview-tab": '{"url":"about:blank#1","groupID":1,"bounds":{"left":120,"top":20,"width":20,"height":20}}'} michael@0: },{ michael@0: entries: [{ url: "about:blank#2" }], michael@0: hidden: false, michael@0: extData: {"tabview-tab": '{"url":"about:blank#2","groupID":2,"bounds":{"left":20,"top":20,"width":20,"height":20}}'}, michael@0: }], michael@0: selected: 2, michael@0: extData: { michael@0: "tabview-groups": '{"nextID":3,"activeGroupId":2, "totalNumber":2}', michael@0: "tabview-group": michael@0: '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},"id":1},' + michael@0: '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},"id":2}}' michael@0: } michael@0: }] michael@0: }; michael@0: michael@0: let state2 = { michael@0: windows: [{ michael@0: tabs: [{entries: [{ url: "about:blank#1" }], hidden: true}, michael@0: {entries: [{ url: "about:blank#2" }], hidden: false}], michael@0: selected: 2 michael@0: }] michael@0: }; michael@0: michael@0: let ss = Cc["@mozilla.org/browser/sessionstore;1"] michael@0: .getService(Ci.nsISessionStore); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: newWindowWithState(state1, function (win) { michael@0: registerCleanupFunction(function () win.close()); michael@0: michael@0: showTabView(function () { michael@0: let cw = win.TabView.getContentWindow(); michael@0: let [group1, group2] = cw.GroupItems.groupItems; michael@0: let [tab1, tab2] = win.gBrowser.tabs; michael@0: michael@0: checkUrl(group1.getChild(0), "about:blank#1", "tab1 is in first group"); michael@0: checkUrl(group2.getChild(0), "about:blank#2", "tab2 is in second group"); michael@0: michael@0: whenWindowStateReady(win, function () { michael@0: let groups = cw.GroupItems.groupItems; michael@0: is(groups.length, 1, "one groupItem"); michael@0: is(groups[0].getChildren().length, 2, "single groupItem has two children"); michael@0: michael@0: finish(); michael@0: }); michael@0: michael@0: ss.setWindowState(win, JSON.stringify(state2), true); michael@0: }, win); michael@0: }); michael@0: } michael@0: michael@0: function checkUrl(aTabItem, aUrl, aMsg) { michael@0: is(aTabItem.tab.linkedBrowser.currentURI.spec, aUrl, aMsg); michael@0: }