diff -r 000000000000 -r 6474c204b198 browser/components/customizableui/test/browser_962884_opt_in_disable_hyphens.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browser/components/customizableui/test/browser_962884_opt_in_disable_hyphens.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,67 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +add_task(function() { + const kNormalLabel = "Character Encoding"; + CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR); + let characterEncoding = document.getElementById("characterencoding-button"); + const kOriginalLabel = characterEncoding.getAttribute("label"); + characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel); + CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_PANEL); + + yield PanelUI.show(); + + is(characterEncoding.getAttribute("auto-hyphens"), "off", + "Hyphens should be disabled if the ­ character is present in the label"); + let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text"); + let multilineTextCS = getComputedStyle(multilineText); + is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the ­ character is present.") + + let hiddenPanelPromise = promisePanelHidden(window); + PanelUI.toggle(); + yield hiddenPanelPromise; + + characterEncoding.setAttribute("label", kNormalLabel); + + yield PanelUI.show(); + + isnot(characterEncoding.getAttribute("auto-hyphens"), "off", + "Hyphens should not be disabled if the ­ character is not present in the label"); + multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text"); + let multilineTextCS = getComputedStyle(multilineText); + is(multilineTextCS.MozHyphens, "auto", "-moz-hyphens should be set to auto by default.") + + hiddenPanelPromise = promisePanelHidden(window); + PanelUI.toggle(); + yield hiddenPanelPromise; + + characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel); + CustomizableUI.removeWidgetFromArea("characterencoding-button"); + yield startCustomizing(); + + isnot(characterEncoding.getAttribute("auto-hyphens"), "off", + "Hyphens should not be disabled when the widget is in the palette"); + + gCustomizeMode.addToPanel(characterEncoding); + is(characterEncoding.getAttribute("auto-hyphens"), "off", + "Hyphens should be disabled if the ­ character is present in the label in customization mode"); + let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text"); + let multilineTextCS = getComputedStyle(multilineText); + is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the ­ character is present in customization mode.") + + yield endCustomizing(); + + CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR); + ok(!characterEncoding.hasAttribute("auto-hyphens"), + "Removing the widget from the panel should remove the auto-hyphens attribute"); + + characterEncoding.setAttribute("label", kOriginalLabel); +}); + +add_task(function asyncCleanup() { + yield endCustomizing(); + yield resetCustomization(); +});