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 | let contentWindow; |
michael@0 | 5 | let groupItem; |
michael@0 | 6 | let groupItemId; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | |
michael@0 | 11 | registerCleanupFunction(function() { |
michael@0 | 12 | contentWindow.gPrefBranch.clearUserPref("animate_zoom"); |
michael@0 | 13 | let createdGroupItem = contentWindow.GroupItems.groupItem(groupItemId) |
michael@0 | 14 | if (createdGroupItem) |
michael@0 | 15 | closeGroupItem(createdGroupItem); |
michael@0 | 16 | hideTabView(); |
michael@0 | 17 | }); |
michael@0 | 18 | |
michael@0 | 19 | showTabView(function() { |
michael@0 | 20 | contentWindow = TabView.getContentWindow(); |
michael@0 | 21 | groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200); |
michael@0 | 22 | groupItemId = groupItem.id; |
michael@0 | 23 | testMouseClickOnEmptyGroupItem(); |
michael@0 | 24 | }); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function testMouseClickOnEmptyGroupItem() { |
michael@0 | 28 | whenTabViewIsHidden(function() { |
michael@0 | 29 | is(groupItem.getChildren().length, 1, "The group item contains one tab item now"); |
michael@0 | 30 | showTabView(testDraggingWithinGroupItem); |
michael@0 | 31 | }); |
michael@0 | 32 | is(groupItem.getChildren().length, 0, "The group item doesn't contain any tab items"); |
michael@0 | 33 | EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow); |
michael@0 | 34 | EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function testDraggingWithinGroupItem() { |
michael@0 | 38 | let target = groupItem.container; |
michael@0 | 39 | contentWindow.gPrefBranch.setBoolPref("animate_zoom", false); |
michael@0 | 40 | |
michael@0 | 41 | // stimulate drag and drop |
michael@0 | 42 | EventUtils.sendMouseEvent( {type: "mousedown" }, target, contentWindow); |
michael@0 | 43 | EventUtils.synthesizeMouse(target, 10, 10, { type: "mousemove" }, contentWindow); |
michael@0 | 44 | ok(groupItem.isDragging, "The group item is being dragged") |
michael@0 | 45 | |
michael@0 | 46 | EventUtils.sendMouseEvent({ type: "mouseup" }, target, contentWindow); |
michael@0 | 47 | ok(!groupItem.isDragging, "The dragging is competely"); |
michael@0 | 48 | |
michael@0 | 49 | executeSoon(function() { |
michael@0 | 50 | ok(TabView.isVisible(), "The tab view is still visible after dragging"); |
michael@0 | 51 | contentWindow.gPrefBranch.clearUserPref("animate_zoom"); |
michael@0 | 52 | |
michael@0 | 53 | testMouseClickOnGroupItem(); |
michael@0 | 54 | }); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function testMouseClickOnGroupItem() { |
michael@0 | 58 | whenTabViewIsHidden(function() { |
michael@0 | 59 | is(groupItem.getChildren().length, 1, "The group item still contains one tab item"); |
michael@0 | 60 | |
michael@0 | 61 | closeGroupItem(groupItem, function() { |
michael@0 | 62 | hideTabView(finish); |
michael@0 | 63 | }); |
michael@0 | 64 | }); |
michael@0 | 65 | EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow); |
michael@0 | 66 | EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow); |
michael@0 | 67 | } |
michael@0 | 68 |