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 | waitForExplicitFinish(); |
michael@0 | 6 | |
michael@0 | 7 | newWindowWithTabView(function (win) { |
michael@0 | 8 | registerCleanupFunction(function () win.close()); |
michael@0 | 9 | waitForFocus(function () testScenarios(win)); |
michael@0 | 10 | }); |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | function testScenarios(win) { |
michael@0 | 14 | let simulateDragDrop = function (target) { |
michael@0 | 15 | EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
michael@0 | 16 | EventUtils.synthesizeMouse(target, 40, 20, {type: "mousemove"}, cw); |
michael@0 | 17 | EventUtils.synthesizeMouse(target, 80, 20, {type: "mouseup"}, cw); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | let dragOutOfGroup = function (target) { |
michael@0 | 21 | EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
michael@0 | 22 | EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw); |
michael@0 | 23 | EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | let dragIntoGroup = function (target) { |
michael@0 | 27 | EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
michael@0 | 28 | EventUtils.synthesizeMouse(target, -200, 5, {type: "mousemove"}, cw); |
michael@0 | 29 | EventUtils.synthesizeMouse(target, -200, 5, {type: "mouseup"}, cw); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | let assertActiveOrphan = function (tabItem) { |
michael@0 | 33 | ok(!cw.GroupItems.getActiveGroupItem(), "no groupItem is active"); |
michael@0 | 34 | is(cw.UI.getActiveTab(), tabItem, "orphan tab is active"); |
michael@0 | 35 | is(cw.UI.getActiveOrphanTab(), tabItem, "orphan tab is active"); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | let cw = win.TabView.getContentWindow(); |
michael@0 | 39 | let groupItem = cw.GroupItems.groupItems[0]; |
michael@0 | 40 | let groupItem2 = createGroupItemWithBlankTabs(win, 400, 300, 20, 4); |
michael@0 | 41 | |
michael@0 | 42 | // move group |
michael@0 | 43 | cw.UI.setActive(groupItem); |
michael@0 | 44 | simulateDragDrop(groupItem2.container); |
michael@0 | 45 | is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); |
michael@0 | 46 | is(cw.UI.getActiveTab(), groupItem2.getChild(0), "second groupItem's first tab is active"); |
michael@0 | 47 | |
michael@0 | 48 | // resize group |
michael@0 | 49 | cw.UI.setActive(groupItem); |
michael@0 | 50 | let tabItem = groupItem2.getChild(2); |
michael@0 | 51 | groupItem2.setActiveTab(tabItem); |
michael@0 | 52 | simulateDragDrop(groupItem2.$resizer[0]); |
michael@0 | 53 | is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); |
michael@0 | 54 | is(cw.UI.getActiveTab(), tabItem, "second groupItem's third tab is active"); |
michael@0 | 55 | |
michael@0 | 56 | // drag tab out of group |
michael@0 | 57 | tabItem = groupItem2.getChild(0); |
michael@0 | 58 | dragOutOfGroup(tabItem.container); |
michael@0 | 59 | is(cw.UI.getActiveTab(), tabItem, "the dragged tab is active"); |
michael@0 | 60 | |
michael@0 | 61 | // drag back into group |
michael@0 | 62 | dragIntoGroup(tabItem.container); |
michael@0 | 63 | cw.UI.setActive(groupItem); |
michael@0 | 64 | cw.UI.setActive(groupItem2); |
michael@0 | 65 | is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); |
michael@0 | 66 | |
michael@0 | 67 | // hide + unhide groupItem |
michael@0 | 68 | hideGroupItem(groupItem2, function () { |
michael@0 | 69 | is(cw.GroupItems.getActiveGroupItem(), groupItem, "first groupItem is active"); |
michael@0 | 70 | |
michael@0 | 71 | unhideGroupItem(groupItem2, function () { |
michael@0 | 72 | is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); |
michael@0 | 73 | is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); |
michael@0 | 74 | |
michael@0 | 75 | finish(); |
michael@0 | 76 | }); |
michael@0 | 77 | }); |
michael@0 | 78 | } |