|
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 const TEST_PAGE = "http://mochi.test:8888/browser/browser/components/customizableui/test/support/test_967000_charEncoding_page.html"; |
|
8 |
|
9 let newTab; |
|
10 let initialLocation = gBrowser.currentURI.spec; |
|
11 |
|
12 add_task(function() { |
|
13 info("Check Character Encoding button functionality"); |
|
14 |
|
15 // add the Character Encoding button to the panel |
|
16 CustomizableUI.addWidgetToArea("characterencoding-button", |
|
17 CustomizableUI.AREA_PANEL); |
|
18 |
|
19 // check the button's functionality |
|
20 yield PanelUI.show(); |
|
21 |
|
22 let charEncodingButton = document.getElementById("characterencoding-button"); |
|
23 ok(charEncodingButton, "The Character Encoding button was added to the Panel Menu"); |
|
24 is(charEncodingButton.getAttribute("disabled"), "true", |
|
25 "The Character encoding button is initially disabled"); |
|
26 |
|
27 let panelHidePromise = promisePanelHidden(window); |
|
28 PanelUI.hide(); |
|
29 yield panelHidePromise; |
|
30 |
|
31 newTab = gBrowser.selectedTab; |
|
32 yield promiseTabLoadEvent(newTab, TEST_PAGE) |
|
33 |
|
34 yield PanelUI.show(); |
|
35 ok(!charEncodingButton.hasAttribute("disabled"), "The Character encoding button gets enabled"); |
|
36 charEncodingButton.click(); |
|
37 |
|
38 let characterEncodingView = document.getElementById("PanelUI-characterEncodingView"); |
|
39 ok(characterEncodingView.hasAttribute("current"), "The Character encoding panel is displayed"); |
|
40 |
|
41 let pinnedEncodings = document.getElementById("PanelUI-characterEncodingView-pinned"); |
|
42 let charsetsList = document.getElementById("PanelUI-characterEncodingView-charsets"); |
|
43 ok(pinnedEncodings, "Pinned charsets are available"); |
|
44 ok(charsetsList, "Charsets list is available"); |
|
45 |
|
46 let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); |
|
47 is(checkedButtons.length, 2, "There should be 2 checked items (1 charset, 1 detector)."); |
|
48 is(checkedButtons[0].getAttribute("label"), "Unicode", "The unicode encoding is correctly selected"); |
|
49 is(characterEncodingView.querySelectorAll("#PanelUI-characterEncodingView-autodetect toolbarbutton[checked='true']").length, |
|
50 1, |
|
51 "There should be 1 checked detector."); |
|
52 |
|
53 panelHidePromise = promisePanelHidden(window); |
|
54 PanelUI.hide(); |
|
55 yield panelHidePromise; |
|
56 }); |
|
57 |
|
58 add_task(function asyncCleanup() { |
|
59 // reset the panel to the default state |
|
60 yield resetCustomization(); |
|
61 ok(CustomizableUI.inDefaultState, "The UI is in default state again."); |
|
62 |
|
63 // restore the initial location |
|
64 gBrowser.addTab(initialLocation); |
|
65 gBrowser.removeTab(newTab); |
|
66 }); |