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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 add_task(function() {
     8   const kNormalLabel = "Character Encoding";
     9   CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR);
    10   let characterEncoding = document.getElementById("characterencoding-button");
    11   const kOriginalLabel = characterEncoding.getAttribute("label");
    12   characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel);
    13   CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_PANEL);
    15   yield PanelUI.show();
    17   is(characterEncoding.getAttribute("auto-hyphens"), "off",
    18      "Hyphens should be disabled if the &shy; character is present in the label");
    19   let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
    20   let multilineTextCS = getComputedStyle(multilineText);
    21   is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the &shy; character is present.")
    23   let hiddenPanelPromise = promisePanelHidden(window);
    24   PanelUI.toggle();
    25   yield hiddenPanelPromise;
    27   characterEncoding.setAttribute("label", kNormalLabel);
    29   yield PanelUI.show();
    31   isnot(characterEncoding.getAttribute("auto-hyphens"), "off",
    32         "Hyphens should not be disabled if the &shy; character is not present in the label");
    33   multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
    34   let multilineTextCS = getComputedStyle(multilineText);
    35   is(multilineTextCS.MozHyphens, "auto", "-moz-hyphens should be set to auto by default.")
    37   hiddenPanelPromise = promisePanelHidden(window);
    38   PanelUI.toggle();
    39   yield hiddenPanelPromise;
    41   characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel);
    42   CustomizableUI.removeWidgetFromArea("characterencoding-button");
    43   yield startCustomizing();
    45   isnot(characterEncoding.getAttribute("auto-hyphens"), "off",
    46         "Hyphens should not be disabled when the widget is in the palette");
    48   gCustomizeMode.addToPanel(characterEncoding);
    49   is(characterEncoding.getAttribute("auto-hyphens"), "off",
    50      "Hyphens should be disabled if the &shy; character is present in the label in customization mode");
    51   let multilineText = document.getAnonymousElementByAttribute(characterEncoding, "class", "toolbarbutton-multiline-text");
    52   let multilineTextCS = getComputedStyle(multilineText);
    53   is(multilineTextCS.MozHyphens, "manual", "-moz-hyphens should be set to manual when the &shy; character is present in customization mode.")
    55   yield endCustomizing();
    57   CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_NAVBAR);
    58   ok(!characterEncoding.hasAttribute("auto-hyphens"),
    59      "Removing the widget from the panel should remove the auto-hyphens attribute");
    61   characterEncoding.setAttribute("label", kOriginalLabel);
    62 });
    64 add_task(function asyncCleanup() {
    65   yield endCustomizing();
    66   yield resetCustomization();
    67 });

mercurial