Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
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 | let newTab = null; |
michael@0 | 9 | |
michael@0 | 10 | add_task(function() { |
michael@0 | 11 | info("Check Character Encoding panel functionality"); |
michael@0 | 12 | |
michael@0 | 13 | // add the Character Encoding button to the panel |
michael@0 | 14 | CustomizableUI.addWidgetToArea("characterencoding-button", |
michael@0 | 15 | CustomizableUI.AREA_PANEL); |
michael@0 | 16 | |
michael@0 | 17 | newTab = gBrowser.addTab(TEST_PAGE); |
michael@0 | 18 | yield promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE); |
michael@0 | 19 | |
michael@0 | 20 | yield PanelUI.show(); |
michael@0 | 21 | let charEncodingButton = document.getElementById("characterencoding-button"); |
michael@0 | 22 | charEncodingButton.click(); |
michael@0 | 23 | |
michael@0 | 24 | let characterEncodingView = document.getElementById("PanelUI-characterEncodingView"); |
michael@0 | 25 | let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); |
michael@0 | 26 | let initialEncoding = checkedButtons[0]; |
michael@0 | 27 | is(initialEncoding.getAttribute("label"), "Unicode", "The unicode encoding is initially selected"); |
michael@0 | 28 | |
michael@0 | 29 | // change the encoding |
michael@0 | 30 | let encodings = characterEncodingView.querySelectorAll("toolbarbutton"); |
michael@0 | 31 | let newEncoding = encodings[0].hasAttribute("checked") ? encodings[1] : encodings[0]; |
michael@0 | 32 | let tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE); |
michael@0 | 33 | newEncoding.click(); |
michael@0 | 34 | yield tabLoadPromise; |
michael@0 | 35 | |
michael@0 | 36 | // check that the new encodng is applied |
michael@0 | 37 | yield PanelUI.show(); |
michael@0 | 38 | charEncodingButton.click(); |
michael@0 | 39 | checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); |
michael@0 | 40 | let selectedEncodingName = checkedButtons[0].getAttribute("label"); |
michael@0 | 41 | ok(selectedEncodingName != "Unicode", "The encoding was changed to " + selectedEncodingName); |
michael@0 | 42 | |
michael@0 | 43 | // reset the initial encoding |
michael@0 | 44 | yield PanelUI.show(); |
michael@0 | 45 | charEncodingButton.click(); |
michael@0 | 46 | tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE); |
michael@0 | 47 | initialEncoding.click(); |
michael@0 | 48 | yield tabLoadPromise; |
michael@0 | 49 | yield PanelUI.show(); |
michael@0 | 50 | charEncodingButton.click(); |
michael@0 | 51 | let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']"); |
michael@0 | 52 | is(checkedButtons[0].getAttribute("label"), "Unicode", "The encoding was reset to Unicode"); |
michael@0 | 53 | }); |
michael@0 | 54 | |
michael@0 | 55 | add_task(function asyncCleanup() { |
michael@0 | 56 | // reset the panel to the default state |
michael@0 | 57 | yield resetCustomization(); |
michael@0 | 58 | ok(CustomizableUI.inDefaultState, "The UI is in default state again."); |
michael@0 | 59 | |
michael@0 | 60 | // remove the added tab |
michael@0 | 61 | gBrowser.removeTab(newTab); |
michael@0 | 62 | }); |