browser/components/tabview/test/browser_tabview_bug595943.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 // Show TabView
michael@0 8 window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
michael@0 9 TabView.toggle();
michael@0 10 }
michael@0 11
michael@0 12 function onTabViewWindowLoaded() {
michael@0 13 window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
michael@0 14 ok(TabView.isVisible(), "Tab View is visible");
michael@0 15
michael@0 16 let contentWindow = document.getElementById("tab-view").contentWindow;
michael@0 17
michael@0 18 // establish initial state
michael@0 19 is(contentWindow.GroupItems.groupItems.length, 1, "we start with one group (the default)");
michael@0 20 is(gBrowser.tabs.length, 1, "we start with one tab");
michael@0 21
michael@0 22 let originalTab = gBrowser.tabs[0];
michael@0 23 ok(contentWindow.GroupItems.groupItems[0]._children[0].tab == originalTab,
michael@0 24 "the original tab is in the original group");
michael@0 25
michael@0 26 // create a second group
michael@0 27 let box = new contentWindow.Rect(20, 20, 180, 180);
michael@0 28 let groupItem = new contentWindow.GroupItem([], { bounds: box });
michael@0 29 is(contentWindow.GroupItems.groupItems.length, 2, "we now have two groups");
michael@0 30 contentWindow.UI.setActive(groupItem);
michael@0 31
michael@0 32 // create a second tab
michael@0 33 let normalXulTab = gBrowser.loadOneTab("about:blank");
michael@0 34 is(gBrowser.tabs.length, 2, "we now have two tabs");
michael@0 35 is(groupItem._children.length, 1, "the new tab was added to the group");
michael@0 36
michael@0 37 // create a third tab
michael@0 38 let appXulTab = gBrowser.loadOneTab("about:blank");
michael@0 39 is(gBrowser.tabs.length, 3, "we now have three tabs");
michael@0 40 gBrowser.pinTab(appXulTab);
michael@0 41 is(groupItem._children.length, 1, "the app tab is not in the group");
michael@0 42
michael@0 43 // We now have two groups with one tab each, plus an app tab.
michael@0 44 // Click into one of the tabs, close it and make sure we don't go back to Tab View.
michael@0 45 function onTabViewHidden() {
michael@0 46 window.removeEventListener("tabviewhidden", onTabViewHidden, false);
michael@0 47 ok(!TabView.isVisible(), "Tab View is hidden because we clicked on the app tab");
michael@0 48
michael@0 49 // Remove the tab we're looking at.
michael@0 50 gBrowser.removeTab(normalXulTab);
michael@0 51
michael@0 52 // Make sure we haven't returned to TabView; this is the crux of this test
michael@0 53 ok(!TabView.isVisible(), "Tab View remains hidden");
michael@0 54
michael@0 55 // clean up
michael@0 56 gBrowser.selectedTab = originalTab;
michael@0 57
michael@0 58 gBrowser.unpinTab(appXulTab);
michael@0 59 gBrowser.removeTab(appXulTab);
michael@0 60
michael@0 61 ok(groupItem.closeIfEmpty(), "the second group was empty");
michael@0 62
michael@0 63 // Verify ending state
michael@0 64 is(gBrowser.tabs.length, 1, "we finish with one tab");
michael@0 65 is(contentWindow.GroupItems.groupItems.length, 1,
michael@0 66 "we finish with one group");
michael@0 67 ok(!TabView.isVisible(), "we finish with Tab View hidden");
michael@0 68
michael@0 69 finish();
michael@0 70 }
michael@0 71
michael@0 72 window.addEventListener("tabviewhidden", onTabViewHidden, false);
michael@0 73 EventUtils.sendMouseEvent({ type: "mousedown" }, normalXulTab._tabViewTabItem.container, contentWindow);
michael@0 74 EventUtils.sendMouseEvent({ type: "mouseup" }, normalXulTab._tabViewTabItem.container, contentWindow);
michael@0 75 }

mercurial