Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | let originalTab; |
michael@0 | 5 | let newTabOne; |
michael@0 | 6 | let groupItemTwoId; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | |
michael@0 | 11 | originalTab = gBrowser.visibleTabs[0]; |
michael@0 | 12 | // add a tab to the existing group. |
michael@0 | 13 | newTabOne = gBrowser.addTab(); |
michael@0 | 14 | |
michael@0 | 15 | registerCleanupFunction(function() { |
michael@0 | 16 | while (gBrowser.tabs[1]) |
michael@0 | 17 | gBrowser.removeTab(gBrowser.tabs[1]); |
michael@0 | 18 | hideTabView(); |
michael@0 | 19 | }); |
michael@0 | 20 | |
michael@0 | 21 | showTabView(function() { |
michael@0 | 22 | let contentWindow = TabView.getContentWindow(); |
michael@0 | 23 | |
michael@0 | 24 | registerCleanupFunction(function() { |
michael@0 | 25 | let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); |
michael@0 | 26 | if (groupItem) |
michael@0 | 27 | closeGroupItem(groupItem); |
michael@0 | 28 | }); |
michael@0 | 29 | |
michael@0 | 30 | is(contentWindow.GroupItems.groupItems.length, 1, |
michael@0 | 31 | "There is one group item on startup"); |
michael@0 | 32 | let groupItemOne = contentWindow.GroupItems.groupItems[0]; |
michael@0 | 33 | is(groupItemOne.getChildren().length, 2, |
michael@0 | 34 | "There should be two tab items in that group."); |
michael@0 | 35 | is(gBrowser.selectedTab, groupItemOne.getChild(0).tab, |
michael@0 | 36 | "The currently selected tab should be the first tab in the groupItemOne"); |
michael@0 | 37 | |
michael@0 | 38 | // create another group with a tab. |
michael@0 | 39 | let groupItemTwo = createGroupItemWithBlankTabs(window, 300, 300, 200, 1); |
michael@0 | 40 | groupItemTwoId = groupItemTwoId; |
michael@0 | 41 | hideTabView(function() { |
michael@0 | 42 | // start the test |
michael@0 | 43 | testGroupSwitch(contentWindow, groupItemOne, groupItemTwo); |
michael@0 | 44 | }); |
michael@0 | 45 | }); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function testGroupSwitch(contentWindow, groupItemOne, groupItemTwo) { |
michael@0 | 49 | is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab, |
michael@0 | 50 | "The currently selected tab should be the only tab in the groupItemTwo"); |
michael@0 | 51 | |
michael@0 | 52 | // switch to groupItemOne |
michael@0 | 53 | let tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); |
michael@0 | 54 | if (tabItem) |
michael@0 | 55 | gBrowser.selectedTab = tabItem.tab; |
michael@0 | 56 | is(gBrowser.selectedTab, groupItemOne.getChild(0).tab, |
michael@0 | 57 | "The currently selected tab should be the first tab in the groupItemOne"); |
michael@0 | 58 | |
michael@0 | 59 | // switch to the second tab in groupItemOne |
michael@0 | 60 | gBrowser.selectedTab = groupItemOne.getChild(1).tab; |
michael@0 | 61 | |
michael@0 | 62 | // switch to groupItemTwo |
michael@0 | 63 | tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); |
michael@0 | 64 | if (tabItem) |
michael@0 | 65 | gBrowser.selectedTab = tabItem.tab; |
michael@0 | 66 | is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab, |
michael@0 | 67 | "The currently selected tab should be the only tab in the groupItemTwo"); |
michael@0 | 68 | |
michael@0 | 69 | // switch to groupItemOne |
michael@0 | 70 | tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); |
michael@0 | 71 | if (tabItem) |
michael@0 | 72 | gBrowser.selectedTab = tabItem.tab; |
michael@0 | 73 | is(gBrowser.selectedTab, groupItemOne.getChild(1).tab, |
michael@0 | 74 | "The currently selected tab should be the second tab in the groupItemOne"); |
michael@0 | 75 | |
michael@0 | 76 | // cleanup. |
michael@0 | 77 | gBrowser.removeTab(groupItemTwo.getChild(0).tab); |
michael@0 | 78 | gBrowser.removeTab(newTabOne); |
michael@0 | 79 | |
michael@0 | 80 | finish(); |
michael@0 | 81 | } |