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 fadeAwayUndoButtonDelay; |
michael@0 | 5 | let fadeAwayUndoButtonDuration; |
michael@0 | 6 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | |
michael@0 | 10 | window.addEventListener("tabviewshown", testCloseLastGroup, false); |
michael@0 | 11 | TabView.toggle(); |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | function testCloseLastGroup() { |
michael@0 | 15 | window.removeEventListener("tabviewshown", testCloseLastGroup, false); |
michael@0 | 16 | ok(TabView.isVisible(), "Tab View is visible"); |
michael@0 | 17 | |
michael@0 | 18 | let contentWindow = document.getElementById("tab-view").contentWindow; |
michael@0 | 19 | |
michael@0 | 20 | is(contentWindow.GroupItems.groupItems.length, 1, "Has one group only"); |
michael@0 | 21 | |
michael@0 | 22 | let groupItem = contentWindow.GroupItems.groupItems[0]; |
michael@0 | 23 | |
michael@0 | 24 | let checkExistence = function() { |
michael@0 | 25 | is(contentWindow.GroupItems.groupItems.length, 1, |
michael@0 | 26 | "Still has one group after delay"); |
michael@0 | 27 | |
michael@0 | 28 | EventUtils.sendMouseEvent( |
michael@0 | 29 | { type: "click" }, groupItem.$undoContainer[0], contentWindow); |
michael@0 | 30 | }; |
michael@0 | 31 | |
michael@0 | 32 | groupItem.addSubscriber("groupHidden", function onHidden() { |
michael@0 | 33 | groupItem.removeSubscriber("groupHidden", onHidden); |
michael@0 | 34 | // it should still stay after 3 ms. |
michael@0 | 35 | setTimeout(checkExistence, 3); |
michael@0 | 36 | }); |
michael@0 | 37 | |
michael@0 | 38 | groupItem.addSubscriber("groupShown", function onShown() { |
michael@0 | 39 | groupItem.removeSubscriber("groupShown", onShown); |
michael@0 | 40 | |
michael@0 | 41 | let endGame = function() { |
michael@0 | 42 | window.removeEventListener("tabviewhidden", endGame, false); |
michael@0 | 43 | ok(!TabView.isVisible(), "Tab View is hidden"); |
michael@0 | 44 | |
michael@0 | 45 | groupItem.fadeAwayUndoButtonDelay = fadeAwayUndoButtonDelay; |
michael@0 | 46 | groupItem.fadeAwayUndoButtonDuration = fadeAwayUndoButtonDuration; |
michael@0 | 47 | |
michael@0 | 48 | finish(); |
michael@0 | 49 | }; |
michael@0 | 50 | window.addEventListener("tabviewhidden", endGame, false); |
michael@0 | 51 | |
michael@0 | 52 | TabView.toggle(); |
michael@0 | 53 | }); |
michael@0 | 54 | |
michael@0 | 55 | let closeButton = groupItem.container.getElementsByClassName("close"); |
michael@0 | 56 | ok(closeButton, "Group item close button exists"); |
michael@0 | 57 | |
michael@0 | 58 | // store the original values |
michael@0 | 59 | fadeAwayUndoButtonDelay = groupItem.fadeAwayUndoButtonDelay; |
michael@0 | 60 | fadeAwayUndoButtonDuration = groupItem.fadeAwayUndoButtonDuration; |
michael@0 | 61 | |
michael@0 | 62 | // set both fade away delay and duration to 1ms |
michael@0 | 63 | groupItem.fadeAwayUndoButtonDelay = 1; |
michael@0 | 64 | groupItem.fadeAwayUndoButtonDuration = 1; |
michael@0 | 65 | |
michael@0 | 66 | EventUtils.sendMouseEvent({ type: "click" }, closeButton[0], contentWindow); |
michael@0 | 67 | } |