1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug630157.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,79 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + let cw; 1.9 + 1.10 + let createGroupItem = function () { 1.11 + let bounds = new cw.Rect(20, 20, 400, 200); 1.12 + let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); 1.13 + 1.14 + let groupItemId = groupItem.id; 1.15 + registerCleanupFunction(function() { 1.16 + let groupItem = cw.GroupItems.groupItem(groupItemId); 1.17 + if (groupItem) 1.18 + groupItem.close(); 1.19 + }); 1.20 + 1.21 + return groupItem; 1.22 + } 1.23 + 1.24 + let assertNumberOfGroups = function (num) { 1.25 + is(cw.GroupItems.groupItems.length, num, 'there should be ' + num + ' groups'); 1.26 + } 1.27 + 1.28 + let assertNumberOfTabs = function (num) { 1.29 + is(gBrowser.tabs.length, num, 'there should be ' + num + ' tabs'); 1.30 + } 1.31 + 1.32 + let simulateDoubleClick = function (target, button) { 1.33 + for (let i=0; i<2; i++) 1.34 + EventUtils.synthesizeMouseAtCenter(target, {button: button || 0}, cw); 1.35 + } 1.36 + 1.37 + let finishTest = function () { 1.38 + let tabItem = gBrowser.tabs[0]._tabViewTabItem; 1.39 + cw.GroupItems.updateActiveGroupItemAndTabBar(tabItem); 1.40 + 1.41 + assertNumberOfGroups(1); 1.42 + assertNumberOfTabs(1); 1.43 + 1.44 + finish(); 1.45 + } 1.46 + 1.47 + let testDoubleClick = function () { 1.48 + let groupItem = createGroupItem(); 1.49 + assertNumberOfGroups(2); 1.50 + assertNumberOfTabs(1); 1.51 + 1.52 + // simulate double click on group title 1.53 + let input = groupItem.$title[0]; 1.54 + simulateDoubleClick(input); 1.55 + assertNumberOfTabs(1); 1.56 + 1.57 + // simulate double click on title bar 1.58 + let titlebar = groupItem.$titlebar[0]; 1.59 + simulateDoubleClick(titlebar); 1.60 + assertNumberOfTabs(1); 1.61 + 1.62 + // simulate double click with middle mouse button 1.63 + let container = groupItem.container; 1.64 + simulateDoubleClick(container, 1); 1.65 + assertNumberOfTabs(1); 1.66 + 1.67 + // simulate double click with right mouse button 1.68 + simulateDoubleClick(container, 2); 1.69 + assertNumberOfTabs(1); 1.70 + 1.71 + groupItem.close(); 1.72 + hideTabView(finishTest); 1.73 + } 1.74 + 1.75 + waitForExplicitFinish(); 1.76 + registerCleanupFunction(function () TabView.hide()); 1.77 + 1.78 + showTabView(function () { 1.79 + cw = TabView.getContentWindow(); 1.80 + testDoubleClick(); 1.81 + }); 1.82 +}