tor-browser

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

browser_searchbar_removal.js (1043B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const { SearchWidgetTracker } = ChromeUtils.importESModule(
      7  "moz-src:///browser/components/customizableui/SearchWidgetTracker.sys.mjs"
      8 );
      9 
     10 const SEARCH_BAR_LAST_USED_PREF_NAME = "browser.search.widget.lastUsed";
     11 
     12 add_task(async function checkSearchBarPresent() {
     13  await gCUITestUtils.addSearchBar();
     14  Services.prefs.setStringPref(
     15    SEARCH_BAR_LAST_USED_PREF_NAME,
     16    new Date("2022").toISOString()
     17  );
     18 
     19  Assert.ok(
     20    document.getElementById("searchbar"),
     21    "Search bar should be present in the Nav bar"
     22  );
     23  SearchWidgetTracker._updateSearchBarVisibilityBasedOnUsage();
     24  Assert.ok(
     25    !document.getElementById("searchbar"),
     26    "Search bar should not be present in the Nav bar"
     27  );
     28  Assert.ok(
     29    !CustomizableUI.getPlacementOfWidget("search-container"),
     30    "Should remove the search bar"
     31  );
     32  Services.prefs.clearUserPref(SEARCH_BAR_LAST_USED_PREF_NAME);
     33  gCUITestUtils.removeSearchBar();
     34 });