Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
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 | // Restoring default should show an "undo" option which undoes the restoring operation. |
michael@0 | 8 | add_task(function() { |
michael@0 | 9 | let homeButtonId = "home-button"; |
michael@0 | 10 | CustomizableUI.removeWidgetFromArea(homeButtonId); |
michael@0 | 11 | yield startCustomizing(); |
michael@0 | 12 | ok(!CustomizableUI.inDefaultState, "Not in default state to begin with"); |
michael@0 | 13 | is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette"); |
michael@0 | 14 | let undoResetButton = document.getElementById("customization-undo-reset-button"); |
michael@0 | 15 | is(undoResetButton.hidden, true, "The undo button is hidden before reset"); |
michael@0 | 16 | |
michael@0 | 17 | yield gCustomizeMode.reset(); |
michael@0 | 18 | |
michael@0 | 19 | ok(CustomizableUI.inDefaultState, "In default state after reset"); |
michael@0 | 20 | is(undoResetButton.hidden, false, "The undo button is visible after reset"); |
michael@0 | 21 | |
michael@0 | 22 | undoResetButton.click(); |
michael@0 | 23 | yield waitForCondition(function() !gCustomizeMode.resetting); |
michael@0 | 24 | ok(!CustomizableUI.inDefaultState, "Not in default state after reset-undo"); |
michael@0 | 25 | is(undoResetButton.hidden, true, "The undo button is hidden after clicking on the undo button"); |
michael@0 | 26 | is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette"); |
michael@0 | 27 | |
michael@0 | 28 | yield gCustomizeMode.reset(); |
michael@0 | 29 | }); |
michael@0 | 30 | |
michael@0 | 31 | // Performing an action after a reset will hide the reset button. |
michael@0 | 32 | add_task(function() { |
michael@0 | 33 | let homeButtonId = "home-button"; |
michael@0 | 34 | CustomizableUI.removeWidgetFromArea(homeButtonId); |
michael@0 | 35 | ok(!CustomizableUI.inDefaultState, "Not in default state to begin with"); |
michael@0 | 36 | is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette"); |
michael@0 | 37 | let undoResetButton = document.getElementById("customization-undo-reset-button"); |
michael@0 | 38 | is(undoResetButton.hidden, true, "The undo button is hidden before reset"); |
michael@0 | 39 | |
michael@0 | 40 | yield gCustomizeMode.reset(); |
michael@0 | 41 | |
michael@0 | 42 | ok(CustomizableUI.inDefaultState, "In default state after reset"); |
michael@0 | 43 | is(undoResetButton.hidden, false, "The undo button is visible after reset"); |
michael@0 | 44 | |
michael@0 | 45 | CustomizableUI.addWidgetToArea(homeButtonId, CustomizableUI.AREA_PANEL); |
michael@0 | 46 | is(undoResetButton.hidden, true, "The undo button is hidden after another change"); |
michael@0 | 47 | }); |
michael@0 | 48 | |
michael@0 | 49 | // "Restore defaults", exiting customize, and re-entering shouldn't show the Undo button |
michael@0 | 50 | add_task(function() { |
michael@0 | 51 | let undoResetButton = document.getElementById("customization-undo-reset-button"); |
michael@0 | 52 | is(undoResetButton.hidden, true, "The undo button is hidden before a reset"); |
michael@0 | 53 | ok(!CustomizableUI.inDefaultState, "The browser should not be in default state"); |
michael@0 | 54 | yield gCustomizeMode.reset(); |
michael@0 | 55 | |
michael@0 | 56 | is(undoResetButton.hidden, false, "The undo button is visible after a reset"); |
michael@0 | 57 | yield endCustomizing(); |
michael@0 | 58 | yield startCustomizing(); |
michael@0 | 59 | is(undoResetButton.hidden, true, "The undo reset button should be hidden after entering customization mode"); |
michael@0 | 60 | }); |
michael@0 | 61 | |
michael@0 | 62 | // Bug 971626 - Restore Defaults should collapse the Title Bar |
michael@0 | 63 | add_task(function() { |
michael@0 | 64 | if (Services.appinfo.OS != "WINNT" && |
michael@0 | 65 | Services.appinfo.OS != "Darwin") { |
michael@0 | 66 | return; |
michael@0 | 67 | } |
michael@0 | 68 | let prefName = "browser.tabs.drawInTitlebar"; |
michael@0 | 69 | let defaultValue = Services.prefs.getBoolPref(prefName); |
michael@0 | 70 | let restoreDefaultsButton = document.getElementById("customization-reset-button"); |
michael@0 | 71 | let titleBarButton = document.getElementById("customization-titlebar-visibility-button"); |
michael@0 | 72 | let undoResetButton = document.getElementById("customization-undo-reset-button"); |
michael@0 | 73 | ok(CustomizableUI.inDefaultState, "Should be in default state at start of test"); |
michael@0 | 74 | ok(restoreDefaultsButton.disabled, "Restore defaults button should be disabled when in default state"); |
michael@0 | 75 | is(titleBarButton.hasAttribute("checked"), !defaultValue, "Title bar button should reflect pref value"); |
michael@0 | 76 | is(undoResetButton.hidden, true, "Undo reset button should be hidden at start of test"); |
michael@0 | 77 | |
michael@0 | 78 | Services.prefs.setBoolPref(prefName, !defaultValue); |
michael@0 | 79 | ok(!restoreDefaultsButton.disabled, "Restore defaults button should be enabled when pref changed"); |
michael@0 | 80 | is(titleBarButton.hasAttribute("checked"), defaultValue, "Title bar button should reflect changed pref value"); |
michael@0 | 81 | ok(!CustomizableUI.inDefaultState, "With titlebar flipped, no longer default"); |
michael@0 | 82 | is(undoResetButton.hidden, true, "Undo reset button should be hidden after pref change"); |
michael@0 | 83 | |
michael@0 | 84 | yield gCustomizeMode.reset(); |
michael@0 | 85 | ok(restoreDefaultsButton.disabled, "Restore defaults button should be disabled after reset"); |
michael@0 | 86 | is(titleBarButton.hasAttribute("checked"), !defaultValue, "Title bar button should reflect default value after reset"); |
michael@0 | 87 | is(Services.prefs.getBoolPref(prefName), defaultValue, "Reset should reset drawInTitlebar"); |
michael@0 | 88 | ok(CustomizableUI.inDefaultState, "In default state after titlebar reset"); |
michael@0 | 89 | is(undoResetButton.hidden, false, "Undo reset button should be visible after reset"); |
michael@0 | 90 | ok(!undoResetButton.disabled, "Undo reset button should be enabled after reset"); |
michael@0 | 91 | |
michael@0 | 92 | yield gCustomizeMode.undoReset(); |
michael@0 | 93 | ok(!restoreDefaultsButton.disabled, "Restore defaults button should be enabled after undo-reset"); |
michael@0 | 94 | is(titleBarButton.hasAttribute("checked"), defaultValue, "Title bar button should reflect undo-reset value"); |
michael@0 | 95 | ok(!CustomizableUI.inDefaultState, "No longer in default state after undo"); |
michael@0 | 96 | is(Services.prefs.getBoolPref(prefName), !defaultValue, "Undo-reset goes back to previous pref value"); |
michael@0 | 97 | is(undoResetButton.hidden, true, "Undo reset button should be hidden after undo-reset clicked"); |
michael@0 | 98 | |
michael@0 | 99 | Services.prefs.clearUserPref(prefName); |
michael@0 | 100 | ok(CustomizableUI.inDefaultState, "In default state after pref cleared"); |
michael@0 | 101 | is(undoResetButton.hidden, true, "Undo reset button should be hidden at end of test"); |
michael@0 | 102 | }); |
michael@0 | 103 | |
michael@0 | 104 | add_task(function asyncCleanup() { |
michael@0 | 105 | yield gCustomizeMode.reset(); |
michael@0 | 106 | yield endCustomizing(); |
michael@0 | 107 | }); |