Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | const TEST_PAGE = "http://mochi.test:8888/browser/browser/components/customizableui/test/support/test_967000_charEncoding_page.html"; |
michael@0 | 8 | |
michael@0 | 9 | let newTab; |
michael@0 | 10 | let initialLocation = gBrowser.currentURI.spec; |
michael@0 | 11 | |
michael@0 | 12 | add_task(function() { |
michael@0 | 13 | info("Check Character Encoding button functionality"); |
michael@0 | 14 | |
michael@0 | 15 | // add the Character Encoding button to the panel |
michael@0 | 16 | CustomizableUI.addWidgetToArea("characterencoding-button", |
michael@0 | 17 | CustomizableUI.AREA_PANEL); |
michael@0 | 18 | |
michael@0 | 19 | // check the button's functionality |
michael@0 | 20 | yield PanelUI.show(); |
michael@0 | 21 | |
michael@0 | 22 | let charEncodingButton = document.getElementById("characterencoding-button"); |
michael@0 | 23 | ok(charEncodingButton, "The Character Encoding button was added to the Panel Menu"); |
michael@0 | 24 | is(charEncodingButton.getAttribute("disabled"), "true", |
michael@0 | 25 | "The Character encoding button is initially disabled"); |
michael@0 | 26 | |
michael@0 | 27 | let panelHidePromise = promisePanelHidden(window); |
michael@0 | 28 | PanelUI.hide(); |
michael@0 | 29 | yield panelHidePromise; |
michael@0 | 30 | |
michael@0 | 31 | newTab = gBrowser.selectedTab; |
michael@0 | 32 | yield promiseTabLoadEvent(newTab, TEST_PAGE) |
michael@0 | 33 | |
michael@0 | 34 | yield PanelUI.show(); |
michael@0 | 35 | ok(!charEncodingButton.hasAttribute("disabled"), "The Character encoding button gets enabled"); |
michael@0 | 36 | charEncodingButton.click(); |
michael@0 | 37 | |
michael@0 | 38 | let characterEncodingView = document.getElementById("PanelUI-characterEncodingView"); |
michael@0 | 39 | ok(characterEncodingView.hasAttribute("current"), "The Character encoding panel is displayed"); |
michael@0 | 40 | |
michael@0 | 41 | let pinnedEncodings = document.getElementById("PanelUI-characterEncodingView-pinned"); |
michael@0 | 42 | let charsetsList = document.getElementById("PanelUI-characterEncodingView-charsets"); |
michael@0 | 43 | ok(pinnedEncodings, "Pinned charsets are available"); |
michael@0 | 44 | ok(charsetsList, "Charsets list is available"); |
michael@0 | 45 | |
michael@0 | 46 | let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); |
michael@0 | 47 | is(checkedButtons.length, 2, "There should be 2 checked items (1 charset, 1 detector)."); |
michael@0 | 48 | is(checkedButtons[0].getAttribute("label"), "Unicode", "The unicode encoding is correctly selected"); |
michael@0 | 49 | is(characterEncodingView.querySelectorAll("#PanelUI-characterEncodingView-autodetect toolbarbutton[checked='true']").length, |
michael@0 | 50 | 1, |
michael@0 | 51 | "There should be 1 checked detector."); |
michael@0 | 52 | |
michael@0 | 53 | panelHidePromise = promisePanelHidden(window); |
michael@0 | 54 | PanelUI.hide(); |
michael@0 | 55 | yield panelHidePromise; |
michael@0 | 56 | }); |
michael@0 | 57 | |
michael@0 | 58 | add_task(function asyncCleanup() { |
michael@0 | 59 | // reset the panel to the default state |
michael@0 | 60 | yield resetCustomization(); |
michael@0 | 61 | ok(CustomizableUI.inDefaultState, "The UI is in default state again."); |
michael@0 | 62 | |
michael@0 | 63 | // restore the initial location |
michael@0 | 64 | gBrowser.addTab(initialLocation); |
michael@0 | 65 | gBrowser.removeTab(newTab); |
michael@0 | 66 | }); |