1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_967000_button_charEncoding.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +const TEST_PAGE = "http://mochi.test:8888/browser/browser/components/customizableui/test/support/test_967000_charEncoding_page.html"; 1.11 + 1.12 +let newTab; 1.13 +let initialLocation = gBrowser.currentURI.spec; 1.14 + 1.15 +add_task(function() { 1.16 + info("Check Character Encoding button functionality"); 1.17 + 1.18 + // add the Character Encoding button to the panel 1.19 + CustomizableUI.addWidgetToArea("characterencoding-button", 1.20 + CustomizableUI.AREA_PANEL); 1.21 + 1.22 + // check the button's functionality 1.23 + yield PanelUI.show(); 1.24 + 1.25 + let charEncodingButton = document.getElementById("characterencoding-button"); 1.26 + ok(charEncodingButton, "The Character Encoding button was added to the Panel Menu"); 1.27 + is(charEncodingButton.getAttribute("disabled"), "true", 1.28 + "The Character encoding button is initially disabled"); 1.29 + 1.30 + let panelHidePromise = promisePanelHidden(window); 1.31 + PanelUI.hide(); 1.32 + yield panelHidePromise; 1.33 + 1.34 + newTab = gBrowser.selectedTab; 1.35 + yield promiseTabLoadEvent(newTab, TEST_PAGE) 1.36 + 1.37 + yield PanelUI.show(); 1.38 + ok(!charEncodingButton.hasAttribute("disabled"), "The Character encoding button gets enabled"); 1.39 + charEncodingButton.click(); 1.40 + 1.41 + let characterEncodingView = document.getElementById("PanelUI-characterEncodingView"); 1.42 + ok(characterEncodingView.hasAttribute("current"), "The Character encoding panel is displayed"); 1.43 + 1.44 + let pinnedEncodings = document.getElementById("PanelUI-characterEncodingView-pinned"); 1.45 + let charsetsList = document.getElementById("PanelUI-characterEncodingView-charsets"); 1.46 + ok(pinnedEncodings, "Pinned charsets are available"); 1.47 + ok(charsetsList, "Charsets list is available"); 1.48 + 1.49 + let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); 1.50 + is(checkedButtons.length, 2, "There should be 2 checked items (1 charset, 1 detector)."); 1.51 + is(checkedButtons[0].getAttribute("label"), "Unicode", "The unicode encoding is correctly selected"); 1.52 + is(characterEncodingView.querySelectorAll("#PanelUI-characterEncodingView-autodetect toolbarbutton[checked='true']").length, 1.53 + 1, 1.54 + "There should be 1 checked detector."); 1.55 + 1.56 + panelHidePromise = promisePanelHidden(window); 1.57 + PanelUI.hide(); 1.58 + yield panelHidePromise; 1.59 +}); 1.60 + 1.61 +add_task(function asyncCleanup() { 1.62 + // reset the panel to the default state 1.63 + yield resetCustomization(); 1.64 + ok(CustomizableUI.inDefaultState, "The UI is in default state again."); 1.65 + 1.66 + // restore the initial location 1.67 + gBrowser.addTab(initialLocation); 1.68 + gBrowser.removeTab(newTab); 1.69 +});