tor-browser

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

browser_972267_customizationchange_events.js (1298B)


      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 // Create a new window, then move the stop/reload button to the menu and check both windows have
      8 // customizationchange events fire on the toolbox:
      9 add_task(async function () {
     10  let newWindow = await openAndLoadWindow();
     11  let otherToolbox = newWindow.gNavToolbox;
     12 
     13  let handlerCalledCount = 0;
     14  let handler = () => {
     15    handlerCalledCount++;
     16  };
     17 
     18  let stopReloadButton = document.getElementById("stop-reload-button");
     19 
     20  gNavToolbox.addEventListener("customizationchange", handler);
     21  otherToolbox.addEventListener("customizationchange", handler);
     22 
     23  await gCustomizeMode.addToPanel(stopReloadButton);
     24 
     25  is(handlerCalledCount, 2, "Should be called for both windows.");
     26 
     27  handlerCalledCount = 0;
     28  gCustomizeMode.addToToolbar(stopReloadButton);
     29  is(handlerCalledCount, 2, "Should be called for both windows.");
     30 
     31  gNavToolbox.removeEventListener("customizationchange", handler);
     32  otherToolbox.removeEventListener("customizationchange", handler);
     33 
     34  await promiseWindowClosed(newWindow);
     35 });
     36 
     37 add_task(async function asyncCleanup() {
     38  await resetCustomization();
     39 });