tor-browser

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

debug-target-collapsibilities.js (1403B)


      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 PREF_PREFIX = "devtools.aboutdebugging.collapsibilities.";
      8 const {
      9  DEBUG_TARGET_PANE,
     10 } = require("resource://devtools/client/aboutdebugging/src/constants.js");
     11 
     12 /**
     13 * This module provides a collection of helper methods to read and update the debug
     14 * target pane's collapsibilities.
     15 */
     16 
     17 /**
     18 * @return {object}
     19 *         {
     20 *           key: constants.DEBUG_TARGET_PANE
     21 *           value: true - collapsed
     22 *                  false - expanded
     23 *         }
     24 */
     25 function getDebugTargetCollapsibilities() {
     26  const map = new Map();
     27 
     28  for (const key of Object.values(DEBUG_TARGET_PANE)) {
     29    const pref = Services.prefs.getBoolPref(PREF_PREFIX + key, false);
     30    map.set(key, pref);
     31  }
     32 
     33  return map;
     34 }
     35 exports.getDebugTargetCollapsibilities = getDebugTargetCollapsibilities;
     36 
     37 /**
     38 * @param collapsibilities - Same format to getDebugTargetCollapsibilities.
     39 */
     40 function setDebugTargetCollapsibilities(collapsibilities) {
     41  for (const key of Object.values(DEBUG_TARGET_PANE)) {
     42    const isCollapsed = collapsibilities.get(key);
     43    Services.prefs.setBoolPref(PREF_PREFIX + key, isCollapsed);
     44  }
     45 }
     46 exports.setDebugTargetCollapsibilities = setDebugTargetCollapsibilities;