1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_987640_charEncoding.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 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 +let newTab = null; 1.12 + 1.13 +add_task(function() { 1.14 + info("Check Character Encoding panel functionality"); 1.15 + 1.16 + // add the Character Encoding button to the panel 1.17 + CustomizableUI.addWidgetToArea("characterencoding-button", 1.18 + CustomizableUI.AREA_PANEL); 1.19 + 1.20 + newTab = gBrowser.addTab(TEST_PAGE); 1.21 + yield promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE); 1.22 + 1.23 + yield PanelUI.show(); 1.24 + let charEncodingButton = document.getElementById("characterencoding-button"); 1.25 + charEncodingButton.click(); 1.26 + 1.27 + let characterEncodingView = document.getElementById("PanelUI-characterEncodingView"); 1.28 + let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); 1.29 + let initialEncoding = checkedButtons[0]; 1.30 + is(initialEncoding.getAttribute("label"), "Unicode", "The unicode encoding is initially selected"); 1.31 + 1.32 + // change the encoding 1.33 + let encodings = characterEncodingView.querySelectorAll("toolbarbutton"); 1.34 + let newEncoding = encodings[0].hasAttribute("checked") ? encodings[1] : encodings[0]; 1.35 + let tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE); 1.36 + newEncoding.click(); 1.37 + yield tabLoadPromise; 1.38 + 1.39 + // check that the new encodng is applied 1.40 + yield PanelUI.show(); 1.41 + charEncodingButton.click(); 1.42 + checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); 1.43 + let selectedEncodingName = checkedButtons[0].getAttribute("label"); 1.44 + ok(selectedEncodingName != "Unicode", "The encoding was changed to " + selectedEncodingName); 1.45 + 1.46 + // reset the initial encoding 1.47 + yield PanelUI.show(); 1.48 + charEncodingButton.click(); 1.49 + tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE); 1.50 + initialEncoding.click(); 1.51 + yield tabLoadPromise; 1.52 + yield PanelUI.show(); 1.53 + charEncodingButton.click(); 1.54 + let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); 1.55 + is(checkedButtons[0].getAttribute("label"), "Unicode", "The encoding was reset to Unicode"); 1.56 +}); 1.57 + 1.58 +add_task(function asyncCleanup() { 1.59 + // reset the panel to the default state 1.60 + yield resetCustomization(); 1.61 + ok(CustomizableUI.inDefaultState, "The UI is in default state again."); 1.62 + 1.63 + // remove the added tab 1.64 + gBrowser.removeTab(newTab); 1.65 +});