Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 function test() {
5 let cw;
7 let createGroupItem = function () {
8 let bounds = new cw.Rect(20, 20, 150, 150);
9 let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true});
11 cw.UI.setActive(groupItem);
12 gBrowser.loadOneTab('about:blank', {inBackground: true});
14 return groupItem;
15 }
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 }
27 let testDragAndDropWithMiddleMouseButton = function () {
28 let groupItem = createGroupItem();
29 let tabItem = groupItem.getChild(0);
30 let tabContainer = tabItem.container;
31 let bounds = tabItem.getBounds();
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');
38 // try to drag and let the mouse stay within tab bounds
39 synthesizeMiddleMouseDrag(tabContainer, 10);
40 ok(!groupItem.getChild(0), 'tabItem was closed');
42 hideTabView(finish);
43 }
45 waitForExplicitFinish();
47 showTabView(function () {
48 cw = TabView.getContentWindow();
49 afterAllTabsLoaded(testDragAndDropWithMiddleMouseButton);
50 });
51 }