browser/components/tabview/test/browser_tabview_bug595943.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 function test() {
     5   waitForExplicitFinish();
     7   // Show TabView
     8   window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
     9   TabView.toggle();
    10 }
    12 function onTabViewWindowLoaded() {
    13   window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
    14   ok(TabView.isVisible(), "Tab View is visible");
    16   let contentWindow = document.getElementById("tab-view").contentWindow;
    18   // establish initial state
    19   is(contentWindow.GroupItems.groupItems.length, 1, "we start with one group (the default)"); 
    20   is(gBrowser.tabs.length, 1, "we start with one tab");
    22   let originalTab = gBrowser.tabs[0];
    23   ok(contentWindow.GroupItems.groupItems[0]._children[0].tab == originalTab, 
    24     "the original tab is in the original group");
    26   // create a second group 
    27   let box = new contentWindow.Rect(20, 20, 180, 180);
    28   let groupItem = new contentWindow.GroupItem([], { bounds: box });
    29   is(contentWindow.GroupItems.groupItems.length, 2, "we now have two groups");
    30   contentWindow.UI.setActive(groupItem);
    32   // create a second tab
    33   let normalXulTab = gBrowser.loadOneTab("about:blank");
    34   is(gBrowser.tabs.length, 2, "we now have two tabs");
    35   is(groupItem._children.length, 1, "the new tab was added to the group");
    37   // create a third tab
    38   let appXulTab = gBrowser.loadOneTab("about:blank");
    39   is(gBrowser.tabs.length, 3, "we now have three tabs");
    40   gBrowser.pinTab(appXulTab);
    41   is(groupItem._children.length, 1, "the app tab is not in the group");
    43   // We now have two groups with one tab each, plus an app tab.
    44   // Click into one of the tabs, close it and make sure we don't go back to Tab View.
    45   function onTabViewHidden() {
    46     window.removeEventListener("tabviewhidden", onTabViewHidden, false);
    47     ok(!TabView.isVisible(), "Tab View is hidden because we clicked on the app tab");
    49     // Remove the tab we're looking at.
    50     gBrowser.removeTab(normalXulTab);  
    52     // Make sure we haven't returned to TabView; this is the crux of this test
    53     ok(!TabView.isVisible(), "Tab View remains hidden");
    55     // clean up
    56     gBrowser.selectedTab = originalTab;
    58     gBrowser.unpinTab(appXulTab);
    59     gBrowser.removeTab(appXulTab);
    61     ok(groupItem.closeIfEmpty(), "the second group was empty");
    63     // Verify ending state
    64     is(gBrowser.tabs.length, 1, "we finish with one tab");
    65     is(contentWindow.GroupItems.groupItems.length, 1,
    66        "we finish with one group");
    67     ok(!TabView.isVisible(), "we finish with Tab View hidden");
    69     finish();
    70   }
    72   window.addEventListener("tabviewhidden", onTabViewHidden, false);
    73   EventUtils.sendMouseEvent({ type: "mousedown" }, normalXulTab._tabViewTabItem.container, contentWindow);
    74   EventUtils.sendMouseEvent({ type: "mouseup" }, normalXulTab._tabViewTabItem.container, contentWindow);
    75 }

mercurial