tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_987640_charEncoding.js (2279B)


      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/. */
      4 
      5 "use strict";
      6 
      7 const TEST_PAGE =
      8  "http://mochi.test:8888/browser/browser/components/customizableui/test/support/test_967000_charEncoding_page.html";
      9 
     10 add_task(async function () {
     11  info("Check Character Encoding panel functionality");
     12 
     13  // add the Character Encoding button to the panel
     14  CustomizableUI.addWidgetToArea(
     15    "characterencoding-button",
     16    CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
     17  );
     18 
     19  await waitForOverflowButtonShown();
     20 
     21  let newTab = await BrowserTestUtils.openNewForegroundTab(
     22    gBrowser,
     23    TEST_PAGE,
     24    true,
     25    true
     26  );
     27 
     28  await document.getElementById("nav-bar").overflowable.show();
     29  let charEncodingButton = document.getElementById("characterencoding-button");
     30 
     31  ok(
     32    !charEncodingButton.hasAttribute("disabled"),
     33    "The encoding button should be enabled"
     34  );
     35 
     36  let browserStopPromise = BrowserTestUtils.browserStopped(gBrowser, TEST_PAGE);
     37  charEncodingButton.click();
     38  await browserStopPromise;
     39  is(
     40    gBrowser.selectedBrowser.characterSet,
     41    "UTF-8",
     42    "The encoding should be changed to UTF-8"
     43  );
     44  ok(
     45    !gBrowser.selectedBrowser.mayEnableCharacterEncodingMenu,
     46    "The encoding menu should be disabled"
     47  );
     48 
     49  is(
     50    charEncodingButton.getAttribute("disabled"),
     51    "true",
     52    "We should disable the encoding button in toolbar"
     53  );
     54 
     55  CustomizableUI.removeWidgetFromArea("characterencoding-button");
     56  CustomizableUI.addWidgetToArea(
     57    "characterencoding-button",
     58    CustomizableUI.AREA_FIXED_OVERFLOW_PANEL
     59  );
     60  await waitForOverflowButtonShown();
     61  await document.getElementById("nav-bar").overflowable.show();
     62  charEncodingButton = document.getElementById("characterencoding-button");
     63 
     64  // check the encoding menu again
     65  is(
     66    charEncodingButton.getAttribute("disabled"),
     67    "true",
     68    "We should disable the encoding button in overflow menu"
     69  );
     70 
     71  BrowserTestUtils.removeTab(newTab);
     72 });
     73 
     74 add_task(async function asyncCleanup() {
     75  // reset the panel to the default state
     76  await resetCustomization();
     77  ok(CustomizableUI.inDefaultState, "The UI is in default state again.");
     78 });