michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const TEST_PAGE = "http://mochi.test:8888/browser/browser/components/customizableui/test/support/test_967000_charEncoding_page.html"; michael@0: michael@0: let newTab; michael@0: let initialLocation = gBrowser.currentURI.spec; michael@0: michael@0: add_task(function() { michael@0: info("Check Character Encoding button functionality"); michael@0: michael@0: // add the Character Encoding button to the panel michael@0: CustomizableUI.addWidgetToArea("characterencoding-button", michael@0: CustomizableUI.AREA_PANEL); michael@0: michael@0: // check the button's functionality michael@0: yield PanelUI.show(); michael@0: michael@0: let charEncodingButton = document.getElementById("characterencoding-button"); michael@0: ok(charEncodingButton, "The Character Encoding button was added to the Panel Menu"); michael@0: is(charEncodingButton.getAttribute("disabled"), "true", michael@0: "The Character encoding button is initially disabled"); michael@0: michael@0: let panelHidePromise = promisePanelHidden(window); michael@0: PanelUI.hide(); michael@0: yield panelHidePromise; michael@0: michael@0: newTab = gBrowser.selectedTab; michael@0: yield promiseTabLoadEvent(newTab, TEST_PAGE) michael@0: michael@0: yield PanelUI.show(); michael@0: ok(!charEncodingButton.hasAttribute("disabled"), "The Character encoding button gets enabled"); michael@0: charEncodingButton.click(); michael@0: michael@0: let characterEncodingView = document.getElementById("PanelUI-characterEncodingView"); michael@0: ok(characterEncodingView.hasAttribute("current"), "The Character encoding panel is displayed"); michael@0: michael@0: let pinnedEncodings = document.getElementById("PanelUI-characterEncodingView-pinned"); michael@0: let charsetsList = document.getElementById("PanelUI-characterEncodingView-charsets"); michael@0: ok(pinnedEncodings, "Pinned charsets are available"); michael@0: ok(charsetsList, "Charsets list is available"); michael@0: michael@0: let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); michael@0: is(checkedButtons.length, 2, "There should be 2 checked items (1 charset, 1 detector)."); michael@0: is(checkedButtons[0].getAttribute("label"), "Unicode", "The unicode encoding is correctly selected"); michael@0: is(characterEncodingView.querySelectorAll("#PanelUI-characterEncodingView-autodetect toolbarbutton[checked='true']").length, michael@0: 1, michael@0: "There should be 1 checked detector."); michael@0: michael@0: panelHidePromise = promisePanelHidden(window); michael@0: PanelUI.hide(); michael@0: yield panelHidePromise; michael@0: }); michael@0: michael@0: add_task(function asyncCleanup() { michael@0: // reset the panel to the default state michael@0: yield resetCustomization(); michael@0: ok(CustomizableUI.inDefaultState, "The UI is in default state again."); michael@0: michael@0: // restore the initial location michael@0: gBrowser.addTab(initialLocation); michael@0: gBrowser.removeTab(newTab); michael@0: });