tor-browser

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

browser_913972_currentset_overflow.js (2605B)


      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 var navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
      8 
      9 registerCleanupFunction(async function asyncCleanup() {
     10  await resetCustomization();
     11 });
     12 
     13 add_setup(async function () {
     14  await SpecialPowers.pushPrefEnv({
     15    set: [["browser.search.widget.new", false]],
     16  });
     17 });
     18 
     19 // Default state no longer overflows at minimum window width (bug 1960002).
     20 // Add buttons to trigger overflow, resize to a small window, resize back,
     21 // shouldn't change state.
     22 add_task(async function () {
     23  ok(
     24    !navbar.hasAttribute("overflowing"),
     25    "Should start with a non-overflowing toolbar."
     26  );
     27  let originalWindowWidth = ensureToolbarOverflow(window, false);
     28  let navbarTarget = CustomizableUI.getCustomizationTarget(navbar);
     29  let oldChildCount = navbarTarget.childElementCount;
     30  let placements = [...navbarTarget.children].map(node => node.id);
     31  await TestUtils.waitForCondition(
     32    () => navbar.hasAttribute("overflowing"),
     33    "Navbar has a overflowing attribute"
     34  );
     35  ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
     36  window.resizeTo(originalWindowWidth, window.outerHeight);
     37  await TestUtils.waitForCondition(
     38    () => !navbar.hasAttribute("overflowing"),
     39    "Navbar does not have an overflowing attribute"
     40  );
     41  ok(
     42    !navbar.hasAttribute("overflowing"),
     43    "Should no longer have an overflowing toolbar."
     44  );
     45 
     46  // Verify actual physical placements match those of the placement array:
     47  let placementCounter = 0;
     48  for (let node of navbarTarget.children) {
     49    if (node.getAttribute("skipintoolbarset") == "true") {
     50      continue;
     51    }
     52    is(
     53      placements[placementCounter++],
     54      node.id,
     55      "Nodes should match after overflow"
     56    );
     57  }
     58  is(
     59    placements.length,
     60    placementCounter,
     61    "Should have as many nodes as expected"
     62  );
     63  is(
     64    navbarTarget.childElementCount,
     65    oldChildCount,
     66    "Number of nodes should match"
     67  );
     68  await CustomizableUI.reset();
     69 });
     70 
     71 // Enter and exit customization mode, check that default state is correct.
     72 add_task(async function () {
     73  ok(CustomizableUI.inDefaultState, "Should start in default state.");
     74  await startCustomizing();
     75  ok(
     76    CustomizableUI.inDefaultState,
     77    "Should be in default state in customization mode."
     78  );
     79  await endCustomizing();
     80  ok(
     81    CustomizableUI.inDefaultState,
     82    "Should be in default state after customization mode."
     83  );
     84 });