1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug706430.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let state1 = { 1.8 + windows: [{ 1.9 + tabs: [{ 1.10 + entries: [{ url: "about:blank#1" }], 1.11 + hidden: true, 1.12 + extData: {"tabview-tab": '{"url":"about:blank#1","groupID":1,"bounds":{"left":120,"top":20,"width":20,"height":20}}'} 1.13 + },{ 1.14 + entries: [{ url: "about:blank#2" }], 1.15 + hidden: false, 1.16 + extData: {"tabview-tab": '{"url":"about:blank#2","groupID":2,"bounds":{"left":20,"top":20,"width":20,"height":20}}'}, 1.17 + }], 1.18 + selected: 2, 1.19 + extData: { 1.20 + "tabview-groups": '{"nextID":3,"activeGroupId":2, "totalNumber":2}', 1.21 + "tabview-group": 1.22 + '{"1":{"bounds":{"left":15,"top":5,"width":280,"height":232},"id":1},' + 1.23 + '"2":{"bounds":{"left":309,"top":5,"width":267,"height":226},"id":2}}' 1.24 + } 1.25 + }] 1.26 +}; 1.27 + 1.28 +let state2 = { 1.29 + windows: [{ 1.30 + tabs: [{entries: [{ url: "about:blank#1" }], hidden: true}, 1.31 + {entries: [{ url: "about:blank#2" }], hidden: false}], 1.32 + selected: 2 1.33 + }] 1.34 +}; 1.35 + 1.36 +let ss = Cc["@mozilla.org/browser/sessionstore;1"] 1.37 + .getService(Ci.nsISessionStore); 1.38 + 1.39 +function test() { 1.40 + waitForExplicitFinish(); 1.41 + 1.42 + newWindowWithState(state1, function (win) { 1.43 + registerCleanupFunction(function () win.close()); 1.44 + 1.45 + showTabView(function () { 1.46 + let cw = win.TabView.getContentWindow(); 1.47 + let [group1, group2] = cw.GroupItems.groupItems; 1.48 + let [tab1, tab2] = win.gBrowser.tabs; 1.49 + 1.50 + checkUrl(group1.getChild(0), "about:blank#1", "tab1 is in first group"); 1.51 + checkUrl(group2.getChild(0), "about:blank#2", "tab2 is in second group"); 1.52 + 1.53 + whenWindowStateReady(win, function () { 1.54 + let groups = cw.GroupItems.groupItems; 1.55 + is(groups.length, 1, "one groupItem"); 1.56 + is(groups[0].getChildren().length, 2, "single groupItem has two children"); 1.57 + 1.58 + finish(); 1.59 + }); 1.60 + 1.61 + ss.setWindowState(win, JSON.stringify(state2), true); 1.62 + }, win); 1.63 + }); 1.64 +} 1.65 + 1.66 +function checkUrl(aTabItem, aUrl, aMsg) { 1.67 + is(aTabItem.tab.linkedBrowser.currentURI.spec, aUrl, aMsg); 1.68 +}