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.

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

mercurial