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 contentWindow; |
michael@0 | 5 | let groupItemTwoId; |
michael@0 | 6 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | |
michael@0 | 10 | registerCleanupFunction(function() { |
michael@0 | 11 | while (gBrowser.tabs[1]) |
michael@0 | 12 | gBrowser.removeTab(gBrowser.tabs[1]); |
michael@0 | 13 | hideTabView(); |
michael@0 | 14 | }); |
michael@0 | 15 | gBrowser.loadOneTab("about:blank", { inBackground: true }); |
michael@0 | 16 | showTabView(setup); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function setup() { |
michael@0 | 20 | registerCleanupFunction(function() { |
michael@0 | 21 | let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); |
michael@0 | 22 | if (groupItem) |
michael@0 | 23 | closeGroupItem(groupItem); |
michael@0 | 24 | }); |
michael@0 | 25 | |
michael@0 | 26 | let contentWindow = TabView.getContentWindow(); |
michael@0 | 27 | is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); |
michael@0 | 28 | |
michael@0 | 29 | let groupItemOne = contentWindow.GroupItems.groupItems[0]; |
michael@0 | 30 | is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items"); |
michael@0 | 31 | |
michael@0 | 32 | let groupItemTwo = createGroupItemWithBlankTabs(window, 250, 250, 40, 1); |
michael@0 | 33 | groupItemTwoId = groupItemTwo.id; |
michael@0 | 34 | testGroups(groupItemOne, groupItemTwo, contentWindow); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function testGroups(groupItemOne, groupItemTwo, contentWindow) { |
michael@0 | 38 | // check active tab and group |
michael@0 | 39 | is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, |
michael@0 | 40 | "The group two is the active group"); |
michael@0 | 41 | is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(0), |
michael@0 | 42 | "The first tab item in group two is active"); |
michael@0 | 43 | |
michael@0 | 44 | let tabItem = groupItemOne.getChild(1); |
michael@0 | 45 | tabItem.addSubscriber("tabRemoved", function onTabRemoved() { |
michael@0 | 46 | tabItem.removeSubscriber("tabRemoved", onTabRemoved); |
michael@0 | 47 | |
michael@0 | 48 | is(groupItemOne.getChildren().length, 1, |
michael@0 | 49 | "The num of childen in group one is 1"); |
michael@0 | 50 | |
michael@0 | 51 | // check active group and active tab |
michael@0 | 52 | is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne, |
michael@0 | 53 | "The group one is the active group"); |
michael@0 | 54 | is(contentWindow.UI.getActiveTab(), groupItemOne.getChild(0), |
michael@0 | 55 | "The first tab item in group one is active"); |
michael@0 | 56 | |
michael@0 | 57 | whenTabViewIsHidden(function() { |
michael@0 | 58 | is(groupItemOne.getChildren().length, 2, |
michael@0 | 59 | "The num of childen in group one is 2"); |
michael@0 | 60 | |
michael@0 | 61 | // clean up and finish |
michael@0 | 62 | closeGroupItem(groupItemTwo, function() { |
michael@0 | 63 | gBrowser.removeTab(groupItemOne.getChild(1).tab); |
michael@0 | 64 | is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); |
michael@0 | 65 | is(groupItemOne.getChildren().length, 1, |
michael@0 | 66 | "The num of childen in group one is 1"); |
michael@0 | 67 | is(gBrowser.tabs.length, 1, "Has only one tab"); |
michael@0 | 68 | |
michael@0 | 69 | finish(); |
michael@0 | 70 | }); |
michael@0 | 71 | }); |
michael@0 | 72 | EventUtils.synthesizeKey("t", { accelKey: true }); |
michael@0 | 73 | }); |
michael@0 | 74 | // close a tab item in group one |
michael@0 | 75 | EventUtils.synthesizeMouseAtCenter(tabItem.$close[0], {}, contentWindow); |
michael@0 | 76 | } |