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 | function test() { |
michael@0 | 5 | let win, cw, groupItem; |
michael@0 | 6 | |
michael@0 | 7 | function checkNumberOfGroupItems(num) { |
michael@0 | 8 | is(cw.GroupItems.groupItems.length, num, "there are " + num + " groupItems"); |
michael@0 | 9 | } |
michael@0 | 10 | |
michael@0 | 11 | function next() { |
michael@0 | 12 | if (tests.length) |
michael@0 | 13 | tests.shift()(); |
michael@0 | 14 | else |
michael@0 | 15 | finish(); |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | // Empty groups should not be closed when toggling Panorama on and off. |
michael@0 | 19 | function test1() { |
michael@0 | 20 | hideTabView(function () { |
michael@0 | 21 | showTabView(function () { |
michael@0 | 22 | checkNumberOfGroupItems(2); |
michael@0 | 23 | next(); |
michael@0 | 24 | }, win); |
michael@0 | 25 | }, win); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | // Groups should not be closed when their last tab is closed outside of Panorama. |
michael@0 | 29 | function test2() { |
michael@0 | 30 | whenTabViewIsHidden(function () { |
michael@0 | 31 | whenTabViewIsShown(function () { |
michael@0 | 32 | checkNumberOfGroupItems(2); |
michael@0 | 33 | next(); |
michael@0 | 34 | }, win); |
michael@0 | 35 | |
michael@0 | 36 | win.gBrowser.removeTab(win.gBrowser.selectedTab); |
michael@0 | 37 | }, win); |
michael@0 | 38 | |
michael@0 | 39 | groupItem.newTab(); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | // Groups should be closed when their last tab is closed. |
michael@0 | 43 | function test3() { |
michael@0 | 44 | whenTabViewIsHidden(function () { |
michael@0 | 45 | showTabView(function () { |
michael@0 | 46 | let tab = win.gBrowser.tabs[1]; |
michael@0 | 47 | tab._tabViewTabItem.close(); |
michael@0 | 48 | checkNumberOfGroupItems(1); |
michael@0 | 49 | next(); |
michael@0 | 50 | }, win); |
michael@0 | 51 | }, win); |
michael@0 | 52 | |
michael@0 | 53 | win.gBrowser.addTab(); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | // Groups should be closed when their last tab is dragged out. |
michael@0 | 57 | function test4() { |
michael@0 | 58 | groupItem = createGroupItemWithBlankTabs(win, 200, 200, 20, 1); |
michael@0 | 59 | checkNumberOfGroupItems(2); |
michael@0 | 60 | |
michael@0 | 61 | let tab = win.gBrowser.tabs[1]; |
michael@0 | 62 | let target = tab._tabViewTabItem.container; |
michael@0 | 63 | |
michael@0 | 64 | waitForFocus(function () { |
michael@0 | 65 | EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
michael@0 | 66 | EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw); |
michael@0 | 67 | EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw); |
michael@0 | 68 | |
michael@0 | 69 | checkNumberOfGroupItems(2); |
michael@0 | 70 | closeGroupItem(cw.GroupItems.groupItems[1], next); |
michael@0 | 71 | }, win); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | let tests = [test1, test2, test3, test4]; |
michael@0 | 75 | |
michael@0 | 76 | waitForExplicitFinish(); |
michael@0 | 77 | |
michael@0 | 78 | newWindowWithTabView(function (aWin) { |
michael@0 | 79 | registerCleanupFunction(function () aWin.close()); |
michael@0 | 80 | |
michael@0 | 81 | win = aWin; |
michael@0 | 82 | cw = win.TabView.getContentWindow(); |
michael@0 | 83 | groupItem = createEmptyGroupItem(cw, 200, 200, 20); |
michael@0 | 84 | |
michael@0 | 85 | checkNumberOfGroupItems(2); |
michael@0 | 86 | next(); |
michael@0 | 87 | }); |
michael@0 | 88 | } |