browser/components/tabview/test/browser_tabview_bug626368.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_bug626368.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     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 createGroupItem = function () {
    1.11 +    let bounds = new cw.Rect(20, 20, 150, 150);
    1.12 +    let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true});
    1.13 +
    1.14 +    cw.UI.setActive(groupItem);
    1.15 +    gBrowser.loadOneTab('about:blank', {inBackground: true});
    1.16 +
    1.17 +    return groupItem;
    1.18 +  }
    1.19 +
    1.20 +  let synthesizeMiddleMouseDrag = function (tabContainer, width) {
    1.21 +    EventUtils.synthesizeMouseAtCenter(tabContainer,
    1.22 +        {type: 'mousedown', button: 1}, cw);
    1.23 +    let rect = tabContainer.getBoundingClientRect();
    1.24 +    EventUtils.synthesizeMouse(tabContainer, rect.width / 2 + width,
    1.25 +        rect.height / 2, {type: 'mousemove', button: 1}, cw);
    1.26 +    EventUtils.synthesizeMouse(tabContainer, rect.width / 2 + width,
    1.27 +        rect.height / 2, {type: 'mouseup', button: 1}, cw);
    1.28 +  }
    1.29 +
    1.30 +  let testDragAndDropWithMiddleMouseButton = function () {
    1.31 +    let groupItem = createGroupItem();
    1.32 +    let tabItem = groupItem.getChild(0);
    1.33 +    let tabContainer = tabItem.container;
    1.34 +    let bounds = tabItem.getBounds();
    1.35 +
    1.36 +    // try to drag and move the mouse out of the tab
    1.37 +    synthesizeMiddleMouseDrag(tabContainer, 200);
    1.38 +    is(groupItem.getChild(0), tabItem, 'tabItem was not closed');
    1.39 +    ok(bounds.equals(tabItem.getBounds()), 'bounds did not change');
    1.40 +
    1.41 +    // try to drag and let the mouse stay within tab bounds
    1.42 +    synthesizeMiddleMouseDrag(tabContainer, 10);
    1.43 +    ok(!groupItem.getChild(0), 'tabItem was closed');
    1.44 +
    1.45 +    hideTabView(finish);
    1.46 +  }
    1.47 +
    1.48 +  waitForExplicitFinish();
    1.49 +
    1.50 +  showTabView(function () {
    1.51 +    cw = TabView.getContentWindow();
    1.52 +    afterAllTabsLoaded(testDragAndDropWithMiddleMouseButton);
    1.53 +  });
    1.54 +}

mercurial