michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: let contentWindow; michael@0: let contentElement; michael@0: let groupItem; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: registerCleanupFunction(function () { michael@0: hideTabView(); michael@0: }); michael@0: michael@0: showTabView(function() { michael@0: contentWindow = TabView.getContentWindow(); michael@0: contentElement = contentWindow.document.getElementById("content"); michael@0: test1(); michael@0: }); michael@0: } michael@0: michael@0: function test1() { michael@0: is(gBrowser.tabs.length, 1, michael@0: "Total number of tabs is 1 before right button double click"); michael@0: // first click michael@0: mouseClick(contentElement, 2); michael@0: // second click michael@0: mouseClick(contentElement, 2); michael@0: michael@0: is(gBrowser.tabs.length, 1, michael@0: "Total number of tabs is 1 after right button double click"); michael@0: test2(); michael@0: } michael@0: michael@0: michael@0: function test2() { michael@0: is(gBrowser.tabs.length, 1, michael@0: "Total number of tabs is 1 before left, right and left mouse clicks"); michael@0: michael@0: // first click michael@0: mouseClick(contentElement, 0); michael@0: // second click michael@0: mouseClick(contentElement, 2); michael@0: // third click michael@0: mouseClick(contentElement, 0); michael@0: michael@0: is(gBrowser.tabs.length, 1, michael@0: "Total number of tabs is 1 before left, right and left mouse clicks"); michael@0: test3(); michael@0: } michael@0: michael@0: function test3() { michael@0: ok(contentWindow.GroupItems.groupItems.length, 1, "Only one group item exists"); michael@0: groupItem = contentWindow.GroupItems.groupItems[0]; michael@0: michael@0: is(groupItem.getChildren().length, 1, michael@0: "The number of tab items in the group is 1 before right button double click"); michael@0: michael@0: // first click michael@0: mouseClick(groupItem.container, 2); michael@0: // second click michael@0: mouseClick(groupItem.container, 2); michael@0: michael@0: is(groupItem.getChildren().length, 1, michael@0: "The number of tab items in the group is 1 after right button double click"); michael@0: test4(); michael@0: } michael@0: michael@0: function test4() { michael@0: is(groupItem.getChildren().length, 1, michael@0: "The number of tab items in the group is 1 before left, right, left mouse clicks"); michael@0: michael@0: // first click michael@0: mouseClick(groupItem.container, 0); michael@0: // second click michael@0: mouseClick(groupItem.container, 2); michael@0: // third click michael@0: mouseClick(groupItem.container, 0); michael@0: michael@0: is(groupItem.getChildren().length, 1, michael@0: "The number of tab items in the group is 1 before left, right, left mouse clicks"); michael@0: michael@0: hideTabView(function() { michael@0: is(gBrowser.tabs.length, 1, "Total number of tabs is 1 after all tests"); michael@0: michael@0: contentWindow = null; michael@0: contentElement = null; michael@0: groupItem = null; michael@0: michael@0: finish(); michael@0: }); michael@0: } michael@0: michael@0: function mouseClick(targetElement, buttonCode) { michael@0: EventUtils.sendMouseEvent( michael@0: { type: "mousedown", button: buttonCode }, targetElement, contentWindow); michael@0: EventUtils.sendMouseEvent( michael@0: { type: "mouseup", button: buttonCode }, targetElement, contentWindow); michael@0: } michael@0: