1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_938980_navbar_collapsed.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,122 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +let bookmarksToolbar = document.getElementById("PersonalToolbar"); 1.11 +let navbar = document.getElementById("nav-bar"); 1.12 +let tabsToolbar = document.getElementById("TabsToolbar"); 1.13 + 1.14 +// Customization reset should restore visibility to default-visible toolbars. 1.15 +add_task(function() { 1.16 + is(navbar.collapsed, false, "Test should start with navbar visible"); 1.17 + setToolbarVisibility(navbar, false); 1.18 + is(navbar.collapsed, true, "navbar should be hidden now"); 1.19 + 1.20 + yield resetCustomization(); 1.21 + 1.22 + is(navbar.collapsed, false, "Customization reset should restore visibility to the navbar"); 1.23 +}); 1.24 + 1.25 +// Customization reset should restore collapsed-state to default-collapsed toolbars. 1.26 +add_task(function() { 1.27 + ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); 1.28 + 1.29 + is(bookmarksToolbar.collapsed, true, "Test should start with bookmarks toolbar collapsed"); 1.30 + is(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should have height=0"); 1.31 + isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); 1.32 + is(navbar.collapsed, false, "The nav-bar should be shown by default"); 1.33 + 1.34 + setToolbarVisibility(bookmarksToolbar, true); 1.35 + setToolbarVisibility(navbar, false); 1.36 + isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should be visible now"); 1.37 + is(navbar.getBoundingClientRect().height, 1, "navbar should have a height=1 (due to border)"); 1.38 + is(CustomizableUI.inDefaultState, false, "Should no longer be in default state"); 1.39 + 1.40 + yield startCustomizing(); 1.41 + gCustomizeMode.reset(); 1.42 + yield waitForCondition(function() !gCustomizeMode.resetting); 1.43 + yield endCustomizing(); 1.44 + 1.45 + is(bookmarksToolbar.collapsed, true, "Customization reset should restore collapsed-state to the bookmarks toolbar"); 1.46 + isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); 1.47 + is(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should have height=0 after reset"); 1.48 + ok(CustomizableUI.inDefaultState, "Everything should be back to default state"); 1.49 +}); 1.50 + 1.51 +// Check that the menubar will be collapsed by resetting, if the platform supports it. 1.52 +add_task(function() { 1.53 + let menubar = document.getElementById("toolbar-menubar"); 1.54 + const canMenubarCollapse = CustomizableUI.isToolbarDefaultCollapsed(menubar.id); 1.55 + if (!canMenubarCollapse) { 1.56 + return; 1.57 + } 1.58 + ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); 1.59 + 1.60 + is(menubar.getBoundingClientRect().height, 0, "menubar should be hidden by default"); 1.61 + setToolbarVisibility(menubar, true); 1.62 + isnot(menubar.getBoundingClientRect().height, 0, "menubar should be visible now"); 1.63 + 1.64 + yield startCustomizing(); 1.65 + gCustomizeMode.reset(); 1.66 + yield waitForCondition(function() !gCustomizeMode.resetting); 1.67 + 1.68 + is(menubar.getAttribute("autohide"), "true", "The menubar should have autohide=true after reset in customization mode"); 1.69 + is(menubar.getBoundingClientRect().height, 0, "The menubar should have height=0 after reset in customization mode"); 1.70 + 1.71 + yield endCustomizing(); 1.72 + 1.73 + is(menubar.getAttribute("autohide"), "true", "The menubar should have autohide=true after reset"); 1.74 + is(menubar.getBoundingClientRect().height, 0, "The menubar should have height=0 after reset"); 1.75 +}); 1.76 + 1.77 +// Customization reset should restore collapsed-state to default-collapsed toolbars. 1.78 +add_task(function() { 1.79 + ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); 1.80 + is(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should have height=0"); 1.81 + isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); 1.82 + 1.83 + setToolbarVisibility(bookmarksToolbar, true); 1.84 + isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should be visible now"); 1.85 + is(CustomizableUI.inDefaultState, false, "Should no longer be in default state"); 1.86 + 1.87 + yield startCustomizing(); 1.88 + 1.89 + isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should be visible before reset"); 1.90 + isnot(navbar.getBoundingClientRect().height, 0, "The navbar should be visible before reset"); 1.91 + isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); 1.92 + 1.93 + gCustomizeMode.reset(); 1.94 + yield waitForCondition(function() !gCustomizeMode.resetting); 1.95 + 1.96 + is(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should have height=0 after reset"); 1.97 + isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); 1.98 + isnot(navbar.getBoundingClientRect().height, 0, "The navbar should still be visible after reset"); 1.99 + ok(CustomizableUI.inDefaultState, "Everything should be back to default state"); 1.100 + yield endCustomizing(); 1.101 +}); 1.102 + 1.103 +// Check that the menubar will be collapsed by resetting, if the platform supports it. 1.104 +add_task(function() { 1.105 + let menubar = document.getElementById("toolbar-menubar"); 1.106 + const canMenubarCollapse = CustomizableUI.isToolbarDefaultCollapsed(menubar.id); 1.107 + if (!canMenubarCollapse) { 1.108 + return; 1.109 + } 1.110 + ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); 1.111 + yield startCustomizing(); 1.112 + let resetButton = document.getElementById("customization-reset-button"); 1.113 + is(resetButton.disabled, true, "The reset button should be disabled when in default state"); 1.114 + 1.115 + setToolbarVisibility(menubar, true); 1.116 + is(resetButton.disabled, false, "The reset button should be enabled when not in default state") 1.117 + ok(!CustomizableUI.inDefaultState, "No longer in default state when the menubar is shown"); 1.118 + 1.119 + yield gCustomizeMode.reset(); 1.120 + 1.121 + is(resetButton.disabled, true, "The reset button should be disabled when in default state"); 1.122 + ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); 1.123 + 1.124 + yield endCustomizing(); 1.125 +});