browser/components/tabview/test/browser_tabview_bug635696.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 function test() {
michael@0 5 let cw;
michael@0 6
michael@0 7 let createGroupItem = function () {
michael@0 8 let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1);
michael@0 9
michael@0 10 let groupItemId = groupItem.id;
michael@0 11 registerCleanupFunction(function() {
michael@0 12 let groupItem = cw.GroupItems.groupItem(groupItemId);
michael@0 13 if (groupItem)
michael@0 14 groupItem.close();
michael@0 15 });
michael@0 16
michael@0 17 return groupItem;
michael@0 18 }
michael@0 19
michael@0 20 let testSingleGroupItem = function () {
michael@0 21 let groupItem = cw.GroupItems.groupItems[0];
michael@0 22 is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is active");
michael@0 23
michael@0 24 let tabItem = groupItem.getChild(0);
michael@0 25 is(cw.UI.getActiveTab(), tabItem, "tabItem is active");
michael@0 26
michael@0 27 hideGroupItem(groupItem, function () {
michael@0 28 unhideGroupItem(groupItem, function () {
michael@0 29 is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is still active");
michael@0 30 is(cw.UI.getActiveTab(), tabItem, "tabItem is still active");
michael@0 31 next();
michael@0 32 });
michael@0 33 });
michael@0 34 }
michael@0 35
michael@0 36 let testTwoGroupItems = function () {
michael@0 37 let groupItem = cw.GroupItems.groupItems[0];
michael@0 38 let tabItem = groupItem.getChild(0);
michael@0 39
michael@0 40 let groupItem2 = createGroupItem();
michael@0 41 let tabItem2 = groupItem2.getChild(0);
michael@0 42
michael@0 43 hideGroupItem(groupItem, function () {
michael@0 44 is(cw.UI.getActiveTab(), tabItem2, "tabItem2 is active");
michael@0 45 unhideGroupItem(groupItem, function () {
michael@0 46 cw.UI.setActive(tabItem);
michael@0 47 closeGroupItem(groupItem2, next);
michael@0 48 });
michael@0 49 });
michael@0 50 }
michael@0 51
michael@0 52 let tests = [testSingleGroupItem, testTwoGroupItems];
michael@0 53
michael@0 54 let next = function () {
michael@0 55 let test = tests.shift();
michael@0 56 if (test)
michael@0 57 test();
michael@0 58 else
michael@0 59 hideTabView(finishTest);
michael@0 60 }
michael@0 61
michael@0 62 let finishTest = function () {
michael@0 63 is(cw.GroupItems.groupItems.length, 1, "there is one groupItem");
michael@0 64 is(gBrowser.tabs.length, 1, "there is one tab");
michael@0 65 ok(!TabView.isVisible(), "tabview is hidden");
michael@0 66
michael@0 67 finish();
michael@0 68 }
michael@0 69
michael@0 70 waitForExplicitFinish();
michael@0 71
michael@0 72 showTabView(function () {
michael@0 73 registerCleanupFunction(function () TabView.hide());
michael@0 74 cw = TabView.getContentWindow();
michael@0 75 next();
michael@0 76 });
michael@0 77 }

mercurial