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

mercurial