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 cw; |
michael@0 | 6 | |
michael@0 | 7 | let createGroupItem = function () { |
michael@0 | 8 | let bounds = new cw.Rect(20, 20, 400, 200); |
michael@0 | 9 | let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); |
michael@0 | 10 | |
michael@0 | 11 | let groupItemId = groupItem.id; |
michael@0 | 12 | registerCleanupFunction(function() { |
michael@0 | 13 | let groupItem = cw.GroupItems.groupItem(groupItemId); |
michael@0 | 14 | if (groupItem) |
michael@0 | 15 | groupItem.close(); |
michael@0 | 16 | }); |
michael@0 | 17 | |
michael@0 | 18 | return groupItem; |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | let assertNumberOfGroups = function (num) { |
michael@0 | 22 | is(cw.GroupItems.groupItems.length, num, 'there should be ' + num + ' groups'); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | let assertNumberOfTabs = function (num) { |
michael@0 | 26 | is(gBrowser.tabs.length, num, 'there should be ' + num + ' tabs'); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | let simulateDoubleClick = function (target, button) { |
michael@0 | 30 | for (let i=0; i<2; i++) |
michael@0 | 31 | EventUtils.synthesizeMouseAtCenter(target, {button: button || 0}, cw); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | let finishTest = function () { |
michael@0 | 35 | let tabItem = gBrowser.tabs[0]._tabViewTabItem; |
michael@0 | 36 | cw.GroupItems.updateActiveGroupItemAndTabBar(tabItem); |
michael@0 | 37 | |
michael@0 | 38 | assertNumberOfGroups(1); |
michael@0 | 39 | assertNumberOfTabs(1); |
michael@0 | 40 | |
michael@0 | 41 | finish(); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | let testDoubleClick = function () { |
michael@0 | 45 | let groupItem = createGroupItem(); |
michael@0 | 46 | assertNumberOfGroups(2); |
michael@0 | 47 | assertNumberOfTabs(1); |
michael@0 | 48 | |
michael@0 | 49 | // simulate double click on group title |
michael@0 | 50 | let input = groupItem.$title[0]; |
michael@0 | 51 | simulateDoubleClick(input); |
michael@0 | 52 | assertNumberOfTabs(1); |
michael@0 | 53 | |
michael@0 | 54 | // simulate double click on title bar |
michael@0 | 55 | let titlebar = groupItem.$titlebar[0]; |
michael@0 | 56 | simulateDoubleClick(titlebar); |
michael@0 | 57 | assertNumberOfTabs(1); |
michael@0 | 58 | |
michael@0 | 59 | // simulate double click with middle mouse button |
michael@0 | 60 | let container = groupItem.container; |
michael@0 | 61 | simulateDoubleClick(container, 1); |
michael@0 | 62 | assertNumberOfTabs(1); |
michael@0 | 63 | |
michael@0 | 64 | // simulate double click with right mouse button |
michael@0 | 65 | simulateDoubleClick(container, 2); |
michael@0 | 66 | assertNumberOfTabs(1); |
michael@0 | 67 | |
michael@0 | 68 | groupItem.close(); |
michael@0 | 69 | hideTabView(finishTest); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | waitForExplicitFinish(); |
michael@0 | 73 | registerCleanupFunction(function () TabView.hide()); |
michael@0 | 74 | |
michael@0 | 75 | showTabView(function () { |
michael@0 | 76 | cw = TabView.getContentWindow(); |
michael@0 | 77 | testDoubleClick(); |
michael@0 | 78 | }); |
michael@0 | 79 | } |