michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: let bookmarksToolbar = document.getElementById("PersonalToolbar"); michael@0: let navbar = document.getElementById("nav-bar"); michael@0: let tabsToolbar = document.getElementById("TabsToolbar"); michael@0: michael@0: // Customization reset should restore visibility to default-visible toolbars. michael@0: add_task(function() { michael@0: is(navbar.collapsed, false, "Test should start with navbar visible"); michael@0: setToolbarVisibility(navbar, false); michael@0: is(navbar.collapsed, true, "navbar should be hidden now"); michael@0: michael@0: yield resetCustomization(); michael@0: michael@0: is(navbar.collapsed, false, "Customization reset should restore visibility to the navbar"); michael@0: }); michael@0: michael@0: // Customization reset should restore collapsed-state to default-collapsed toolbars. michael@0: add_task(function() { michael@0: ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); michael@0: michael@0: is(bookmarksToolbar.collapsed, true, "Test should start with bookmarks toolbar collapsed"); michael@0: is(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should have height=0"); michael@0: isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); michael@0: is(navbar.collapsed, false, "The nav-bar should be shown by default"); michael@0: michael@0: setToolbarVisibility(bookmarksToolbar, true); michael@0: setToolbarVisibility(navbar, false); michael@0: isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should be visible now"); michael@0: is(navbar.getBoundingClientRect().height, 1, "navbar should have a height=1 (due to border)"); michael@0: is(CustomizableUI.inDefaultState, false, "Should no longer be in default state"); michael@0: michael@0: yield startCustomizing(); michael@0: gCustomizeMode.reset(); michael@0: yield waitForCondition(function() !gCustomizeMode.resetting); michael@0: yield endCustomizing(); michael@0: michael@0: is(bookmarksToolbar.collapsed, true, "Customization reset should restore collapsed-state to the bookmarks toolbar"); michael@0: isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); michael@0: is(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should have height=0 after reset"); michael@0: ok(CustomizableUI.inDefaultState, "Everything should be back to default state"); michael@0: }); michael@0: michael@0: // Check that the menubar will be collapsed by resetting, if the platform supports it. michael@0: add_task(function() { michael@0: let menubar = document.getElementById("toolbar-menubar"); michael@0: const canMenubarCollapse = CustomizableUI.isToolbarDefaultCollapsed(menubar.id); michael@0: if (!canMenubarCollapse) { michael@0: return; michael@0: } michael@0: ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); michael@0: michael@0: is(menubar.getBoundingClientRect().height, 0, "menubar should be hidden by default"); michael@0: setToolbarVisibility(menubar, true); michael@0: isnot(menubar.getBoundingClientRect().height, 0, "menubar should be visible now"); michael@0: michael@0: yield startCustomizing(); michael@0: gCustomizeMode.reset(); michael@0: yield waitForCondition(function() !gCustomizeMode.resetting); michael@0: michael@0: is(menubar.getAttribute("autohide"), "true", "The menubar should have autohide=true after reset in customization mode"); michael@0: is(menubar.getBoundingClientRect().height, 0, "The menubar should have height=0 after reset in customization mode"); michael@0: michael@0: yield endCustomizing(); michael@0: michael@0: is(menubar.getAttribute("autohide"), "true", "The menubar should have autohide=true after reset"); michael@0: is(menubar.getBoundingClientRect().height, 0, "The menubar should have height=0 after reset"); michael@0: }); michael@0: michael@0: // Customization reset should restore collapsed-state to default-collapsed toolbars. michael@0: add_task(function() { michael@0: ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); michael@0: is(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should have height=0"); michael@0: isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); michael@0: michael@0: setToolbarVisibility(bookmarksToolbar, true); michael@0: isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "bookmarksToolbar should be visible now"); michael@0: is(CustomizableUI.inDefaultState, false, "Should no longer be in default state"); michael@0: michael@0: yield startCustomizing(); michael@0: michael@0: isnot(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should be visible before reset"); michael@0: isnot(navbar.getBoundingClientRect().height, 0, "The navbar should be visible before reset"); michael@0: isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); michael@0: michael@0: gCustomizeMode.reset(); michael@0: yield waitForCondition(function() !gCustomizeMode.resetting); michael@0: michael@0: is(bookmarksToolbar.getBoundingClientRect().height, 0, "The bookmarksToolbar should have height=0 after reset"); michael@0: isnot(tabsToolbar.getBoundingClientRect().height, 0, "TabsToolbar should have non-zero height"); michael@0: isnot(navbar.getBoundingClientRect().height, 0, "The navbar should still be visible after reset"); michael@0: ok(CustomizableUI.inDefaultState, "Everything should be back to default state"); michael@0: yield endCustomizing(); michael@0: }); michael@0: michael@0: // Check that the menubar will be collapsed by resetting, if the platform supports it. michael@0: add_task(function() { michael@0: let menubar = document.getElementById("toolbar-menubar"); michael@0: const canMenubarCollapse = CustomizableUI.isToolbarDefaultCollapsed(menubar.id); michael@0: if (!canMenubarCollapse) { michael@0: return; michael@0: } michael@0: ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); michael@0: yield startCustomizing(); michael@0: let resetButton = document.getElementById("customization-reset-button"); michael@0: is(resetButton.disabled, true, "The reset button should be disabled when in default state"); michael@0: michael@0: setToolbarVisibility(menubar, true); michael@0: is(resetButton.disabled, false, "The reset button should be enabled when not in default state") michael@0: ok(!CustomizableUI.inDefaultState, "No longer in default state when the menubar is shown"); michael@0: michael@0: yield gCustomizeMode.reset(); michael@0: michael@0: is(resetButton.disabled, true, "The reset button should be disabled when in default state"); michael@0: ok(CustomizableUI.inDefaultState, "Everything should be in its default state"); michael@0: michael@0: yield endCustomizing(); michael@0: });