browser/components/tabview/test/browser_tabview_bug654721.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 let state = {
michael@0 5 windows: [{
michael@0 6 tabs: [{
michael@0 7 entries: [{ url: "about:mozilla" }],
michael@0 8 hidden: true,
michael@0 9 extData: {"tabview-tab": '{"url":"about:mozilla","groupID":1,"bounds":{"left":20,"top":20,"width":20,"height":20}}'}
michael@0 10 },{
michael@0 11 entries: [{ url: "about:mozilla" }],
michael@0 12 hidden: false,
michael@0 13 // this is an existing orphan tab from a previous Fx version and we want
michael@0 14 // to make sure this gets transformed into a group
michael@0 15 extData: {"tabview-tab": '{"url":"about:mozilla","groupID":0,"bounds":{"left":300,"top":300,"width":200,"height":200}}'},
michael@0 16 }],
michael@0 17 selected: 2,
michael@0 18 extData: {
michael@0 19 "tabview-groups": '{"nextID":3,"activeGroupId":1}',
michael@0 20 "tabview-group":
michael@0 21 '{"1":{"bounds":{"left":20,"top":20,"width":200,"height":200},"id":1}}'
michael@0 22 }
michael@0 23 }]
michael@0 24 };
michael@0 25
michael@0 26 function test() {
michael@0 27 waitForExplicitFinish();
michael@0 28
michael@0 29 newWindowWithState(state, function (win) {
michael@0 30 registerCleanupFunction(function () win.close());
michael@0 31
michael@0 32 showTabView(function () {
michael@0 33 let cw = win.TabView.getContentWindow();
michael@0 34 let groupItems = cw.GroupItems.groupItems;
michael@0 35 is(groupItems.length, 2, "two groupItems");
michael@0 36
michael@0 37 let [group1, group2] = groupItems;
michael@0 38
michael@0 39 let bounds1 = new cw.Rect(20, 20, 200, 200);
michael@0 40 ok(bounds1.equals(group1.getBounds()), "bounds for group1 are correct");
michael@0 41
michael@0 42 let bounds2 = new cw.Rect(300, 300, 200, 200);
michael@0 43 ok(bounds2.equals(group2.getBounds()), "bounds for group2 are correct");
michael@0 44
michael@0 45 cw.UI.setActive(group2);
michael@0 46 win.gBrowser.loadOneTab("about:blank", {inBackground: true});
michael@0 47
michael@0 48 let tabItem = group2.getChild(0);
michael@0 49 let target = tabItem.container;
michael@0 50
michael@0 51 EventUtils.synthesizeMouse(target, 10, 10, {type: 'mousedown'}, cw);
michael@0 52 EventUtils.synthesizeMouse(target, 20, -200, {type: 'mousemove'}, cw);
michael@0 53 EventUtils.synthesizeMouse(target, 10, 10, {type: 'mouseup'}, cw);
michael@0 54
michael@0 55 is(groupItems.length, 3, "three groupItems");
michael@0 56
michael@0 57 let latestGroup = groupItems[groupItems.length - 1];
michael@0 58 is(tabItem, latestGroup.getChild(0), "dragged tab has its own groupItem");
michael@0 59
michael@0 60 finish();
michael@0 61 }, win);
michael@0 62 });
michael@0 63 }

mercurial