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