|
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/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
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); |
|
14 |
|
15 yield PanelUI.show(); |
|
16 |
|
17 is(characterEncoding.getAttribute("auto-hyphens"), "off", |
|
18 "Hyphens should be disabled if the ­ 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 ­ character is present.") |
|
22 |
|
23 let hiddenPanelPromise = promisePanelHidden(window); |
|
24 PanelUI.toggle(); |
|
25 yield hiddenPanelPromise; |
|
26 |
|
27 characterEncoding.setAttribute("label", kNormalLabel); |
|
28 |
|
29 yield PanelUI.show(); |
|
30 |
|
31 isnot(characterEncoding.getAttribute("auto-hyphens"), "off", |
|
32 "Hyphens should not be disabled if the ­ 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.") |
|
36 |
|
37 hiddenPanelPromise = promisePanelHidden(window); |
|
38 PanelUI.toggle(); |
|
39 yield hiddenPanelPromise; |
|
40 |
|
41 characterEncoding.setAttribute("label", "\u00ad" + kNormalLabel); |
|
42 CustomizableUI.removeWidgetFromArea("characterencoding-button"); |
|
43 yield startCustomizing(); |
|
44 |
|
45 isnot(characterEncoding.getAttribute("auto-hyphens"), "off", |
|
46 "Hyphens should not be disabled when the widget is in the palette"); |
|
47 |
|
48 gCustomizeMode.addToPanel(characterEncoding); |
|
49 is(characterEncoding.getAttribute("auto-hyphens"), "off", |
|
50 "Hyphens should be disabled if the ­ 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 ­ character is present in customization mode.") |
|
54 |
|
55 yield endCustomizing(); |
|
56 |
|
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"); |
|
60 |
|
61 characterEncoding.setAttribute("label", kOriginalLabel); |
|
62 }); |
|
63 |
|
64 add_task(function asyncCleanup() { |
|
65 yield endCustomizing(); |
|
66 yield resetCustomization(); |
|
67 }); |