michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let fadeAwayUndoButtonDelay; michael@0: let fadeAwayUndoButtonDuration; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: window.addEventListener("tabviewshown", testCloseLastGroup, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: function testCloseLastGroup() { michael@0: window.removeEventListener("tabviewshown", testCloseLastGroup, false); michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: let contentWindow = document.getElementById("tab-view").contentWindow; michael@0: michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "Has one group only"); michael@0: michael@0: let groupItem = contentWindow.GroupItems.groupItems[0]; michael@0: michael@0: let checkExistence = function() { michael@0: is(contentWindow.GroupItems.groupItems.length, 1, michael@0: "Still has one group after delay"); michael@0: michael@0: EventUtils.sendMouseEvent( michael@0: { type: "click" }, groupItem.$undoContainer[0], contentWindow); michael@0: }; michael@0: michael@0: groupItem.addSubscriber("groupHidden", function onHidden() { michael@0: groupItem.removeSubscriber("groupHidden", onHidden); michael@0: // it should still stay after 3 ms. michael@0: setTimeout(checkExistence, 3); michael@0: }); michael@0: michael@0: groupItem.addSubscriber("groupShown", function onShown() { michael@0: groupItem.removeSubscriber("groupShown", onShown); michael@0: michael@0: let endGame = function() { michael@0: window.removeEventListener("tabviewhidden", endGame, false); michael@0: ok(!TabView.isVisible(), "Tab View is hidden"); michael@0: michael@0: groupItem.fadeAwayUndoButtonDelay = fadeAwayUndoButtonDelay; michael@0: groupItem.fadeAwayUndoButtonDuration = fadeAwayUndoButtonDuration; michael@0: michael@0: finish(); michael@0: }; michael@0: window.addEventListener("tabviewhidden", endGame, false); michael@0: michael@0: TabView.toggle(); michael@0: }); michael@0: michael@0: let closeButton = groupItem.container.getElementsByClassName("close"); michael@0: ok(closeButton, "Group item close button exists"); michael@0: michael@0: // store the original values michael@0: fadeAwayUndoButtonDelay = groupItem.fadeAwayUndoButtonDelay; michael@0: fadeAwayUndoButtonDuration = groupItem.fadeAwayUndoButtonDuration; michael@0: michael@0: // set both fade away delay and duration to 1ms michael@0: groupItem.fadeAwayUndoButtonDelay = 1; michael@0: groupItem.fadeAwayUndoButtonDuration = 1; michael@0: michael@0: EventUtils.sendMouseEvent({ type: "click" }, closeButton[0], contentWindow); michael@0: }