michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let state = { michael@0: windows: [{ michael@0: tabs: [{ michael@0: entries: [{ url: "about:mozilla" }], michael@0: hidden: true, michael@0: extData: {"tabview-tab": '{"url":"about:mozilla","groupID":1,"bounds":{"left":20,"top":20,"width":20,"height":20}}'} michael@0: },{ michael@0: entries: [{ url: "about:mozilla" }], michael@0: hidden: false, michael@0: // this is an existing orphan tab from a previous Fx version and we want michael@0: // to make sure this gets transformed into a group michael@0: extData: {"tabview-tab": '{"url":"about:mozilla","groupID":0,"bounds":{"left":300,"top":300,"width":200,"height":200}}'}, michael@0: }], michael@0: selected: 2, michael@0: extData: { michael@0: "tabview-groups": '{"nextID":3,"activeGroupId":1}', michael@0: "tabview-group": michael@0: '{"1":{"bounds":{"left":20,"top":20,"width":200,"height":200},"id":1}}' michael@0: } michael@0: }] michael@0: }; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: newWindowWithState(state, function (win) { michael@0: registerCleanupFunction(function () win.close()); michael@0: michael@0: showTabView(function () { michael@0: let cw = win.TabView.getContentWindow(); michael@0: let groupItems = cw.GroupItems.groupItems; michael@0: is(groupItems.length, 2, "two groupItems"); michael@0: michael@0: let [group1, group2] = groupItems; michael@0: michael@0: let bounds1 = new cw.Rect(20, 20, 200, 200); michael@0: ok(bounds1.equals(group1.getBounds()), "bounds for group1 are correct"); michael@0: michael@0: let bounds2 = new cw.Rect(300, 300, 200, 200); michael@0: ok(bounds2.equals(group2.getBounds()), "bounds for group2 are correct"); michael@0: michael@0: cw.UI.setActive(group2); michael@0: win.gBrowser.loadOneTab("about:blank", {inBackground: true}); michael@0: michael@0: let tabItem = group2.getChild(0); michael@0: let target = tabItem.container; michael@0: michael@0: EventUtils.synthesizeMouse(target, 10, 10, {type: 'mousedown'}, cw); michael@0: EventUtils.synthesizeMouse(target, 20, -200, {type: 'mousemove'}, cw); michael@0: EventUtils.synthesizeMouse(target, 10, 10, {type: 'mouseup'}, cw); michael@0: michael@0: is(groupItems.length, 3, "three groupItems"); michael@0: michael@0: let latestGroup = groupItems[groupItems.length - 1]; michael@0: is(tabItem, latestGroup.getChild(0), "dragged tab has its own groupItem"); michael@0: michael@0: finish(); michael@0: }, win); michael@0: }); michael@0: }