1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug586553.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 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 + window.addEventListener("tabviewshown", onTabViewWindowLoaded, false); 1.11 + TabView.toggle(); 1.12 +} 1.13 + 1.14 +let moves = 0; 1.15 +let contentWindow = null; 1.16 +let newTabs = []; 1.17 +let originalTab = null; 1.18 + 1.19 +function onTabMove(e) { 1.20 + let tab = e.target; 1.21 + moves++; 1.22 +} 1.23 + 1.24 +function onTabViewWindowLoaded() { 1.25 + window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false); 1.26 + 1.27 + contentWindow = document.getElementById("tab-view").contentWindow; 1.28 + 1.29 + originalTab = gBrowser.selectedTab; 1.30 + newTabs = [gBrowser.addTab("about:rights"), gBrowser.addTab("about:mozilla"), gBrowser.addTab("about:license")]; 1.31 + 1.32 + is(originalTab._tPos, 0, "Original tab is in position 0"); 1.33 + is(newTabs[0]._tPos, 1, "Rights is in position 1"); 1.34 + is(newTabs[1]._tPos, 2, "Mozilla is in position 2"); 1.35 + is(newTabs[2]._tPos, 3, "License is in position 3"); 1.36 + 1.37 + gBrowser.tabContainer.addEventListener("TabMove", onTabMove, false); 1.38 + 1.39 + let groupItem = contentWindow.GroupItems.getActiveGroupItem(); 1.40 + 1.41 + // move 3 > 0 (and therefore 0 > 1, 1 > 2, 2 > 3) 1.42 + groupItem._children.splice(0, 0, groupItem._children.splice(3, 1)[0]); 1.43 + groupItem.arrange(); 1.44 + 1.45 + window.addEventListener("tabviewhidden", onTabViewWindowHidden, false); 1.46 + TabView.toggle(); 1.47 +} 1.48 + 1.49 +function onTabViewWindowHidden() { 1.50 + window.removeEventListener("tabviewhidden", onTabViewWindowHidden, false); 1.51 + gBrowser.tabContainer.removeEventListener("TabMove", onTabMove, false); 1.52 + 1.53 + is(moves, 1, "Only one move should be necessary for this basic move."); 1.54 + 1.55 + is(newTabs[2]._tPos, 0, "License is in position 0"); 1.56 + is(originalTab._tPos, 1, "Original tab is in position 1"); 1.57 + is(newTabs[0]._tPos, 2, "Rights is in position 2"); 1.58 + is(newTabs[1]._tPos, 3, "Mozilla is in position 3"); 1.59 + 1.60 + gBrowser.removeTab(newTabs[0]); 1.61 + gBrowser.removeTab(newTabs[1]); 1.62 + gBrowser.removeTab(newTabs[2]); 1.63 + finish(); 1.64 +}