michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: let cw; michael@0: michael@0: let createGroupItem = function () { michael@0: let bounds = new cw.Rect(20, 20, 150, 150); michael@0: let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); michael@0: michael@0: cw.UI.setActive(groupItem); michael@0: gBrowser.loadOneTab('about:blank', {inBackground: true}); michael@0: michael@0: return groupItem; michael@0: } michael@0: michael@0: let synthesizeMiddleMouseDrag = function (tabContainer, width) { michael@0: EventUtils.synthesizeMouseAtCenter(tabContainer, michael@0: {type: 'mousedown', button: 1}, cw); michael@0: let rect = tabContainer.getBoundingClientRect(); michael@0: EventUtils.synthesizeMouse(tabContainer, rect.width / 2 + width, michael@0: rect.height / 2, {type: 'mousemove', button: 1}, cw); michael@0: EventUtils.synthesizeMouse(tabContainer, rect.width / 2 + width, michael@0: rect.height / 2, {type: 'mouseup', button: 1}, cw); michael@0: } michael@0: michael@0: let testDragAndDropWithMiddleMouseButton = function () { michael@0: let groupItem = createGroupItem(); michael@0: let tabItem = groupItem.getChild(0); michael@0: let tabContainer = tabItem.container; michael@0: let bounds = tabItem.getBounds(); michael@0: michael@0: // try to drag and move the mouse out of the tab michael@0: synthesizeMiddleMouseDrag(tabContainer, 200); michael@0: is(groupItem.getChild(0), tabItem, 'tabItem was not closed'); michael@0: ok(bounds.equals(tabItem.getBounds()), 'bounds did not change'); michael@0: michael@0: // try to drag and let the mouse stay within tab bounds michael@0: synthesizeMiddleMouseDrag(tabContainer, 10); michael@0: ok(!groupItem.getChild(0), 'tabItem was closed'); michael@0: michael@0: hideTabView(finish); michael@0: } michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: showTabView(function () { michael@0: cw = TabView.getContentWindow(); michael@0: afterAllTabsLoaded(testDragAndDropWithMiddleMouseButton); michael@0: }); michael@0: }