browser/components/tabview/test/browser_tabview_bug625424.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/tabview/test/browser_tabview_bug625424.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function test() {
     1.8 +  let win;
     1.9 +  let cw;
    1.10 +
    1.11 +  let getGroupItem = function (index) {
    1.12 +    return cw.GroupItems.groupItems[index];
    1.13 +  }
    1.14 +
    1.15 +  let newWindow = function (test) {
    1.16 +    newWindowWithTabView(function (tvwin) {
    1.17 +      registerCleanupFunction(function () {
    1.18 +        if (!tvwin.closed)
    1.19 +          tvwin.close();
    1.20 +      });
    1.21 +
    1.22 +      win = tvwin;
    1.23 +      cw = win.TabView.getContentWindow();
    1.24 +
    1.25 +      // setup group items
    1.26 +      getGroupItem(0).setSize(200, 200, true);
    1.27 +      createGroupItemWithBlankTabs(win, 200, 200, 300, 1);
    1.28 +
    1.29 +      test();
    1.30 +    });
    1.31 +  }
    1.32 +
    1.33 +  let assertNumberOfTabsInGroupItem = function (groupItem, numTabs) {
    1.34 +    is(groupItem.getChildren().length, numTabs,
    1.35 +        'there are ' + numTabs + ' tabs in this groupItem');
    1.36 +  }
    1.37 +
    1.38 +  let testDragOnHiddenGroup = function () {
    1.39 +    let groupItem = getGroupItem(1);
    1.40 +
    1.41 +    hideGroupItem(groupItem, function () {
    1.42 +      let drag = groupItem.getChild(0).container;
    1.43 +      let drop = groupItem.$undoContainer[0];
    1.44 +
    1.45 +      assertNumberOfTabsInGroupItem(groupItem, 1);
    1.46 +
    1.47 +      EventUtils.synthesizeMouseAtCenter(drag, {type: 'mousedown'}, cw);
    1.48 +      EventUtils.synthesizeMouseAtCenter(drop, {type: 'mousemove'}, cw);
    1.49 +      EventUtils.synthesizeMouseAtCenter(drop, {type: 'mouseup'}, cw);
    1.50 +
    1.51 +      assertNumberOfTabsInGroupItem(groupItem, 1);
    1.52 +
    1.53 +      win.close();
    1.54 +      newWindow(testDragOnVisibleGroup);
    1.55 +    });
    1.56 +  }
    1.57 +
    1.58 +  let testDragOnVisibleGroup = function () {
    1.59 +    let groupItem = getGroupItem(0);
    1.60 +    let drag = getGroupItem(1).getChild(0).container;
    1.61 +    let drop = groupItem.container;
    1.62 +
    1.63 +    assertNumberOfTabsInGroupItem(groupItem, 1);
    1.64 +
    1.65 +    EventUtils.synthesizeMouseAtCenter(drag, {type: 'mousedown'}, cw);
    1.66 +    EventUtils.synthesizeMouseAtCenter(drop, {type: 'mousemove'}, cw);
    1.67 +    EventUtils.synthesizeMouseAtCenter(drop, {type: 'mouseup'}, cw);
    1.68 +
    1.69 +    assertNumberOfTabsInGroupItem(groupItem, 2);
    1.70 +
    1.71 +    win.close();
    1.72 +    finish();
    1.73 +  }
    1.74 +
    1.75 +  waitForExplicitFinish();
    1.76 +  newWindow(testDragOnHiddenGroup);
    1.77 +}

mercurial