tor-browser

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

preview.js (2530B)


      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 function empties() {
      6  const a = "";
      7  const b = false;
      8  const c = undefined;
      9  const d = null;
     10  debugger;
     11 }
     12 
     13 function smalls() {
     14  const a = "...";
     15  const b = true;
     16  const c = 1;
     17  const d = [];
     18  const e = {};
     19  debugger;
     20 }
     21 
     22 function objects() {
     23  const obj = {
     24    foo: 1,
     25  };
     26 
     27  const empty = Object.create(null);
     28  const foo = obj?.foo;
     29 
     30  debugger;
     31 }
     32 
     33 function largeArray() {
     34  const bs = [];
     35  for (let i = 0; i <= 100; i++) {
     36    bs.push({ a: 2, b: { c: 3 } });
     37  }
     38  debugger;
     39 }
     40 
     41 function classPreview() {
     42  class Foo {
     43    x = 1;
     44    #privateVar = 2;
     45    static #privateStatic = { first: "a", second: "b" };
     46    #privateMethod() {
     47      return this.#privateVar;
     48    }
     49    breakFn() {
     50      let i = this.x * this.#privateVar + Foo.#privateStatic;
     51      if (#privateVar in this && this.#privateVar !== 0) {
     52        i = i * 2;
     53      }
     54      const y = {
     55        hello: {
     56          foo: "foo",
     57           bar: "bar"
     58        },
     59      };
     60      y;
     61      debugger;
     62    }
     63  }
     64  const foo = new Foo();
     65  foo.breakFn();
     66 }
     67 
     68 function invalidTargets() {
     69  "a";
     70  false;
     71  undefined;
     72  null;
     73  42;
     74  const myVar = "foo";
     75  debugger;
     76  return myVar;
     77 }
     78 
     79 function multipleTokens() {
     80  var foo = {bar: { baz: "bloop"}}, blip = {boom: 0};
     81  foo || blip
     82  foo.bar;
     83  foo.bar.baz;
     84  foo || blip.boom;
     85  debugger;
     86 }
     87 
     88 function thisProperties() {
     89  new(class {
     90    constructor() {
     91      this.myProperty = {
     92        x: "this-myProperty-x",
     93        y: "this-myProperty-y",
     94        z: "this-myProperty-z",
     95      };
     96      this.myProperty.x;
     97      const propertyName = "myProperty";
     98      this[propertyName].y;
     99      this?.[propertyName].z;
    100      debugger;
    101    }
    102  });
    103 }
    104 
    105 function valueOfExpression() {
    106  function a(value) {
    107    b(value).catch(console.error);
    108    debugger;
    109  };
    110 
    111  function b() {
    112    return new Promise(() => {});
    113  }
    114 
    115  a("foo")
    116 }
    117 
    118 const workers = [];
    119 let worker = null;
    120 // This is scenario is used to test `editor.getInScopeLines`
    121 function spawnWorker() {
    122  worker = new Worker("worker.js?id=123");
    123  workers.push(worker);
    124  // Asserts that `worker` token on line 126 is detected as part of the outer scope
    125  // so tooltip previews should be displayed for it.
    126  worker.onmessage = function (e) {
    127    console.log("Message received in main script, from ", e);
    128  };
    129 
    130  worker.onerror = function (e) {
    131    debugger;
    132  };
    133 }