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 assertNumberOfGroupItems = function (num) { michael@0: let groupItems = cw.GroupItems.groupItems; michael@0: is(groupItems.length, num, "number of groupItems is " + num); michael@0: }; michael@0: michael@0: let dragTabOutOfGroup = function (groupItem) { michael@0: let tabItem = groupItem.getChild(0); michael@0: let target = tabItem.container; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); michael@0: EventUtils.synthesizeMouse(target, 400, 100, {type: "mousemove"}, cw); michael@0: EventUtils.synthesizeMouseAtCenter(target, {type: "mouseup"}, cw); michael@0: }; michael@0: michael@0: let testCreateGroup = function (callback) { michael@0: let content = cw.document.getElementById("content"); michael@0: michael@0: // drag to create a new group michael@0: EventUtils.synthesizeMouse(content, 400, 50, {type: "mousedown"}, cw); michael@0: EventUtils.synthesizeMouse(content, 500, 250, {type: "mousemove"}, cw); michael@0: EventUtils.synthesizeMouse(content, 500, 250, {type: "mouseup"}, cw); michael@0: michael@0: assertNumberOfGroupItems(2); michael@0: michael@0: // enter a title for the new group michael@0: EventUtils.synthesizeKey("t", {}, cw); michael@0: EventUtils.synthesizeKey("VK_RETURN", {}, cw); michael@0: michael@0: michael@0: let groupItem = cw.GroupItems.groupItems[1]; michael@0: is(groupItem.getTitle(), "t", "new groupItem's title is correct"); michael@0: michael@0: closeGroupItem(groupItem, callback); michael@0: }; michael@0: michael@0: let testDragOutOfGroup = function (callback) { michael@0: assertNumberOfGroupItems(1); michael@0: michael@0: let groupItem = cw.GroupItems.groupItems[0]; michael@0: dragTabOutOfGroup(groupItem); michael@0: assertNumberOfGroupItems(2); michael@0: michael@0: // enter a title for the new group michael@0: EventUtils.synthesizeKey("t", {}, cw); michael@0: EventUtils.synthesizeKey("VK_RETURN", {}, cw); michael@0: michael@0: groupItem = cw.GroupItems.groupItems[1]; michael@0: is(groupItem.getTitle(), "t", "new groupItem's title is correct"); michael@0: closeGroupItem(groupItem, callback); michael@0: }; michael@0: michael@0: let onLoad = function (win) { michael@0: registerCleanupFunction(function () win.close()); michael@0: michael@0: for (let i = 0; i < 2; i++) michael@0: win.gBrowser.addTab(); michael@0: }; michael@0: michael@0: let onShow = function (win) { michael@0: cw = win.TabView.getContentWindow(); michael@0: assertNumberOfGroupItems(1); michael@0: michael@0: let groupItem = cw.GroupItems.groupItems[0]; michael@0: groupItem.setSize(200, 600, true); michael@0: michael@0: waitForFocus(function () { michael@0: testCreateGroup(function () { michael@0: testDragOutOfGroup(finish); michael@0: }); michael@0: }, cw); michael@0: }; michael@0: michael@0: waitForExplicitFinish(); michael@0: newWindowWithTabView(onShow, onLoad); michael@0: }