tor-browser

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

browser_876944_customize_mode_create_destroy.js (1389B)


      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 kTestWidget1 = "test-customize-mode-create-destroy1";
      8 
      9 // Creating and destroying a widget should correctly wrap/unwrap stuff
     10 add_task(async function testWrapUnwrap() {
     11  await startCustomizing();
     12  CustomizableUI.createWidget({
     13    id: kTestWidget1,
     14    label: "Pretty label",
     15    tooltiptext: "Pretty tooltip",
     16  });
     17  let elem = document.getElementById(kTestWidget1);
     18  let wrapper = document.getElementById("wrapper-" + kTestWidget1);
     19  ok(elem, "There should be an item");
     20  ok(wrapper, "There should be a wrapper");
     21  is(
     22    wrapper.firstElementChild.id,
     23    kTestWidget1,
     24    "Wrapper should have test widget"
     25  );
     26  is(
     27    wrapper.parentNode.id,
     28    "customization-palette",
     29    "Wrapper should be in palette"
     30  );
     31  CustomizableUI.destroyWidget(kTestWidget1);
     32  wrapper = document.getElementById("wrapper-" + kTestWidget1);
     33  ok(!wrapper, "There should be a wrapper");
     34  let item = document.getElementById(kTestWidget1);
     35  ok(!item, "There should no longer be an item");
     36 });
     37 
     38 add_task(async function asyncCleanup() {
     39  await endCustomizing();
     40  try {
     41    CustomizableUI.destroyWidget(kTestWidget1);
     42  } catch (ex) {}
     43  await resetCustomization();
     44 });