browser/components/tabview/test/browser_tabview_bug607108.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_bug607108.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     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 cw;
     1.9 +
    1.10 +  let assertNumberOfGroupItems = function (num) {
    1.11 +    let groupItems = cw.GroupItems.groupItems;
    1.12 +    is(groupItems.length, num, "number of groupItems is " + num);
    1.13 +  };
    1.14 +
    1.15 +  let dragTabOutOfGroup = function (groupItem) {
    1.16 +    let tabItem = groupItem.getChild(0);
    1.17 +    let target = tabItem.container;
    1.18 +
    1.19 +    EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
    1.20 +    EventUtils.synthesizeMouse(target, 400, 100, {type: "mousemove"}, cw);
    1.21 +    EventUtils.synthesizeMouseAtCenter(target, {type: "mouseup"}, cw);
    1.22 +  };
    1.23 +
    1.24 +  let testCreateGroup = function (callback) {
    1.25 +    let content = cw.document.getElementById("content");
    1.26 +
    1.27 +    // drag to create a new group
    1.28 +    EventUtils.synthesizeMouse(content, 400, 50, {type: "mousedown"}, cw);
    1.29 +    EventUtils.synthesizeMouse(content, 500, 250, {type: "mousemove"}, cw);
    1.30 +    EventUtils.synthesizeMouse(content, 500, 250, {type: "mouseup"}, cw);
    1.31 +
    1.32 +    assertNumberOfGroupItems(2);
    1.33 +
    1.34 +    // enter a title for the new group
    1.35 +    EventUtils.synthesizeKey("t", {}, cw);
    1.36 +    EventUtils.synthesizeKey("VK_RETURN", {}, cw);
    1.37 +
    1.38 +
    1.39 +    let groupItem = cw.GroupItems.groupItems[1];
    1.40 +    is(groupItem.getTitle(), "t", "new groupItem's title is correct");
    1.41 +
    1.42 +    closeGroupItem(groupItem, callback);
    1.43 +  };
    1.44 +
    1.45 +  let testDragOutOfGroup = function (callback) {
    1.46 +    assertNumberOfGroupItems(1);
    1.47 +
    1.48 +    let groupItem = cw.GroupItems.groupItems[0];
    1.49 +    dragTabOutOfGroup(groupItem);
    1.50 +    assertNumberOfGroupItems(2);
    1.51 +
    1.52 +    // enter a title for the new group
    1.53 +    EventUtils.synthesizeKey("t", {}, cw);
    1.54 +    EventUtils.synthesizeKey("VK_RETURN", {}, cw);
    1.55 +
    1.56 +    groupItem = cw.GroupItems.groupItems[1];
    1.57 +    is(groupItem.getTitle(), "t", "new groupItem's title is correct");
    1.58 +    closeGroupItem(groupItem, callback);
    1.59 +  };
    1.60 +
    1.61 +  let onLoad = function (win) {
    1.62 +    registerCleanupFunction(function () win.close());
    1.63 +
    1.64 +    for (let i = 0; i < 2; i++)
    1.65 +      win.gBrowser.addTab();
    1.66 +  };
    1.67 +
    1.68 +  let onShow = function (win) {
    1.69 +    cw = win.TabView.getContentWindow();
    1.70 +    assertNumberOfGroupItems(1);
    1.71 +
    1.72 +    let groupItem = cw.GroupItems.groupItems[0];
    1.73 +    groupItem.setSize(200, 600, true);
    1.74 +
    1.75 +    waitForFocus(function () {
    1.76 +      testCreateGroup(function () {
    1.77 +        testDragOutOfGroup(finish);
    1.78 +      });
    1.79 +    }, cw);
    1.80 +  };
    1.81 +
    1.82 +  waitForExplicitFinish();
    1.83 +  newWindowWithTabView(onShow, onLoad);
    1.84 +}

mercurial