browser/components/tabview/test/browser_tabview_bug595930.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 waitForExplicitFinish();
michael@0 6
michael@0 7 window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
michael@0 8 TabView.toggle();
michael@0 9 }
michael@0 10
michael@0 11 function onTabViewWindowLoaded() {
michael@0 12 window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
michael@0 13
michael@0 14 ok(TabView.isVisible(), "Tab View is visible");
michael@0 15
michael@0 16 let [originalTab] = gBrowser.visibleTabs;
michael@0 17 let contentWindow = document.getElementById("tab-view").contentWindow;
michael@0 18
michael@0 19 // create group which we'll close
michael@0 20 let box1 = new contentWindow.Rect(310, 10, 300, 300);
michael@0 21 let group1 = new contentWindow.GroupItem([], { bounds: box1 });
michael@0 22 ok(group1.isEmpty(), "This group is empty");
michael@0 23 contentWindow.UI.setActive(group1);
michael@0 24 let tab1 = gBrowser.loadOneTab("about:blank#1", {inBackground: true});
michael@0 25 let tab1Item = tab1._tabViewTabItem;
michael@0 26 ok(group1.getChildren().some(function(child) child == tab1Item), "The tab was made in our new group");
michael@0 27 is(group1.getChildren().length, 1, "Only one tab in the first group");
michael@0 28
michael@0 29 group1.addSubscriber("close", function onClose() {
michael@0 30 group1.removeSubscriber("close", onClose);
michael@0 31
michael@0 32 let onTabViewHidden = function() {
michael@0 33 window.removeEventListener("tabviewhidden", onTabViewHidden, false);
michael@0 34 // assert that we're no longer in tab view
michael@0 35 ok(!TabView.isVisible(), "Tab View is hidden");
michael@0 36 finish();
michael@0 37 };
michael@0 38 window.addEventListener("tabviewhidden", onTabViewHidden, false);
michael@0 39
michael@0 40 // delay to give time for hidden group DOM element to be removed so
michael@0 41 // the appropriate group would get selected when the key
michael@0 42 // combination is pressed
michael@0 43 executeSoon(function() {
michael@0 44 EventUtils.synthesizeKey("e", {accelKey : true, shiftKey: true}, contentWindow);
michael@0 45 });
michael@0 46 });
michael@0 47
michael@0 48 hideGroupItem(group1, function () {
michael@0 49 // close undo group
michael@0 50 let closeButton = group1.$undoContainer.find(".close");
michael@0 51 EventUtils.sendMouseEvent(
michael@0 52 { type: "click" }, closeButton[0], contentWindow);
michael@0 53 });
michael@0 54 }
michael@0 55

mercurial