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: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let newTabOne = gBrowser.addTab(); michael@0: let newTabTwo = gBrowser.addTab(); michael@0: let newTabThree = gBrowser.addTab(); michael@0: michael@0: registerCleanupFunction(function() { michael@0: TabView.hide(); michael@0: while (gBrowser.tabs.length > 1) michael@0: gBrowser.removeTab(gBrowser.tabs[0]); michael@0: }); michael@0: michael@0: showTabView(function() { michael@0: contentWindow = document.getElementById("tab-view").contentWindow; michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); michael@0: michael@0: groupItem = contentWindow.GroupItems.groupItems[0]; michael@0: michael@0: whenAppTabIconAdded(groupItem, function () { michael@0: whenAppTabIconAdded(groupItem, function () { michael@0: whenAppTabIconAdded(groupItem, function () { michael@0: michael@0: is(xulTabForAppTabIcon(0), newTabOne, michael@0: "New tab one matches the first app tab icon in tabview"); michael@0: is(xulTabForAppTabIcon(1), newTabTwo, michael@0: "New tab two matches the second app tab icon in tabview"); michael@0: is(xulTabForAppTabIcon(2), newTabThree, michael@0: "New tab three matches the third app tab icon in tabview"); michael@0: michael@0: // move the last tab to the first position michael@0: gBrowser.moveTabTo(newTabThree, 0); michael@0: is(xulTabForAppTabIcon(0), newTabThree, michael@0: "New tab three matches the first app tab icon in tabview"); michael@0: is(xulTabForAppTabIcon(1), newTabOne, michael@0: "New tab one matches the second app tab icon in tabview"); michael@0: is(xulTabForAppTabIcon(2), newTabTwo, michael@0: "New tab two matches the third app tab icon in tabview"); michael@0: michael@0: // move the first tab to the second position michael@0: gBrowser.moveTabTo(newTabThree, 1); michael@0: is(xulTabForAppTabIcon(0), newTabOne, michael@0: "New tab one matches the first app tab icon in tabview"); michael@0: is(xulTabForAppTabIcon(1), newTabThree, michael@0: "New tab three matches the second app tab icon in tabview"); michael@0: is(xulTabForAppTabIcon(2), newTabTwo, michael@0: "New tab two matches the third app tab icon in tabview"); michael@0: michael@0: hideTabView(function() { michael@0: gBrowser.removeTab(newTabOne); michael@0: gBrowser.removeTab(newTabTwo); michael@0: gBrowser.removeTab(newTabThree); michael@0: finish(); michael@0: }); michael@0: }); michael@0: gBrowser.pinTab(newTabThree); michael@0: }); michael@0: gBrowser.pinTab(newTabTwo); michael@0: }); michael@0: gBrowser.pinTab(newTabOne); michael@0: }); michael@0: } michael@0: michael@0: function xulTabForAppTabIcon(index) { michael@0: return contentWindow.iQ( michael@0: contentWindow.iQ(".appTabIcon", michael@0: groupItem.$appTabTray)[index]).data("xulTab"); michael@0: } michael@0: