|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 let cw; |
|
6 |
|
7 let createGroupItem = function () { |
|
8 let bounds = new cw.Rect(20, 20, 150, 150); |
|
9 let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); |
|
10 |
|
11 cw.UI.setActive(groupItem); |
|
12 gBrowser.loadOneTab('about:blank', {inBackground: true}); |
|
13 |
|
14 return groupItem; |
|
15 } |
|
16 |
|
17 let synthesizeMiddleMouseDrag = function (tabContainer, width) { |
|
18 EventUtils.synthesizeMouseAtCenter(tabContainer, |
|
19 {type: 'mousedown', button: 1}, cw); |
|
20 let rect = tabContainer.getBoundingClientRect(); |
|
21 EventUtils.synthesizeMouse(tabContainer, rect.width / 2 + width, |
|
22 rect.height / 2, {type: 'mousemove', button: 1}, cw); |
|
23 EventUtils.synthesizeMouse(tabContainer, rect.width / 2 + width, |
|
24 rect.height / 2, {type: 'mouseup', button: 1}, cw); |
|
25 } |
|
26 |
|
27 let testDragAndDropWithMiddleMouseButton = function () { |
|
28 let groupItem = createGroupItem(); |
|
29 let tabItem = groupItem.getChild(0); |
|
30 let tabContainer = tabItem.container; |
|
31 let bounds = tabItem.getBounds(); |
|
32 |
|
33 // try to drag and move the mouse out of the tab |
|
34 synthesizeMiddleMouseDrag(tabContainer, 200); |
|
35 is(groupItem.getChild(0), tabItem, 'tabItem was not closed'); |
|
36 ok(bounds.equals(tabItem.getBounds()), 'bounds did not change'); |
|
37 |
|
38 // try to drag and let the mouse stay within tab bounds |
|
39 synthesizeMiddleMouseDrag(tabContainer, 10); |
|
40 ok(!groupItem.getChild(0), 'tabItem was closed'); |
|
41 |
|
42 hideTabView(finish); |
|
43 } |
|
44 |
|
45 waitForExplicitFinish(); |
|
46 |
|
47 showTabView(function () { |
|
48 cw = TabView.getContentWindow(); |
|
49 afterAllTabsLoaded(testDragAndDropWithMiddleMouseButton); |
|
50 }); |
|
51 } |