1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug640765.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let contentWindow; 1.8 +let groupItem; 1.9 + 1.10 +function test() { 1.11 + waitForExplicitFinish(); 1.12 + 1.13 + let newTabOne = gBrowser.addTab(); 1.14 + let newTabTwo = gBrowser.addTab(); 1.15 + let newTabThree = gBrowser.addTab(); 1.16 + 1.17 + registerCleanupFunction(function() { 1.18 + TabView.hide(); 1.19 + while (gBrowser.tabs.length > 1) 1.20 + gBrowser.removeTab(gBrowser.tabs[0]); 1.21 + }); 1.22 + 1.23 + showTabView(function() { 1.24 + contentWindow = document.getElementById("tab-view").contentWindow; 1.25 + is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); 1.26 + 1.27 + groupItem = contentWindow.GroupItems.groupItems[0]; 1.28 + 1.29 + whenAppTabIconAdded(groupItem, function () { 1.30 + whenAppTabIconAdded(groupItem, function () { 1.31 + whenAppTabIconAdded(groupItem, function () { 1.32 + 1.33 + is(xulTabForAppTabIcon(0), newTabOne, 1.34 + "New tab one matches the first app tab icon in tabview"); 1.35 + is(xulTabForAppTabIcon(1), newTabTwo, 1.36 + "New tab two matches the second app tab icon in tabview"); 1.37 + is(xulTabForAppTabIcon(2), newTabThree, 1.38 + "New tab three matches the third app tab icon in tabview"); 1.39 + 1.40 + // move the last tab to the first position 1.41 + gBrowser.moveTabTo(newTabThree, 0); 1.42 + is(xulTabForAppTabIcon(0), newTabThree, 1.43 + "New tab three matches the first app tab icon in tabview"); 1.44 + is(xulTabForAppTabIcon(1), newTabOne, 1.45 + "New tab one matches the second app tab icon in tabview"); 1.46 + is(xulTabForAppTabIcon(2), newTabTwo, 1.47 + "New tab two matches the third app tab icon in tabview"); 1.48 + 1.49 + // move the first tab to the second position 1.50 + gBrowser.moveTabTo(newTabThree, 1); 1.51 + is(xulTabForAppTabIcon(0), newTabOne, 1.52 + "New tab one matches the first app tab icon in tabview"); 1.53 + is(xulTabForAppTabIcon(1), newTabThree, 1.54 + "New tab three matches the second app tab icon in tabview"); 1.55 + is(xulTabForAppTabIcon(2), newTabTwo, 1.56 + "New tab two matches the third app tab icon in tabview"); 1.57 + 1.58 + hideTabView(function() { 1.59 + gBrowser.removeTab(newTabOne); 1.60 + gBrowser.removeTab(newTabTwo); 1.61 + gBrowser.removeTab(newTabThree); 1.62 + finish(); 1.63 + }); 1.64 + }); 1.65 + gBrowser.pinTab(newTabThree); 1.66 + }); 1.67 + gBrowser.pinTab(newTabTwo); 1.68 + }); 1.69 + gBrowser.pinTab(newTabOne); 1.70 + }); 1.71 +} 1.72 + 1.73 +function xulTabForAppTabIcon(index) { 1.74 + return contentWindow.iQ( 1.75 + contentWindow.iQ(".appTabIcon", 1.76 + groupItem.$appTabTray)[index]).data("xulTab"); 1.77 +} 1.78 +