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 assertNumberOfGroupItems = function (num) { |
michael@0 | 8 | let groupItems = cw.GroupItems.groupItems; |
michael@0 | 9 | is(groupItems.length, num, "number of groupItems is " + num); |
michael@0 | 10 | }; |
michael@0 | 11 | |
michael@0 | 12 | let dragTabOutOfGroup = function (groupItem) { |
michael@0 | 13 | let tabItem = groupItem.getChild(0); |
michael@0 | 14 | let target = tabItem.container; |
michael@0 | 15 | |
michael@0 | 16 | EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
michael@0 | 17 | EventUtils.synthesizeMouse(target, 400, 100, {type: "mousemove"}, cw); |
michael@0 | 18 | EventUtils.synthesizeMouseAtCenter(target, {type: "mouseup"}, cw); |
michael@0 | 19 | }; |
michael@0 | 20 | |
michael@0 | 21 | let testCreateGroup = function (callback) { |
michael@0 | 22 | let content = cw.document.getElementById("content"); |
michael@0 | 23 | |
michael@0 | 24 | // drag to create a new group |
michael@0 | 25 | EventUtils.synthesizeMouse(content, 400, 50, {type: "mousedown"}, cw); |
michael@0 | 26 | EventUtils.synthesizeMouse(content, 500, 250, {type: "mousemove"}, cw); |
michael@0 | 27 | EventUtils.synthesizeMouse(content, 500, 250, {type: "mouseup"}, cw); |
michael@0 | 28 | |
michael@0 | 29 | assertNumberOfGroupItems(2); |
michael@0 | 30 | |
michael@0 | 31 | // enter a title for the new group |
michael@0 | 32 | EventUtils.synthesizeKey("t", {}, cw); |
michael@0 | 33 | EventUtils.synthesizeKey("VK_RETURN", {}, cw); |
michael@0 | 34 | |
michael@0 | 35 | |
michael@0 | 36 | let groupItem = cw.GroupItems.groupItems[1]; |
michael@0 | 37 | is(groupItem.getTitle(), "t", "new groupItem's title is correct"); |
michael@0 | 38 | |
michael@0 | 39 | closeGroupItem(groupItem, callback); |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | let testDragOutOfGroup = function (callback) { |
michael@0 | 43 | assertNumberOfGroupItems(1); |
michael@0 | 44 | |
michael@0 | 45 | let groupItem = cw.GroupItems.groupItems[0]; |
michael@0 | 46 | dragTabOutOfGroup(groupItem); |
michael@0 | 47 | assertNumberOfGroupItems(2); |
michael@0 | 48 | |
michael@0 | 49 | // enter a title for the new group |
michael@0 | 50 | EventUtils.synthesizeKey("t", {}, cw); |
michael@0 | 51 | EventUtils.synthesizeKey("VK_RETURN", {}, cw); |
michael@0 | 52 | |
michael@0 | 53 | groupItem = cw.GroupItems.groupItems[1]; |
michael@0 | 54 | is(groupItem.getTitle(), "t", "new groupItem's title is correct"); |
michael@0 | 55 | closeGroupItem(groupItem, callback); |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | let onLoad = function (win) { |
michael@0 | 59 | registerCleanupFunction(function () win.close()); |
michael@0 | 60 | |
michael@0 | 61 | for (let i = 0; i < 2; i++) |
michael@0 | 62 | win.gBrowser.addTab(); |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | let onShow = function (win) { |
michael@0 | 66 | cw = win.TabView.getContentWindow(); |
michael@0 | 67 | assertNumberOfGroupItems(1); |
michael@0 | 68 | |
michael@0 | 69 | let groupItem = cw.GroupItems.groupItems[0]; |
michael@0 | 70 | groupItem.setSize(200, 600, true); |
michael@0 | 71 | |
michael@0 | 72 | waitForFocus(function () { |
michael@0 | 73 | testCreateGroup(function () { |
michael@0 | 74 | testDragOutOfGroup(finish); |
michael@0 | 75 | }); |
michael@0 | 76 | }, cw); |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | waitForExplicitFinish(); |
michael@0 | 80 | newWindowWithTabView(onShow, onLoad); |
michael@0 | 81 | } |