tor-browser

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

audit.js (982B)


      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 {
      8  AUDIT,
      9  AUDIT_PROGRESS,
     10  AUDITING,
     11  FILTER_TOGGLE,
     12  FILTERS,
     13 } = require("resource://devtools/client/accessibility/constants.js");
     14 
     15 exports.filterToggle =
     16  filter =>
     17  ({ dispatch }) =>
     18    dispatch({ filter, type: FILTER_TOGGLE });
     19 
     20 exports.auditing =
     21  filter =>
     22  ({ dispatch }) => {
     23    const auditing = filter === FILTERS.ALL ? Object.values(FILTERS) : [filter];
     24    return dispatch({ auditing, type: AUDITING });
     25  };
     26 
     27 exports.audit =
     28  (auditFunc, filter) =>
     29  ({ dispatch }) =>
     30    auditFunc(filter, progress =>
     31      dispatch({ type: AUDIT_PROGRESS, progress })
     32    ).then(({ error, ancestries }) => {
     33      return error
     34        ? dispatch({ type: AUDIT, error: true })
     35        : dispatch({ type: AUDIT, response: ancestries });
     36    });