|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let state = { |
|
5 windows: [{ |
|
6 tabs: [{ |
|
7 entries: [{ url: "about:mozilla" }], |
|
8 hidden: true, |
|
9 extData: {"tabview-tab": '{"url":"about:mozilla","groupID":1,"bounds":{"left":20,"top":20,"width":20,"height":20}}'} |
|
10 },{ |
|
11 entries: [{ url: "about:mozilla" }], |
|
12 hidden: false, |
|
13 // this is an existing orphan tab from a previous Fx version and we want |
|
14 // to make sure this gets transformed into a group |
|
15 extData: {"tabview-tab": '{"url":"about:mozilla","groupID":0,"bounds":{"left":300,"top":300,"width":200,"height":200}}'}, |
|
16 }], |
|
17 selected: 2, |
|
18 extData: { |
|
19 "tabview-groups": '{"nextID":3,"activeGroupId":1}', |
|
20 "tabview-group": |
|
21 '{"1":{"bounds":{"left":20,"top":20,"width":200,"height":200},"id":1}}' |
|
22 } |
|
23 }] |
|
24 }; |
|
25 |
|
26 function test() { |
|
27 waitForExplicitFinish(); |
|
28 |
|
29 newWindowWithState(state, function (win) { |
|
30 registerCleanupFunction(function () win.close()); |
|
31 |
|
32 showTabView(function () { |
|
33 let cw = win.TabView.getContentWindow(); |
|
34 let groupItems = cw.GroupItems.groupItems; |
|
35 is(groupItems.length, 2, "two groupItems"); |
|
36 |
|
37 let [group1, group2] = groupItems; |
|
38 |
|
39 let bounds1 = new cw.Rect(20, 20, 200, 200); |
|
40 ok(bounds1.equals(group1.getBounds()), "bounds for group1 are correct"); |
|
41 |
|
42 let bounds2 = new cw.Rect(300, 300, 200, 200); |
|
43 ok(bounds2.equals(group2.getBounds()), "bounds for group2 are correct"); |
|
44 |
|
45 cw.UI.setActive(group2); |
|
46 win.gBrowser.loadOneTab("about:blank", {inBackground: true}); |
|
47 |
|
48 let tabItem = group2.getChild(0); |
|
49 let target = tabItem.container; |
|
50 |
|
51 EventUtils.synthesizeMouse(target, 10, 10, {type: 'mousedown'}, cw); |
|
52 EventUtils.synthesizeMouse(target, 20, -200, {type: 'mousemove'}, cw); |
|
53 EventUtils.synthesizeMouse(target, 10, 10, {type: 'mouseup'}, cw); |
|
54 |
|
55 is(groupItems.length, 3, "three groupItems"); |
|
56 |
|
57 let latestGroup = groupItems[groupItems.length - 1]; |
|
58 is(tabItem, latestGroup.getChild(0), "dragged tab has its own groupItem"); |
|
59 |
|
60 finish(); |
|
61 }, win); |
|
62 }); |
|
63 } |