1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug654721.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let state = { 1.8 + windows: [{ 1.9 + tabs: [{ 1.10 + entries: [{ url: "about:mozilla" }], 1.11 + hidden: true, 1.12 + extData: {"tabview-tab": '{"url":"about:mozilla","groupID":1,"bounds":{"left":20,"top":20,"width":20,"height":20}}'} 1.13 + },{ 1.14 + entries: [{ url: "about:mozilla" }], 1.15 + hidden: false, 1.16 + // this is an existing orphan tab from a previous Fx version and we want 1.17 + // to make sure this gets transformed into a group 1.18 + extData: {"tabview-tab": '{"url":"about:mozilla","groupID":0,"bounds":{"left":300,"top":300,"width":200,"height":200}}'}, 1.19 + }], 1.20 + selected: 2, 1.21 + extData: { 1.22 + "tabview-groups": '{"nextID":3,"activeGroupId":1}', 1.23 + "tabview-group": 1.24 + '{"1":{"bounds":{"left":20,"top":20,"width":200,"height":200},"id":1}}' 1.25 + } 1.26 + }] 1.27 +}; 1.28 + 1.29 +function test() { 1.30 + waitForExplicitFinish(); 1.31 + 1.32 + newWindowWithState(state, function (win) { 1.33 + registerCleanupFunction(function () win.close()); 1.34 + 1.35 + showTabView(function () { 1.36 + let cw = win.TabView.getContentWindow(); 1.37 + let groupItems = cw.GroupItems.groupItems; 1.38 + is(groupItems.length, 2, "two groupItems"); 1.39 + 1.40 + let [group1, group2] = groupItems; 1.41 + 1.42 + let bounds1 = new cw.Rect(20, 20, 200, 200); 1.43 + ok(bounds1.equals(group1.getBounds()), "bounds for group1 are correct"); 1.44 + 1.45 + let bounds2 = new cw.Rect(300, 300, 200, 200); 1.46 + ok(bounds2.equals(group2.getBounds()), "bounds for group2 are correct"); 1.47 + 1.48 + cw.UI.setActive(group2); 1.49 + win.gBrowser.loadOneTab("about:blank", {inBackground: true}); 1.50 + 1.51 + let tabItem = group2.getChild(0); 1.52 + let target = tabItem.container; 1.53 + 1.54 + EventUtils.synthesizeMouse(target, 10, 10, {type: 'mousedown'}, cw); 1.55 + EventUtils.synthesizeMouse(target, 20, -200, {type: 'mousemove'}, cw); 1.56 + EventUtils.synthesizeMouse(target, 10, 10, {type: 'mouseup'}, cw); 1.57 + 1.58 + is(groupItems.length, 3, "three groupItems"); 1.59 + 1.60 + let latestGroup = groupItems[groupItems.length - 1]; 1.61 + is(tabItem, latestGroup.getChild(0), "dragged tab has its own groupItem"); 1.62 + 1.63 + finish(); 1.64 + }, win); 1.65 + }); 1.66 +}