browser/components/customizableui/test/browser_962884_opt_in_disable_hyphens.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

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 add_task(function() {
michael@0 8 const kNormalLabel = "Character Encoding";
michael@0 9 CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR);
michael@0 10 let characterEncoding = document.getElementById("characterencoding-button");
michael@0 11 const kOriginalLabel = characterEncoding.getAttribute("label");
michael@0 12 characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel);
michael@0 13 CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_PANEL);
michael@0 14
michael@0 15 yield PanelUI.show();
michael@0 16
michael@0 17 is(characterEncoding.getAttribute("auto-hyphens"), "off",
michael@0 18 "Hyphens should be disabled if the &shy; character is present in the label");
michael@0 19 let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
michael@0 20 let multilineTextCS = getComputedStyle(multilineText);
michael@0 21 is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the &shy; character is present.")
michael@0 22
michael@0 23 let hiddenPanelPromise = promisePanelHidden(window);
michael@0 24 PanelUI.toggle();
michael@0 25 yield hiddenPanelPromise;
michael@0 26
michael@0 27 characterEncoding.setAttribute("label", kNormalLabel);
michael@0 28
michael@0 29 yield PanelUI.show();
michael@0 30
michael@0 31 isnot(characterEncoding.getAttribute("auto-hyphens"), "off",
michael@0 32 "Hyphens should not be disabled if the &shy; character is not present in the label");
michael@0 33 multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
michael@0 34 let multilineTextCS = getComputedStyle(multilineText);
michael@0 35 is(multilineTextCS.MozHyphens, "auto", "-moz-hyphens should be set to auto by default.")
michael@0 36
michael@0 37 hiddenPanelPromise = promisePanelHidden(window);
michael@0 38 PanelUI.toggle();
michael@0 39 yield hiddenPanelPromise;
michael@0 40
michael@0 41 characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel);
michael@0 42 CustomizableUI.removeWidgetFromArea("characterencoding-button");
michael@0 43 yield startCustomizing();
michael@0 44
michael@0 45 isnot(characterEncoding.getAttribute("auto-hyphens"), "off",
michael@0 46 "Hyphens should not be disabled when the widget is in the palette");
michael@0 47
michael@0 48 gCustomizeMode.addToPanel(characterEncoding);
michael@0 49 is(characterEncoding.getAttribute("auto-hyphens"), "off",
michael@0 50 "Hyphens should be disabled if the &shy; character is present in the label in customization mode");
michael@0 51 let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
michael@0 52 let multilineTextCS = getComputedStyle(multilineText);
michael@0 53 is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the &shy; character is present in customization mode.")
michael@0 54
michael@0 55 yield endCustomizing();
michael@0 56
michael@0 57 CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR);
michael@0 58 ok(!characterEncoding.hasAttribute("auto-hyphens"),
michael@0 59 "Removing the widget from the panel should remove the auto-hyphens attribute");
michael@0 60
michael@0 61 characterEncoding.setAttribute("label", kOriginalLabel);
michael@0 62 });
michael@0 63
michael@0 64 add_task(function asyncCleanup() {
michael@0 65 yield endCustomizing();
michael@0 66 yield resetCustomization();
michael@0 67 });

mercurial