tor-browser

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

dominator-tree-worker.js (1185B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 /* eslint-env worker */
      5 
      6 "use strict";
      7 
      8 console.log("Initializing worker.");
      9 
     10 self.onmessage = () => {
     11  console.log("Starting test.");
     12  try {
     13    const path = ChromeUtils.saveHeapSnapshot({ runtime: true });
     14    const snapshot = ChromeUtils.readHeapSnapshot(path);
     15 
     16    const dominatorTree = snapshot.computeDominatorTree();
     17    ok(dominatorTree);
     18    ok(DominatorTree.isInstance(dominatorTree));
     19 
     20    let threw = false;
     21    try {
     22      new DominatorTree();
     23    } catch (excp) {
     24      threw = true;
     25    }
     26    ok(threw, "Constructor shouldn't be usable");
     27  } catch (ex) {
     28    ok(
     29      false,
     30      "Unexpected error inside worker:\n" + ex.toString() + "\n" + ex.stack
     31    );
     32  } finally {
     33    done();
     34  }
     35 };
     36 
     37 // Proxy assertions to the main thread.
     38 function ok(val, msg) {
     39  console.log("ok(" + !!val + ', "' + msg + '")');
     40  self.postMessage({
     41    type: "assertion",
     42    passed: !!val,
     43    msg,
     44    stack: Error().stack,
     45  });
     46 }
     47 
     48 // Tell the main thread we are done with the tests.
     49 function done() {
     50  console.log("done()");
     51  self.postMessage({
     52    type: "done",
     53  });
     54 }