tor-browser

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

test_worker_in_background_child.js (542B)


      1 function waitForBackground(isBackground, testStage) {
      2  if (WorkerTestUtils.IsRunningInBackground() != isBackground) {
      3    setTimeout(waitForBackground, 100, isBackground, testStage);
      4  } else {
      5    postMessage({
      6      stage: testStage,
      7      status: "PASS",
      8      msg: "",
      9    });
     10  }
     11 }
     12 
     13 onmessage = async e => {
     14  switch (e.data) {
     15    case "CheckIsBackground":
     16      waitForBackground(true, e.data);
     17      break;
     18 
     19    case "CheckIsForeground":
     20    case "CheckIsForegroundAgain":
     21      waitForBackground(false, e.data);
     22      break;
     23  }
     24 };