browser/components/customizableui/test/browser_938980_navbar_collapsed.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 let bookmarksToolbar = document.getElementById("PersonalToolbar");
     8 let navbar = document.getElementById("nav-bar");
     9 let tabsToolbar = document.getElementById("TabsToolbar");
    11 // Customization reset should restore visibility to default-visible toolbars.
    12 add_task(function() {
    13   is(navbar.collapsed, false, "Test should start with navbar visible");
    14   setToolbarVisibility(navbar, false);
    15   is(navbar.collapsed, true, "navbar should be hidden now");
    17   yield resetCustomization();
    19   is(navbar.collapsed, false, "Customization reset should restore visibility to the navbar");
    20 });
    22 // Customization reset should restore collapsed-state to default-collapsed toolbars.
    23 add_task(function() {
    24   ok(CustomizableUI.inDefaultState, "Everything should be in its default state");
    26   is(bookmarksToolbar.collapsed, true, "Test should start with bookmarks toolbar collapsed");
    27   is(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should have height=0");
    28   isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height");
    29   is(navbar.collapsed, false, "The nav-bar should be shown by default");
    31   setToolbarVisibility(bookmarksToolbar, true);
    32   setToolbarVisibility(navbar, false);
    33   isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should be visible now");
    34   is(navbar.getBoundingClientRect().height, 1, "navbar should have a height=1 (due to border)");
    35   is(CustomizableUI.inDefaultState, false, "Should no longer be in default state");
    37   yield startCustomizing();
    38   gCustomizeMode.reset();
    39   yield waitForCondition(function() !gCustomizeMode.resetting);
    40   yield endCustomizing();
    42   is(bookmarksToolbar.collapsed, true, "Customization reset should restore collapsed-state to the bookmarks toolbar");
    43   isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height");
    44   is(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should have height=0 after reset");
    45   ok(CustomizableUI.inDefaultState, "Everything should be back to default state");
    46 });
    48 // Check that the menubar will be collapsed by resetting, if the platform supports it.
    49 add_task(function() {
    50   let menubar = document.getElementById("toolbar-menubar");
    51   const canMenubarCollapse = CustomizableUI.isToolbarDefaultCollapsed(menubar.id);
    52   if (!canMenubarCollapse) {
    53     return;
    54   }
    55   ok(CustomizableUI.inDefaultState, "Everything should be in its default state");
    57   is(menubar.getBoundingClientRect().height, 0, "menubar should be hidden by default");
    58   setToolbarVisibility(menubar, true);
    59   isnot(menubar.getBoundingClientRect().height, 0, "menubar should be visible now");
    61   yield startCustomizing();
    62   gCustomizeMode.reset();
    63   yield waitForCondition(function() !gCustomizeMode.resetting);
    65   is(menubar.getAttribute("autohide"), "true", "The menubar should have autohide=true after reset in customization mode");
    66   is(menubar.getBoundingClientRect().height, 0, "The menubar should have height=0 after reset in customization mode");
    68   yield endCustomizing();
    70   is(menubar.getAttribute("autohide"), "true", "The menubar should have autohide=true after reset");
    71   is(menubar.getBoundingClientRect().height, 0, "The menubar should have height=0 after reset");
    72 });
    74 // Customization reset should restore collapsed-state to default-collapsed toolbars.
    75 add_task(function() {
    76   ok(CustomizableUI.inDefaultState, "Everything should be in its default state");
    77   is(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should have height=0");
    78   isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height");
    80   setToolbarVisibility(bookmarksToolbar, true);
    81   isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should be visible now");
    82   is(CustomizableUI.inDefaultState, false, "Should no longer be in default state");
    84   yield startCustomizing();
    86   isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should be visible before reset");
    87   isnot(navbar.getBoundingClientRect().height, 0, "The navbar should be visible before reset");
    88   isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height");
    90   gCustomizeMode.reset();
    91   yield waitForCondition(function() !gCustomizeMode.resetting);
    93   is(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should have height=0 after reset");
    94   isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height");
    95   isnot(navbar.getBoundingClientRect().height, 0, "The navbar should still be visible after reset");
    96   ok(CustomizableUI.inDefaultState, "Everything should be back to default state");
    97   yield endCustomizing();
    98 });
   100 // Check that the menubar will be collapsed by resetting, if the platform supports it.
   101 add_task(function() {
   102   let menubar = document.getElementById("toolbar-menubar");
   103   const canMenubarCollapse = CustomizableUI.isToolbarDefaultCollapsed(menubar.id);
   104   if (!canMenubarCollapse) {
   105     return;
   106   }
   107   ok(CustomizableUI.inDefaultState, "Everything should be in its default state");
   108   yield startCustomizing();
   109   let resetButton = document.getElementById("customization-reset-button");
   110   is(resetButton.disabled, true, "The reset button should be disabled when in default state");
   112   setToolbarVisibility(menubar, true);
   113   is(resetButton.disabled, false, "The reset button should be enabled when not in default state")
   114   ok(!CustomizableUI.inDefaultState, "No longer in default state when the menubar is shown");
   116   yield gCustomizeMode.reset();
   118   is(resetButton.disabled, true, "The reset button should be disabled when in default state");
   119   ok(CustomizableUI.inDefaultState, "Everything should be in its default state");
   121   yield endCustomizing();
   122 });

mercurial