1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug649319.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + waitForExplicitFinish(); 1.9 + 1.10 + newWindowWithTabView(function (win) { 1.11 + registerCleanupFunction(function () win.close()); 1.12 + waitForFocus(function () testScenarios(win)); 1.13 + }); 1.14 +} 1.15 + 1.16 +function testScenarios(win) { 1.17 + let simulateDragDrop = function (target) { 1.18 + EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); 1.19 + EventUtils.synthesizeMouse(target, 40, 20, {type: "mousemove"}, cw); 1.20 + EventUtils.synthesizeMouse(target, 80, 20, {type: "mouseup"}, cw); 1.21 + } 1.22 + 1.23 + let dragOutOfGroup = function (target) { 1.24 + EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); 1.25 + EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw); 1.26 + EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw); 1.27 + } 1.28 + 1.29 + let dragIntoGroup = function (target) { 1.30 + EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); 1.31 + EventUtils.synthesizeMouse(target, -200, 5, {type: "mousemove"}, cw); 1.32 + EventUtils.synthesizeMouse(target, -200, 5, {type: "mouseup"}, cw); 1.33 + } 1.34 + 1.35 + let assertActiveOrphan = function (tabItem) { 1.36 + ok(!cw.GroupItems.getActiveGroupItem(), "no groupItem is active"); 1.37 + is(cw.UI.getActiveTab(), tabItem, "orphan tab is active"); 1.38 + is(cw.UI.getActiveOrphanTab(), tabItem, "orphan tab is active"); 1.39 + } 1.40 + 1.41 + let cw = win.TabView.getContentWindow(); 1.42 + let groupItem = cw.GroupItems.groupItems[0]; 1.43 + let groupItem2 = createGroupItemWithBlankTabs(win, 400, 300, 20, 4); 1.44 + 1.45 + // move group 1.46 + cw.UI.setActive(groupItem); 1.47 + simulateDragDrop(groupItem2.container); 1.48 + is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); 1.49 + is(cw.UI.getActiveTab(), groupItem2.getChild(0), "second groupItem's first tab is active"); 1.50 + 1.51 + // resize group 1.52 + cw.UI.setActive(groupItem); 1.53 + let tabItem = groupItem2.getChild(2); 1.54 + groupItem2.setActiveTab(tabItem); 1.55 + simulateDragDrop(groupItem2.$resizer[0]); 1.56 + is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); 1.57 + is(cw.UI.getActiveTab(), tabItem, "second groupItem's third tab is active"); 1.58 + 1.59 + // drag tab out of group 1.60 + tabItem = groupItem2.getChild(0); 1.61 + dragOutOfGroup(tabItem.container); 1.62 + is(cw.UI.getActiveTab(), tabItem, "the dragged tab is active"); 1.63 + 1.64 + // drag back into group 1.65 + dragIntoGroup(tabItem.container); 1.66 + cw.UI.setActive(groupItem); 1.67 + cw.UI.setActive(groupItem2); 1.68 + is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); 1.69 + 1.70 + // hide + unhide groupItem 1.71 + hideGroupItem(groupItem2, function () { 1.72 + is(cw.GroupItems.getActiveGroupItem(), groupItem, "first groupItem is active"); 1.73 + 1.74 + unhideGroupItem(groupItem2, function () { 1.75 + is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); 1.76 + is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); 1.77 + 1.78 + finish(); 1.79 + }); 1.80 + }); 1.81 +}