1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug649006.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,99 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 +let contentWindow; 1.7 +let contentElement; 1.8 +let groupItem; 1.9 + 1.10 +function test() { 1.11 + waitForExplicitFinish(); 1.12 + 1.13 + registerCleanupFunction(function () { 1.14 + hideTabView(); 1.15 + }); 1.16 + 1.17 + showTabView(function() { 1.18 + contentWindow = TabView.getContentWindow(); 1.19 + contentElement = contentWindow.document.getElementById("content"); 1.20 + test1(); 1.21 + }); 1.22 +} 1.23 + 1.24 +function test1() { 1.25 + is(gBrowser.tabs.length, 1, 1.26 + "Total number of tabs is 1 before right button double click"); 1.27 + // first click 1.28 + mouseClick(contentElement, 2); 1.29 + // second click 1.30 + mouseClick(contentElement, 2); 1.31 + 1.32 + is(gBrowser.tabs.length, 1, 1.33 + "Total number of tabs is 1 after right button double click"); 1.34 + test2(); 1.35 +} 1.36 + 1.37 + 1.38 +function test2() { 1.39 + is(gBrowser.tabs.length, 1, 1.40 + "Total number of tabs is 1 before left, right and left mouse clicks"); 1.41 + 1.42 + // first click 1.43 + mouseClick(contentElement, 0); 1.44 + // second click 1.45 + mouseClick(contentElement, 2); 1.46 + // third click 1.47 + mouseClick(contentElement, 0); 1.48 + 1.49 + is(gBrowser.tabs.length, 1, 1.50 + "Total number of tabs is 1 before left, right and left mouse clicks"); 1.51 + test3(); 1.52 +} 1.53 + 1.54 +function test3() { 1.55 + ok(contentWindow.GroupItems.groupItems.length, 1, "Only one group item exists"); 1.56 + groupItem = contentWindow.GroupItems.groupItems[0]; 1.57 + 1.58 + is(groupItem.getChildren().length, 1, 1.59 + "The number of tab items in the group is 1 before right button double click"); 1.60 + 1.61 + // first click 1.62 + mouseClick(groupItem.container, 2); 1.63 + // second click 1.64 + mouseClick(groupItem.container, 2); 1.65 + 1.66 + is(groupItem.getChildren().length, 1, 1.67 + "The number of tab items in the group is 1 after right button double click"); 1.68 + test4(); 1.69 +} 1.70 + 1.71 +function test4() { 1.72 + is(groupItem.getChildren().length, 1, 1.73 + "The number of tab items in the group is 1 before left, right, left mouse clicks"); 1.74 + 1.75 + // first click 1.76 + mouseClick(groupItem.container, 0); 1.77 + // second click 1.78 + mouseClick(groupItem.container, 2); 1.79 + // third click 1.80 + mouseClick(groupItem.container, 0); 1.81 + 1.82 + is(groupItem.getChildren().length, 1, 1.83 + "The number of tab items in the group is 1 before left, right, left mouse clicks"); 1.84 + 1.85 + hideTabView(function() { 1.86 + is(gBrowser.tabs.length, 1, "Total number of tabs is 1 after all tests"); 1.87 + 1.88 + contentWindow = null; 1.89 + contentElement = null; 1.90 + groupItem = null; 1.91 + 1.92 + finish(); 1.93 + }); 1.94 +} 1.95 + 1.96 +function mouseClick(targetElement, buttonCode) { 1.97 + EventUtils.sendMouseEvent( 1.98 + { type: "mousedown", button: buttonCode }, targetElement, contentWindow); 1.99 + EventUtils.sendMouseEvent( 1.100 + { type: "mouseup", button: buttonCode }, targetElement, contentWindow); 1.101 +} 1.102 +