tor-browser

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

mockCommandClient.js (1171B)


      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 export function createSource(name, code) {
      6  name = name.replace(/\..*$/, "");
      7  return {
      8    source: code || `function ${name}() {\n  return ${name} \n}`,
      9    contentType: "text/javascript",
     10  };
     11 }
     12 
     13 const sources = [
     14  "a",
     15  "b",
     16  "foo",
     17  "bar",
     18  "foo1",
     19  "foo2",
     20  "a.js",
     21  "baz.js",
     22  "foobar.js",
     23  "barfoo.js",
     24  "foo.js",
     25  "bar.js",
     26  "base.js",
     27  "bazz.js",
     28  "jquery.js",
     29 ];
     30 
     31 export const mockCommandClient = {
     32  sourceContents({ source }) {
     33    return new Promise((resolve, reject) => {
     34      if (sources.includes(source)) {
     35        resolve(createSource(source));
     36      }
     37 
     38      reject(`unknown source: ${source}`);
     39    });
     40  },
     41  setBreakpoint: async () => {},
     42  removeBreakpoint: _id => Promise.resolve(),
     43  threadFront: async () => {},
     44  getFrameScopes: async () => {},
     45  getFrames: async () => [],
     46  evaluateExpressions: async () => {},
     47  getSourceActorBreakpointPositions: async () => ({}),
     48  getSourceActorBreakableLines: async () => [],
     49 };