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: waitForExplicitFinish(); michael@0: michael@0: window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: let moves = 0; michael@0: let contentWindow = null; michael@0: let newTabs = []; michael@0: let originalTab = null; michael@0: michael@0: function onTabMove(e) { michael@0: let tab = e.target; michael@0: moves++; michael@0: } michael@0: michael@0: function onTabViewWindowLoaded() { michael@0: window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); michael@0: michael@0: contentWindow = document.getElementById("tab-view").contentWindow; michael@0: michael@0: originalTab = gBrowser.selectedTab; michael@0: newTabs = [gBrowser.addTab("about:rights"), gBrowser.addTab("about:mozilla"), gBrowser.addTab("about:license")]; michael@0: michael@0: is(originalTab._tPos, 0, "Original tab is in position 0"); michael@0: is(newTabs[0]._tPos, 1, "Rights is in position 1"); michael@0: is(newTabs[1]._tPos, 2, "Mozilla is in position 2"); michael@0: is(newTabs[2]._tPos, 3, "License is in position 3"); michael@0: michael@0: gBrowser.tabContainer.addEventListener("TabMove", onTabMove, false); michael@0: michael@0: let groupItem = contentWindow.GroupItems.getActiveGroupItem(); michael@0: michael@0: // move 3 > 0 (and therefore 0 > 1, 1 > 2, 2 > 3) michael@0: groupItem._children.splice(0, 0, groupItem._children.splice(3, 1)[0]); michael@0: groupItem.arrange(); michael@0: michael@0: window.addEventListener("tabviewhidden", onTabViewWindowHidden, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: function onTabViewWindowHidden() { michael@0: window.removeEventListener("tabviewhidden", onTabViewWindowHidden, false); michael@0: gBrowser.tabContainer.removeEventListener("TabMove", onTabMove, false); michael@0: michael@0: is(moves, 1, "Only one move should be necessary for this basic move."); michael@0: michael@0: is(newTabs[2]._tPos, 0, "License is in position 0"); michael@0: is(originalTab._tPos, 1, "Original tab is in position 1"); michael@0: is(newTabs[0]._tPos, 2, "Rights is in position 2"); michael@0: is(newTabs[1]._tPos, 3, "Mozilla is in position 3"); michael@0: michael@0: gBrowser.removeTab(newTabs[0]); michael@0: gBrowser.removeTab(newTabs[1]); michael@0: gBrowser.removeTab(newTabs[2]); michael@0: finish(); michael@0: }