1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug635696.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 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 + let cw; 1.9 + 1.10 + let createGroupItem = function () { 1.11 + let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1); 1.12 + 1.13 + let groupItemId = groupItem.id; 1.14 + registerCleanupFunction(function() { 1.15 + let groupItem = cw.GroupItems.groupItem(groupItemId); 1.16 + if (groupItem) 1.17 + groupItem.close(); 1.18 + }); 1.19 + 1.20 + return groupItem; 1.21 + } 1.22 + 1.23 + let testSingleGroupItem = function () { 1.24 + let groupItem = cw.GroupItems.groupItems[0]; 1.25 + is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is active"); 1.26 + 1.27 + let tabItem = groupItem.getChild(0); 1.28 + is(cw.UI.getActiveTab(), tabItem, "tabItem is active"); 1.29 + 1.30 + hideGroupItem(groupItem, function () { 1.31 + unhideGroupItem(groupItem, function () { 1.32 + is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is still active"); 1.33 + is(cw.UI.getActiveTab(), tabItem, "tabItem is still active"); 1.34 + next(); 1.35 + }); 1.36 + }); 1.37 + } 1.38 + 1.39 + let testTwoGroupItems = function () { 1.40 + let groupItem = cw.GroupItems.groupItems[0]; 1.41 + let tabItem = groupItem.getChild(0); 1.42 + 1.43 + let groupItem2 = createGroupItem(); 1.44 + let tabItem2 = groupItem2.getChild(0); 1.45 + 1.46 + hideGroupItem(groupItem, function () { 1.47 + is(cw.UI.getActiveTab(), tabItem2, "tabItem2 is active"); 1.48 + unhideGroupItem(groupItem, function () { 1.49 + cw.UI.setActive(tabItem); 1.50 + closeGroupItem(groupItem2, next); 1.51 + }); 1.52 + }); 1.53 + } 1.54 + 1.55 + let tests = [testSingleGroupItem, testTwoGroupItems]; 1.56 + 1.57 + let next = function () { 1.58 + let test = tests.shift(); 1.59 + if (test) 1.60 + test(); 1.61 + else 1.62 + hideTabView(finishTest); 1.63 + } 1.64 + 1.65 + let finishTest = function () { 1.66 + is(cw.GroupItems.groupItems.length, 1, "there is one groupItem"); 1.67 + is(gBrowser.tabs.length, 1, "there is one tab"); 1.68 + ok(!TabView.isVisible(), "tabview is hidden"); 1.69 + 1.70 + finish(); 1.71 + } 1.72 + 1.73 + waitForExplicitFinish(); 1.74 + 1.75 + showTabView(function () { 1.76 + registerCleanupFunction(function () TabView.hide()); 1.77 + cw = TabView.getContentWindow(); 1.78 + next(); 1.79 + }); 1.80 +}