browser/components/tabview/test/browser_tabview_click_group.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 contentWindow;
     5 let groupItem;
     6 let groupItemId;
     8 function test() {
     9   waitForExplicitFinish();
    11   registerCleanupFunction(function() {
    12     contentWindow.gPrefBranch.clearUserPref("animate_zoom");
    13     let createdGroupItem = contentWindow.GroupItems.groupItem(groupItemId)
    14     if (createdGroupItem)
    15       closeGroupItem(createdGroupItem);
    16     hideTabView();
    17   });
    19   showTabView(function() {
    20     contentWindow = TabView.getContentWindow();
    21     groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200);
    22     groupItemId = groupItem.id;
    23     testMouseClickOnEmptyGroupItem();
    24   });
    25 }
    27 function testMouseClickOnEmptyGroupItem() {
    28   whenTabViewIsHidden(function() {
    29     is(groupItem.getChildren().length, 1, "The group item contains one tab item now");
    30     showTabView(testDraggingWithinGroupItem);
    31   });
    32   is(groupItem.getChildren().length, 0, "The group item doesn't contain any tab items");
    33   EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow);
    34   EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow);
    35 }
    37 function testDraggingWithinGroupItem() {
    38   let target = groupItem.container;
    39   contentWindow.gPrefBranch.setBoolPref("animate_zoom", false);
    41   // stimulate drag and drop
    42   EventUtils.sendMouseEvent( {type: "mousedown" }, target, contentWindow);
    43   EventUtils.synthesizeMouse(target, 10, 10, { type: "mousemove" }, contentWindow);
    44   ok(groupItem.isDragging, "The group item is being dragged")
    46   EventUtils.sendMouseEvent({ type: "mouseup" }, target, contentWindow);
    47   ok(!groupItem.isDragging, "The dragging is competely");
    49   executeSoon(function() {
    50     ok(TabView.isVisible(), "The tab view is still visible after dragging");
    51     contentWindow.gPrefBranch.clearUserPref("animate_zoom");
    53     testMouseClickOnGroupItem();
    54   });
    55 }
    57 function testMouseClickOnGroupItem() {
    58   whenTabViewIsHidden(function() {
    59     is(groupItem.getChildren().length, 1, "The group item still contains one tab item");
    61     closeGroupItem(groupItem, function() {
    62       hideTabView(finish);
    63     });
    64   });
    65   EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow);
    66   EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow);
    67 }

mercurial