tor-browser

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

constants.js (7370B)


      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 "use strict";
      5 
      6 const actionTypes = {
      7  APPEND_NOTIFICATION: "APPEND_NOTIFICATION",
      8  APPEND_TO_HISTORY: "APPEND_TO_HISTORY",
      9  AUTOCOMPLETE_CLEAR: "AUTOCOMPLETE_CLEAR",
     10  AUTOCOMPLETE_DATA_RECEIVE: "AUTOCOMPLETE_DATA_RECEIVE",
     11  AUTOCOMPLETE_PENDING_REQUEST: "AUTOCOMPLETE_PENDING_REQUEST",
     12  AUTOCOMPLETE_RETRIEVE_FROM_CACHE: "AUTOCOMPLETE_RETRIEVE_FROM_CACHE",
     13  AUTOCOMPLETE_TOGGLE: "AUTOCOMPLETE_TOGGLE",
     14  BATCH_ACTIONS: "BATCH_ACTIONS",
     15  CLEAR_HISTORY: "CLEAR_HISTORY",
     16  ENABLE_NETWORK_MONITORING: "ENABLE_NETWORK_MONITORING",
     17  EDITOR_TOGGLE: "EDITOR_TOGGLE",
     18  EDITOR_ONBOARDING_DISMISS: "EDITOR_ONBOARDING_DISMISS",
     19  EDITOR_PRETTY_PRINT: "EDITOR_PRETTY_PRINT",
     20  EVALUATE_EXPRESSION: "EVALUATE_EXPRESSION",
     21  SET_TERMINAL_INPUT: "SET_TERMINAL_INPUT",
     22  SET_TERMINAL_EAGER_RESULT: "SET_TERMINAL_EAGER_RESULT",
     23  FILTER_TEXT_SET: "FILTER_TEXT_SET",
     24  FILTER_TOGGLE: "FILTER_TOGGLE",
     25  FILTERS_CLEAR: "FILTERS_CLEAR",
     26  FILTERBAR_DISPLAY_MODE_SET: "FILTERBAR_DISPLAY_MODE_SET",
     27  HISTORY_LOADED: "HISTORY_LOADED",
     28  INITIALIZE: "INITIALIZE",
     29  MESSAGE_CLOSE: "MESSAGE_CLOSE",
     30  MESSAGE_OPEN: "MESSAGE_OPEN",
     31  CSS_MESSAGE_ADD_MATCHING_ELEMENTS: "CSS_MESSAGE_ADD_MATCHING_ELEMENTS",
     32  MESSAGE_REMOVE: "MESSAGE_REMOVE",
     33  MESSAGES_ADD: "MESSAGES_ADD",
     34  MESSAGES_CLEAR: "MESSAGES_CLEAR",
     35  MESSAGES_DISABLE: "MESSAGES_DISABLE",
     36  NETWORK_MESSAGES_UPDATE: "NETWORK_MESSAGES_UPDATE",
     37  NETWORK_UPDATES_REQUEST: "NETWORK_UPDATES_REQUEST",
     38  PERSIST_TOGGLE: "PERSIST_TOGGLE",
     39  PRIVATE_MESSAGES_CLEAR: "PRIVATE_MESSAGES_CLEAR",
     40  REMOVE_NOTIFICATION: "REMOVE_NOTIFICATION",
     41  FRONTS_TO_RELEASE_CLEAR: "FRONTS_TO_RELEASE_CLEAR",
     42  REVERSE_SEARCH_INPUT_TOGGLE: "REVERSE_SEARCH_INPUT_TOGGLE",
     43  SELECT_NETWORK_MESSAGE_TAB: "SELECT_NETWORK_MESSAGE_TAB",
     44  SHOW_OBJECT_IN_SIDEBAR: "SHOW_OBJECT_IN_SIDEBAR",
     45  SIDEBAR_CLOSE: "SIDEBAR_CLOSE",
     46  SPLIT_CONSOLE_CLOSE_BUTTON_TOGGLE: "SPLIT_CONSOLE_CLOSE_BUTTON_TOGGLE",
     47  SHOW_EVALUATION_NOTIFICATION: "SHOW_EVALUATION_NOTIFICATION",
     48  TARGET_MESSAGES_REMOVE: "TARGET_MESSAGES_REMOVE",
     49  TIMESTAMPS_TOGGLE: "TIMESTAMPS_TOGGLE",
     50  UPDATE_HISTORY_POSITION: "UPDATE_HISTORY_POSITION",
     51  REVERSE_SEARCH_INPUT_CHANGE: "REVERSE_SEARCH_INPUT_CHANGE",
     52  REVERSE_SEARCH_NEXT: "REVERSE_SEARCH_NEXT",
     53  REVERSE_SEARCH_BACK: "REVERSE_SEARCH_BACK",
     54  EAGER_EVALUATION_TOGGLE: "EAGER_EVALUATION_TOGGLE",
     55  GROUP_SIMILAR_MESSAGES_TOGGLE: "GROUP_SIMILAR_MESSAGES_TOGGLE",
     56  WILL_NAVIGATE: "WILL_NAVIGATE",
     57  EDITOR_SET_WIDTH: "EDITOR_SET_WIDTH",
     58 };
     59 
     60 const prefs = {
     61  PREFS: {
     62    // Filter preferences only have the suffix since they can be used either for the
     63    // webconsole or the browser console.
     64    FILTER: {
     65      ERROR: "filter.error",
     66      WARN: "filter.warn",
     67      INFO: "filter.info",
     68      LOG: "filter.log",
     69      DEBUG: "filter.debug",
     70      CSS: "filter.css",
     71      NET: "filter.net",
     72      NETXHR: "filter.netxhr",
     73    },
     74    UI: {
     75      // Persist is only used by the webconsole.
     76      PERSIST: "devtools.webconsole.persistlog",
     77      // Max number of entries in history list.
     78      INPUT_HISTORY_COUNT: "devtools.webconsole.inputHistoryCount",
     79      // Is editor mode enabled.
     80      EDITOR: "input.editor",
     81      // Display timestamp in messages.
     82      MESSAGE_TIMESTAMP: "devtools.webconsole.timestampMessages",
     83      // Store the editor width.
     84      EDITOR_WIDTH: "input.editorWidth",
     85      // Show the Editor onboarding UI
     86      EDITOR_ONBOARDING: "devtools.webconsole.input.editorOnboarding",
     87      // Persist the "enable network monitoring" option
     88      ENABLE_NETWORK_MONITORING:
     89        "devtools.browserconsole.enableNetworkMonitoring",
     90    },
     91    FEATURES: {
     92      // We use the same pref to enable the sidebar on webconsole and browser console.
     93      SIDEBAR_TOGGLE: "devtools.webconsole.sidebarToggle",
     94      AUTOCOMPLETE: "devtools.webconsole.input.autocomplete",
     95      EAGER_EVALUATION: "devtools.webconsole.input.eagerEvaluation",
     96      GROUP_SIMILAR_MESSAGES: "devtools.webconsole.groupSimilarMessages",
     97    },
     98  },
     99 };
    100 
    101 const FILTERS = {
    102  CSS: "css",
    103  DEBUG: "debug",
    104  ERROR: "error",
    105  INFO: "info",
    106  LOG: "log",
    107  NET: "net",
    108  NETXHR: "netxhr",
    109  TEXT: "text",
    110  WARN: "warn",
    111 };
    112 
    113 const DEFAULT_FILTERS_VALUES = {
    114  [FILTERS.TEXT]: "",
    115  [FILTERS.ERROR]: true,
    116  [FILTERS.WARN]: true,
    117  [FILTERS.LOG]: true,
    118  [FILTERS.INFO]: true,
    119  [FILTERS.DEBUG]: true,
    120  [FILTERS.CSS]: false,
    121  [FILTERS.NET]: false,
    122  [FILTERS.NETXHR]: false,
    123 };
    124 
    125 const DEFAULT_FILTERS = Object.keys(DEFAULT_FILTERS_VALUES).filter(
    126  filter => DEFAULT_FILTERS_VALUES[filter] !== false
    127 );
    128 
    129 const chromeRDPEnums = {
    130  MESSAGE_SOURCE: {
    131    XML: "xml",
    132    CSS: "css",
    133    JAVASCRIPT: "javascript",
    134    NETWORK: "network",
    135    CONSOLE_API: "console-api",
    136    // Messages emitted by the console frontend itself (i.e. similar messages grouping
    137    // header).
    138    CONSOLE_FRONTEND: "console-frontend",
    139    STORAGE: "storage",
    140    APPCACHE: "appcache",
    141    RENDERING: "rendering",
    142    SECURITY: "security",
    143    OTHER: "other",
    144    DEPRECATION: "deprecation",
    145    // Related to JavaScript Tracer
    146    JSTRACER: "jstracer",
    147  },
    148  MESSAGE_TYPE: {
    149    LOG: "log",
    150    DIR: "dir",
    151    TABLE: "table",
    152    // Related to console.trace() (and not the JavaScript Tracer)
    153    TRACE: "trace",
    154    CLEAR: "clear",
    155    START_GROUP: "startGroup",
    156    START_GROUP_COLLAPSED: "startGroupCollapsed",
    157    END_GROUP: "endGroup",
    158    CONTENT_BLOCKING_GROUP: "contentBlockingWarningGroup",
    159    STORAGE_ISOLATION_GROUP: "storageIsolationWarningGroup",
    160    TRACKING_PROTECTION_GROUP: "trackingProtectionWarningGroup",
    161    COOKIE_GROUP: "cookieGroup",
    162    CORS_GROUP: "CORSWarningGroup",
    163    CSP_GROUP: "CSPWarningGroup",
    164    ASSERT: "assert",
    165    DEBUG: "debug",
    166    PROFILE: "profile",
    167    PROFILE_END: "profileEnd",
    168    // Undocumented in Chrome RDP, but is used for evaluation results.
    169    RESULT: "result",
    170    // Undocumented in Chrome RDP, but is used for input.
    171    COMMAND: "command",
    172    // Undocumented in Chrome RDP, but is used for messages that should not
    173    // output anything (e.g. `console.time()` calls).
    174    NULL_MESSAGE: "nullMessage",
    175    NAVIGATION_MARKER: "navigationMarker",
    176    SIMPLE_TABLE: "simpleTable",
    177    JSTRACER: "jstracer",
    178  },
    179  MESSAGE_LEVEL: {
    180    LOG: "log",
    181    ERROR: "error",
    182    WARN: "warn",
    183    DEBUG: "debug",
    184    INFO: "info",
    185  },
    186 };
    187 
    188 const jstermCommands = {
    189  JSTERM_COMMANDS: {
    190    INSPECT: "inspectObject",
    191  },
    192 };
    193 
    194 // Constants used for defining the direction of JSTerm input history navigation.
    195 const historyCommands = {
    196  HISTORY_BACK: -1,
    197  HISTORY_FORWARD: 1,
    198 };
    199 
    200 const urls = {
    201  // URL opened when executing `:help` command in the input
    202  HELP_URL:
    203    "https://firefox-source-docs.mozilla.org/devtools-user/web_console/helpers/",
    204 };
    205 
    206 const evaluationNotifications = {
    207  ORIGINAL_VARIABLE_MAPPING: "originalVariableMapping",
    208 };
    209 
    210 // Combine into a single constants object
    211 module.exports = Object.assign(
    212  {
    213    FILTERS,
    214    DEFAULT_FILTERS,
    215    DEFAULT_FILTERS_VALUES,
    216    FILTERBAR_DISPLAY_MODES: {
    217      NARROW: "narrow",
    218      WIDE: "wide",
    219    },
    220  },
    221  actionTypes,
    222  chromeRDPEnums,
    223  jstermCommands,
    224  prefs,
    225  historyCommands,
    226  urls,
    227  historyCommands,
    228  evaluationNotifications
    229 );