michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let contentWindow; michael@0: let groupItem; michael@0: let groupItemId; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: registerCleanupFunction(function() { michael@0: contentWindow.gPrefBranch.clearUserPref("animate_zoom"); michael@0: let createdGroupItem = contentWindow.GroupItems.groupItem(groupItemId) michael@0: if (createdGroupItem) michael@0: closeGroupItem(createdGroupItem); michael@0: hideTabView(); michael@0: }); michael@0: michael@0: showTabView(function() { michael@0: contentWindow = TabView.getContentWindow(); michael@0: groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200); michael@0: groupItemId = groupItem.id; michael@0: testMouseClickOnEmptyGroupItem(); michael@0: }); michael@0: } michael@0: michael@0: function testMouseClickOnEmptyGroupItem() { michael@0: whenTabViewIsHidden(function() { michael@0: is(groupItem.getChildren().length, 1, "The group item contains one tab item now"); michael@0: showTabView(testDraggingWithinGroupItem); michael@0: }); michael@0: is(groupItem.getChildren().length, 0, "The group item doesn't contain any tab items"); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow); michael@0: EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow); michael@0: } michael@0: michael@0: function testDraggingWithinGroupItem() { michael@0: let target = groupItem.container; michael@0: contentWindow.gPrefBranch.setBoolPref("animate_zoom", false); michael@0: michael@0: // stimulate drag and drop michael@0: EventUtils.sendMouseEvent( {type: "mousedown" }, target, contentWindow); michael@0: EventUtils.synthesizeMouse(target, 10, 10, { type: "mousemove" }, contentWindow); michael@0: ok(groupItem.isDragging, "The group item is being dragged") michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mouseup" }, target, contentWindow); michael@0: ok(!groupItem.isDragging, "The dragging is competely"); michael@0: michael@0: executeSoon(function() { michael@0: ok(TabView.isVisible(), "The tab view is still visible after dragging"); michael@0: contentWindow.gPrefBranch.clearUserPref("animate_zoom"); michael@0: michael@0: testMouseClickOnGroupItem(); michael@0: }); michael@0: } michael@0: michael@0: function testMouseClickOnGroupItem() { michael@0: whenTabViewIsHidden(function() { michael@0: is(groupItem.getChildren().length, 1, "The group item still contains one tab item"); michael@0: michael@0: closeGroupItem(groupItem, function() { michael@0: hideTabView(finish); michael@0: }); michael@0: }); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow); michael@0: EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow); michael@0: } michael@0: