browser/components/customizableui/test/browser_962884_opt_in_disable_hyphens.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/customizableui/test/browser_962884_opt_in_disable_hyphens.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +add_task(function() {
    1.11 +  const kNormalLabel = "Character Encoding";
    1.12 +  CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR);
    1.13 +  let characterEncoding = document.getElementById("characterencoding-button");
    1.14 +  const kOriginalLabel = characterEncoding.getAttribute("label");
    1.15 +  characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel);
    1.16 +  CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_PANEL);
    1.17 +
    1.18 +  yield PanelUI.show();
    1.19 +
    1.20 +  is(characterEncoding.getAttribute("auto-hyphens"), "off",
    1.21 +     "Hyphens should be disabled if the ­ character is present in the label");
    1.22 +  let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
    1.23 +  let multilineTextCS = getComputedStyle(multilineText);
    1.24 +  is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the ­ character is present.")
    1.25 +
    1.26 +  let hiddenPanelPromise = promisePanelHidden(window);
    1.27 +  PanelUI.toggle();
    1.28 +  yield hiddenPanelPromise;
    1.29 +
    1.30 +  characterEncoding.setAttribute("label", kNormalLabel);
    1.31 +
    1.32 +  yield PanelUI.show();
    1.33 +
    1.34 +  isnot(characterEncoding.getAttribute("auto-hyphens"), "off",
    1.35 +        "Hyphens should not be disabled if the ­ character is not present in the label");
    1.36 +  multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
    1.37 +  let multilineTextCS = getComputedStyle(multilineText);
    1.38 +  is(multilineTextCS.MozHyphens, "auto", "-moz-hyphens should be set to auto by default.")
    1.39 +
    1.40 +  hiddenPanelPromise = promisePanelHidden(window);
    1.41 +  PanelUI.toggle();
    1.42 +  yield hiddenPanelPromise;
    1.43 +
    1.44 +  characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel);
    1.45 +  CustomizableUI.removeWidgetFromArea("characterencoding-button");
    1.46 +  yield startCustomizing();
    1.47 +
    1.48 +  isnot(characterEncoding.getAttribute("auto-hyphens"), "off",
    1.49 +        "Hyphens should not be disabled when the widget is in the palette");
    1.50 +
    1.51 +  gCustomizeMode.addToPanel(characterEncoding);
    1.52 +  is(characterEncoding.getAttribute("auto-hyphens"), "off",
    1.53 +     "Hyphens should be disabled if the ­ character is present in the label in customization mode");
    1.54 +  let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
    1.55 +  let multilineTextCS = getComputedStyle(multilineText);
    1.56 +  is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the ­ character is present in customization mode.")
    1.57 +
    1.58 +  yield endCustomizing();
    1.59 +
    1.60 +  CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR);
    1.61 +  ok(!characterEncoding.hasAttribute("auto-hyphens"),
    1.62 +     "Removing the widget from the panel should remove the auto-hyphens attribute");
    1.63 +
    1.64 +  characterEncoding.setAttribute("label", kOriginalLabel);
    1.65 +});
    1.66 +
    1.67 +add_task(function asyncCleanup() {
    1.68 +  yield endCustomizing();
    1.69 +  yield resetCustomization();
    1.70 +});

mercurial