fune/browser/components/customizableui/test/browser_987640_charEncoding.js
Gijs Kruitbosch beb6be4934 Bug 1354117 - Update various other customizableui tests for photon, r=adw
There are no more help/quit buttons in the panel that shows up in customize mode,
and there are no more hyphenation quirks in items in the panel, so those tests
have been removed. The remaining tests are updated to test the correct panels.

MozReview-Commit-ID: LiUWejjZC7c

--HG--
rename : browser/components/customizableui/test/browser_photon_customization_context_menus.js => browser/components/customizableui/test/browser_customization_context_menus.js
extra : rebase_source : 49cef6ebeee140aefdb7a90d64b48c0da8179dc1
2017-08-01 15:46:58 +01:00

60 lines
2.7 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const TEST_PAGE = "http://mochi.test:8888/browser/browser/components/customizableui/test/support/test_967000_charEncoding_page.html";
add_task(async function() {
info("Check Character Encoding panel functionality");
// add the Character Encoding button to the panel
CustomizableUI.addWidgetToArea("characterencoding-button",
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE, true, true);
await document.getElementById("nav-bar").overflowable.show();
let charEncodingButton = document.getElementById("characterencoding-button");
let characterEncodingView = document.getElementById("PanelUI-characterEncodingView");
let subviewShownPromise = subviewShown(characterEncodingView);
charEncodingButton.click();
await subviewShownPromise;
let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
let initialEncoding = checkedButtons[0];
is(initialEncoding.getAttribute("label"), "Unicode", "The unicode encoding is initially selected");
// change the encoding
let encodings = characterEncodingView.querySelectorAll("toolbarbutton");
let newEncoding = encodings[0].hasAttribute("checked") ? encodings[1] : encodings[0];
let tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE);
newEncoding.click();
await tabLoadPromise;
// check that the new encodng is applied
await document.getElementById("nav-bar").overflowable.show();
charEncodingButton.click();
checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
let selectedEncodingName = checkedButtons[0].getAttribute("label");
ok(selectedEncodingName != "Unicode", "The encoding was changed to " + selectedEncodingName);
// reset the initial encoding
await document.getElementById("nav-bar").overflowable.show();
charEncodingButton.click();
tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE);
initialEncoding.click();
await tabLoadPromise;
await document.getElementById("nav-bar").overflowable.show();
charEncodingButton.click();
checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
is(checkedButtons[0].getAttribute("label"), "Unicode", "The encoding was reset to Unicode");
await BrowserTestUtils.removeTab(newTab);
});
add_task(async function asyncCleanup() {
// reset the panel to the default state
await resetCustomization();
ok(CustomizableUI.inDefaultState, "The UI is in default state again.");
});