Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 const TEST_PAGE = "http://mochi.test:8888/browser/browser/components/customizableui/test/support/test_967000_charEncoding_page.html";
8 let newTab = null;
10 add_task(function() {
11 info("Check Character Encoding panel functionality");
13 // add the Character Encoding button to the panel
14 CustomizableUI.addWidgetToArea("characterencoding-button",
15 CustomizableUI.AREA_PANEL);
17 newTab = gBrowser.addTab(TEST_PAGE);
18 yield promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE);
20 yield PanelUI.show();
21 let charEncodingButton = document.getElementById("characterencoding-button");
22 charEncodingButton.click();
24 let characterEncodingView = document.getElementById("PanelUI-characterEncodingView");
25 let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
26 let initialEncoding = checkedButtons[0];
27 is(initialEncoding.getAttribute("label"), "Unicode", "The unicode encoding is initially selected");
29 // change the encoding
30 let encodings = characterEncodingView.querySelectorAll("toolbarbutton");
31 let newEncoding = encodings[0].hasAttribute("checked") ? encodings[1] : encodings[0];
32 let tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE);
33 newEncoding.click();
34 yield tabLoadPromise;
36 // check that the new encodng is applied
37 yield PanelUI.show();
38 charEncodingButton.click();
39 checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
40 let selectedEncodingName = checkedButtons[0].getAttribute("label");
41 ok(selectedEncodingName != "Unicode", "The encoding was changed to " + selectedEncodingName);
43 // reset the initial encoding
44 yield PanelUI.show();
45 charEncodingButton.click();
46 tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE);
47 initialEncoding.click();
48 yield tabLoadPromise;
49 yield PanelUI.show();
50 charEncodingButton.click();
51 let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
52 is(checkedButtons[0].getAttribute("label"), "Unicode", "The encoding was reset to Unicode");
53 });
55 add_task(function asyncCleanup() {
56 // reset the panel to the default state
57 yield resetCustomization();
58 ok(CustomizableUI.inDefaultState, "The UI is in default state again.");
60 // remove the added tab
61 gBrowser.removeTab(newTab);
62 });