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