browser/components/tabview/test/browser_tabview_bug663421.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_bug663421.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     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, cw, groupItem;
     1.9 +
    1.10 +  function checkNumberOfGroupItems(num) {
    1.11 +    is(cw.GroupItems.groupItems.length, num, "there are " + num + " groupItems");
    1.12 +  }
    1.13 +
    1.14 +  function next() {
    1.15 +    if (tests.length)
    1.16 +      tests.shift()();
    1.17 +    else
    1.18 +      finish();
    1.19 +  }
    1.20 +
    1.21 +  // Empty groups should not be closed when toggling Panorama on and off.
    1.22 +  function test1() {
    1.23 +    hideTabView(function () {
    1.24 +      showTabView(function () {
    1.25 +        checkNumberOfGroupItems(2);
    1.26 +        next();
    1.27 +      }, win);
    1.28 +    }, win);
    1.29 +  }
    1.30 +
    1.31 +  // Groups should not be closed when their last tab is closed outside of Panorama.
    1.32 +  function test2() {
    1.33 +    whenTabViewIsHidden(function () {
    1.34 +      whenTabViewIsShown(function () {
    1.35 +        checkNumberOfGroupItems(2);
    1.36 +        next();
    1.37 +      }, win);
    1.38 +
    1.39 +      win.gBrowser.removeTab(win.gBrowser.selectedTab);
    1.40 +    }, win);
    1.41 +
    1.42 +    groupItem.newTab();
    1.43 +  }
    1.44 +
    1.45 +  // Groups should be closed when their last tab is closed.
    1.46 +  function test3() {
    1.47 +    whenTabViewIsHidden(function () {
    1.48 +      showTabView(function () {
    1.49 +        let tab = win.gBrowser.tabs[1];
    1.50 +        tab._tabViewTabItem.close();
    1.51 +        checkNumberOfGroupItems(1);
    1.52 +        next();
    1.53 +      }, win);
    1.54 +    }, win);
    1.55 +
    1.56 +    win.gBrowser.addTab();
    1.57 +  }
    1.58 +
    1.59 +  // Groups should be closed when their last tab is dragged out.
    1.60 +  function test4() {
    1.61 +    groupItem = createGroupItemWithBlankTabs(win, 200, 200, 20, 1);
    1.62 +    checkNumberOfGroupItems(2);
    1.63 +
    1.64 +    let tab = win.gBrowser.tabs[1];
    1.65 +    let target = tab._tabViewTabItem.container;
    1.66 +
    1.67 +    waitForFocus(function () {
    1.68 +      EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
    1.69 +      EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw);
    1.70 +      EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw);
    1.71 +
    1.72 +      checkNumberOfGroupItems(2);
    1.73 +      closeGroupItem(cw.GroupItems.groupItems[1], next);
    1.74 +    }, win);
    1.75 +  }
    1.76 +
    1.77 +  let tests = [test1, test2, test3, test4];
    1.78 +
    1.79 +  waitForExplicitFinish();
    1.80 +
    1.81 +  newWindowWithTabView(function (aWin) {
    1.82 +    registerCleanupFunction(function () aWin.close());
    1.83 +
    1.84 +    win = aWin;
    1.85 +    cw = win.TabView.getContentWindow();
    1.86 +    groupItem = createEmptyGroupItem(cw, 200, 200, 20);
    1.87 +
    1.88 +    checkNumberOfGroupItems(2);
    1.89 +    next();
    1.90 +  });
    1.91 +}

mercurial