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: add_task(function() { michael@0: const kNormalLabel = "Character Encoding"; michael@0: CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR); michael@0: let characterEncoding = document.getElementById("characterencoding-button"); michael@0: const kOriginalLabel = characterEncoding.getAttribute("label"); michael@0: characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel); michael@0: CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_PANEL); michael@0: michael@0: yield PanelUI.show(); michael@0: michael@0: is(characterEncoding.getAttribute("auto-hyphens"), "off", michael@0: "Hyphens should be disabled if the ­ character is present in the label"); michael@0: let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text"); michael@0: let multilineTextCS = getComputedStyle(multilineText); michael@0: is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the ­ character is present.") michael@0: michael@0: let hiddenPanelPromise = promisePanelHidden(window); michael@0: PanelUI.toggle(); michael@0: yield hiddenPanelPromise; michael@0: michael@0: characterEncoding.setAttribute("label", kNormalLabel); michael@0: michael@0: yield PanelUI.show(); michael@0: michael@0: isnot(characterEncoding.getAttribute("auto-hyphens"), "off", michael@0: "Hyphens should not be disabled if the ­ character is not present in the label"); michael@0: multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text"); michael@0: let multilineTextCS = getComputedStyle(multilineText); michael@0: is(multilineTextCS.MozHyphens, "auto", "-moz-hyphens should be set to auto by default.") michael@0: michael@0: hiddenPanelPromise = promisePanelHidden(window); michael@0: PanelUI.toggle(); michael@0: yield hiddenPanelPromise; michael@0: michael@0: characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel); michael@0: CustomizableUI.removeWidgetFromArea("characterencoding-button"); michael@0: yield startCustomizing(); michael@0: michael@0: isnot(characterEncoding.getAttribute("auto-hyphens"), "off", michael@0: "Hyphens should not be disabled when the widget is in the palette"); michael@0: michael@0: gCustomizeMode.addToPanel(characterEncoding); michael@0: is(characterEncoding.getAttribute("auto-hyphens"), "off", michael@0: "Hyphens should be disabled if the ­ character is present in the label in customization mode"); michael@0: let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text"); michael@0: let multilineTextCS = getComputedStyle(multilineText); michael@0: is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the ­ character is present in customization mode.") michael@0: michael@0: yield endCustomizing(); michael@0: michael@0: CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR); michael@0: ok(!characterEncoding.hasAttribute("auto-hyphens"), michael@0: "Removing the widget from the panel should remove the auto-hyphens attribute"); michael@0: michael@0: characterEncoding.setAttribute("label", kOriginalLabel); michael@0: }); michael@0: michael@0: add_task(function asyncCleanup() { michael@0: yield endCustomizing(); michael@0: yield resetCustomization(); michael@0: });