|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let contentWindow; |
|
5 let groupItem; |
|
6 let groupItemId; |
|
7 |
|
8 function test() { |
|
9 waitForExplicitFinish(); |
|
10 |
|
11 registerCleanupFunction(function() { |
|
12 contentWindow.gPrefBranch.clearUserPref("animate_zoom"); |
|
13 let createdGroupItem = contentWindow.GroupItems.groupItem(groupItemId) |
|
14 if (createdGroupItem) |
|
15 closeGroupItem(createdGroupItem); |
|
16 hideTabView(); |
|
17 }); |
|
18 |
|
19 showTabView(function() { |
|
20 contentWindow = TabView.getContentWindow(); |
|
21 groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200); |
|
22 groupItemId = groupItem.id; |
|
23 testMouseClickOnEmptyGroupItem(); |
|
24 }); |
|
25 } |
|
26 |
|
27 function testMouseClickOnEmptyGroupItem() { |
|
28 whenTabViewIsHidden(function() { |
|
29 is(groupItem.getChildren().length, 1, "The group item contains one tab item now"); |
|
30 showTabView(testDraggingWithinGroupItem); |
|
31 }); |
|
32 is(groupItem.getChildren().length, 0, "The group item doesn't contain any tab items"); |
|
33 EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow); |
|
34 EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow); |
|
35 } |
|
36 |
|
37 function testDraggingWithinGroupItem() { |
|
38 let target = groupItem.container; |
|
39 contentWindow.gPrefBranch.setBoolPref("animate_zoom", false); |
|
40 |
|
41 // stimulate drag and drop |
|
42 EventUtils.sendMouseEvent( {type: "mousedown" }, target, contentWindow); |
|
43 EventUtils.synthesizeMouse(target, 10, 10, { type: "mousemove" }, contentWindow); |
|
44 ok(groupItem.isDragging, "The group item is being dragged") |
|
45 |
|
46 EventUtils.sendMouseEvent({ type: "mouseup" }, target, contentWindow); |
|
47 ok(!groupItem.isDragging, "The dragging is competely"); |
|
48 |
|
49 executeSoon(function() { |
|
50 ok(TabView.isVisible(), "The tab view is still visible after dragging"); |
|
51 contentWindow.gPrefBranch.clearUserPref("animate_zoom"); |
|
52 |
|
53 testMouseClickOnGroupItem(); |
|
54 }); |
|
55 } |
|
56 |
|
57 function testMouseClickOnGroupItem() { |
|
58 whenTabViewIsHidden(function() { |
|
59 is(groupItem.getChildren().length, 1, "The group item still contains one tab item"); |
|
60 |
|
61 closeGroupItem(groupItem, function() { |
|
62 hideTabView(finish); |
|
63 }); |
|
64 }); |
|
65 EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow); |
|
66 EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow); |
|
67 } |
|
68 |