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 | let contentWindow; |
michael@0 | 4 | let contentElement; |
michael@0 | 5 | let groupItem; |
michael@0 | 6 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | |
michael@0 | 10 | registerCleanupFunction(function () { |
michael@0 | 11 | hideTabView(); |
michael@0 | 12 | }); |
michael@0 | 13 | |
michael@0 | 14 | showTabView(function() { |
michael@0 | 15 | contentWindow = TabView.getContentWindow(); |
michael@0 | 16 | contentElement = contentWindow.document.getElementById("content"); |
michael@0 | 17 | test1(); |
michael@0 | 18 | }); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function test1() { |
michael@0 | 22 | is(gBrowser.tabs.length, 1, |
michael@0 | 23 | "Total number of tabs is 1 before right button double click"); |
michael@0 | 24 | // first click |
michael@0 | 25 | mouseClick(contentElement, 2); |
michael@0 | 26 | // second click |
michael@0 | 27 | mouseClick(contentElement, 2); |
michael@0 | 28 | |
michael@0 | 29 | is(gBrowser.tabs.length, 1, |
michael@0 | 30 | "Total number of tabs is 1 after right button double click"); |
michael@0 | 31 | test2(); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | |
michael@0 | 35 | function test2() { |
michael@0 | 36 | is(gBrowser.tabs.length, 1, |
michael@0 | 37 | "Total number of tabs is 1 before left, right and left mouse clicks"); |
michael@0 | 38 | |
michael@0 | 39 | // first click |
michael@0 | 40 | mouseClick(contentElement, 0); |
michael@0 | 41 | // second click |
michael@0 | 42 | mouseClick(contentElement, 2); |
michael@0 | 43 | // third click |
michael@0 | 44 | mouseClick(contentElement, 0); |
michael@0 | 45 | |
michael@0 | 46 | is(gBrowser.tabs.length, 1, |
michael@0 | 47 | "Total number of tabs is 1 before left, right and left mouse clicks"); |
michael@0 | 48 | test3(); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function test3() { |
michael@0 | 52 | ok(contentWindow.GroupItems.groupItems.length, 1, "Only one group item exists"); |
michael@0 | 53 | groupItem = contentWindow.GroupItems.groupItems[0]; |
michael@0 | 54 | |
michael@0 | 55 | is(groupItem.getChildren().length, 1, |
michael@0 | 56 | "The number of tab items in the group is 1 before right button double click"); |
michael@0 | 57 | |
michael@0 | 58 | // first click |
michael@0 | 59 | mouseClick(groupItem.container, 2); |
michael@0 | 60 | // second click |
michael@0 | 61 | mouseClick(groupItem.container, 2); |
michael@0 | 62 | |
michael@0 | 63 | is(groupItem.getChildren().length, 1, |
michael@0 | 64 | "The number of tab items in the group is 1 after right button double click"); |
michael@0 | 65 | test4(); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function test4() { |
michael@0 | 69 | is(groupItem.getChildren().length, 1, |
michael@0 | 70 | "The number of tab items in the group is 1 before left, right, left mouse clicks"); |
michael@0 | 71 | |
michael@0 | 72 | // first click |
michael@0 | 73 | mouseClick(groupItem.container, 0); |
michael@0 | 74 | // second click |
michael@0 | 75 | mouseClick(groupItem.container, 2); |
michael@0 | 76 | // third click |
michael@0 | 77 | mouseClick(groupItem.container, 0); |
michael@0 | 78 | |
michael@0 | 79 | is(groupItem.getChildren().length, 1, |
michael@0 | 80 | "The number of tab items in the group is 1 before left, right, left mouse clicks"); |
michael@0 | 81 | |
michael@0 | 82 | hideTabView(function() { |
michael@0 | 83 | is(gBrowser.tabs.length, 1, "Total number of tabs is 1 after all tests"); |
michael@0 | 84 | |
michael@0 | 85 | contentWindow = null; |
michael@0 | 86 | contentElement = null; |
michael@0 | 87 | groupItem = null; |
michael@0 | 88 | |
michael@0 | 89 | finish(); |
michael@0 | 90 | }); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | function mouseClick(targetElement, buttonCode) { |
michael@0 | 94 | EventUtils.sendMouseEvent( |
michael@0 | 95 | { type: "mousedown", button: buttonCode }, targetElement, contentWindow); |
michael@0 | 96 | EventUtils.sendMouseEvent( |
michael@0 | 97 | { type: "mouseup", button: buttonCode }, targetElement, contentWindow); |
michael@0 | 98 | } |
michael@0 | 99 |