tor-browser

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

browser_flexible_space_area.js (1525B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 function getSpringCount(area) {
      7  return CustomizableUI.getWidgetIdsInArea(area).filter(id =>
      8    id.includes("spring")
      9  ).length;
     10 }
     11 
     12 /**
     13 * Check that no matter where we add a flexible space, we
     14 * never end up without a flexible space in the palette.
     15 */
     16 add_task(async function test_flexible_space_addition() {
     17  await startCustomizing();
     18  let palette = document.getElementById("customization-palette");
     19  // Make the bookmarks toolbar visible:
     20  CustomizableUI.setToolbarVisibility(CustomizableUI.AREA_BOOKMARKS, true);
     21  let areas = [CustomizableUI.AREA_NAVBAR, CustomizableUI.AREA_BOOKMARKS];
     22  if (AppConstants.platform != "macosx") {
     23    areas.push(CustomizableUI.AREA_MENUBAR);
     24  }
     25 
     26  for (let area of areas) {
     27    let spacer = palette.querySelector("toolbarspring");
     28    let toolbar = document.getElementById(area);
     29    toolbar = CustomizableUI.getCustomizationTarget(toolbar);
     30 
     31    let springCount = getSpringCount(area);
     32    simulateItemDrag(spacer, toolbar);
     33    // Check we added the spring:
     34    is(
     35      springCount + 1,
     36      getSpringCount(area),
     37      "Should now have an extra spring"
     38    );
     39 
     40    // Check there's still one in the palette:
     41    let newSpacer = palette.querySelector("toolbarspring");
     42    ok(newSpacer, "Should have created a new spring");
     43  }
     44 });
     45 registerCleanupFunction(async function asyncCleanup() {
     46  await endCustomizing();
     47  await resetCustomization();
     48 });