tor-browser

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

test_ReadHeapSnapshot_worker.js (975B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that we can read core dumps into HeapSnapshot instances in a worker.
      7 add_task(async function () {
      8  const worker = new ChromeWorker("resource://test/heap-snapshot-worker.js");
      9  worker.postMessage({});
     10 
     11  let assertionCount = 0;
     12  worker.onmessage = e => {
     13    if (e.data.type !== "assertion") {
     14      return;
     15    }
     16 
     17    ok(e.data.passed, e.data.msg + "\n" + e.data.stack);
     18    assertionCount++;
     19  };
     20 
     21  await waitForDone(worker);
     22 
     23  Assert.greater(assertionCount, 0);
     24  worker.terminate();
     25 });
     26 
     27 function waitForDone(w) {
     28  return new Promise((resolve, reject) => {
     29    w.onerror = e => {
     30      reject();
     31      ok(false, "Error in worker: " + e);
     32    };
     33 
     34    w.addEventListener("message", function listener(e) {
     35      if (e.data.type === "done") {
     36        w.removeEventListener("message", listener);
     37        resolve();
     38      }
     39    });
     40  });
     41 }