browser/components/customizableui/test/browser_967000_button_charEncoding.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     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";
     9 let newTab;
    10 let initialLocation = gBrowser.currentURI.spec;
    12 add_task(function() {
    13   info("Check Character Encoding button functionality");
    15   // add the Character Encoding button to the panel
    16   CustomizableUI.addWidgetToArea("characterencoding-button",
    17                                   CustomizableUI.AREA_PANEL);
    19   // check the button's functionality
    20   yield PanelUI.show();
    22   let charEncodingButton = document.getElementById("characterencoding-button");
    23   ok(charEncodingButton, "The Character Encoding button was added to the Panel Menu");
    24   is(charEncodingButton.getAttribute("disabled"), "true",
    25      "The Character encoding button is initially disabled");
    27   let panelHidePromise = promisePanelHidden(window);
    28   PanelUI.hide();
    29   yield panelHidePromise;
    31   newTab = gBrowser.selectedTab;
    32   yield promiseTabLoadEvent(newTab, TEST_PAGE)
    34   yield PanelUI.show();
    35   ok(!charEncodingButton.hasAttribute("disabled"), "The Character encoding button gets enabled");
    36   charEncodingButton.click();
    38   let characterEncodingView = document.getElementById("PanelUI-characterEncodingView");
    39   ok(characterEncodingView.hasAttribute("current"), "The Character encoding panel is displayed");
    41   let pinnedEncodings = document.getElementById("PanelUI-characterEncodingView-pinned");
    42   let charsetsList = document.getElementById("PanelUI-characterEncodingView-charsets");
    43   ok(pinnedEncodings, "Pinned charsets are available");
    44   ok(charsetsList, "Charsets list is available");
    46   let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
    47   is(checkedButtons.length, 2, "There should be 2 checked items (1 charset, 1 detector).");
    48   is(checkedButtons[0].getAttribute("label"), "Unicode", "The unicode encoding is correctly selected");
    49   is(characterEncodingView.querySelectorAll("#PanelUI-characterEncodingView-autodetect toolbarbutton[checked='true']").length,
    50      1,
    51      "There should be 1 checked detector.");
    53   panelHidePromise = promisePanelHidden(window);
    54   PanelUI.hide();
    55   yield panelHidePromise;
    56 });
    58 add_task(function asyncCleanup() {
    59   // reset the panel to the default state
    60   yield resetCustomization();
    61   ok(CustomizableUI.inDefaultState, "The UI is in default state again.");
    63   // restore the initial location
    64   gBrowser.addTab(initialLocation);
    65   gBrowser.removeTab(newTab);
    66 });

mercurial