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.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 function test() {
5 let cw;
6 let groupItem;
8 let getTabItemAspect = function (tabItem) {
9 let bounds = cw.iQ('.thumb', tabItem.container).bounds();
10 let padding = cw.TabItems.tabItemPadding;
11 return (bounds.height + padding.y) / (bounds.width + padding.x);
12 }
14 let getAspectRange = function () {
15 let aspect = cw.TabItems.tabAspect;
16 let variance = aspect / 100 * 1.5;
17 return new cw.Range(aspect - variance, aspect + variance);
18 }
20 let dragTabItem = function (tabItem) {
21 let doc = cw.document.documentElement;
22 let tabItem = groupItem.getChild(0);
23 let container = tabItem.container;
24 let aspectRange = getAspectRange();
26 EventUtils.synthesizeMouseAtCenter(container, {type: "mousedown"}, cw);
27 for (let x = 200; x <= 400; x += 100)
28 EventUtils.synthesizeMouse(doc, x, 100, {type: "mousemove"}, cw);
29 ok(aspectRange.contains(getTabItemAspect(tabItem)), "tabItem's aspect is correct");
31 ok(!groupItem.getBounds().intersects(tabItem.getBounds()), "tabItem was moved out of group bounds");
32 ok(!tabItem.parent, "tabItem is orphaned");
34 EventUtils.synthesizeMouseAtCenter(container, {type: "mouseup"}, cw);
35 ok(aspectRange.contains(getTabItemAspect(tabItem)), "tabItem's aspect is correct");
36 }
38 let testDragOutOfStackedGroup = function () {
39 dragTabItem();
41 let secondGroup = cw.GroupItems.groupItems[1];
42 closeGroupItem(secondGroup, testDragOutOfExpandedStackedGroup);
43 }
45 let testDragOutOfExpandedStackedGroup = function () {
46 groupItem.addSubscriber("expanded", function onExpanded() {
47 groupItem.removeSubscriber("expanded", onExpanded);
48 dragTabItem();
49 });
51 groupItem.addSubscriber("collapsed", function onCollapsed() {
52 groupItem.removeSubscriber("collapsed", onCollapsed);
54 let secondGroup = cw.GroupItems.groupItems[1];
55 closeGroupItem(secondGroup, function () hideTabView(finishTest));
56 });
58 groupItem.expand();
59 }
61 let finishTest = function () {
62 is(cw.GroupItems.groupItems.length, 1, "there is one groupItem");
63 is(gBrowser.tabs.length, 1, "there is one tab");
64 ok(!TabView.isVisible(), "tabview is hidden");
66 finish();
67 }
69 waitForExplicitFinish();
71 newWindowWithTabView(function (win) {
72 registerCleanupFunction(function () win.close());
74 cw = win.TabView.getContentWindow();
76 groupItem = cw.GroupItems.groupItems[0];
77 groupItem.setSize(200, 200, true);
79 for (let i = 0; i < 9; i++)
80 win.gBrowser.addTab();
82 ok(groupItem.isStacked(), "groupItem is stacked");
83 testDragOutOfStackedGroup();
84 });
85 }