tor-browser

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

browser_utility_audio_shutdown.js (2170B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // The purpose of that test is to reproduce edge case behaviors that one can
      5 // have while running whole ipc/glue/test/browser/ suite but that could this
      6 // way be intermittent and hard to diagnose. By having such a test we make sure
      7 // it is cleanly reproduced and wont regress somewhat silently.
      8 
      9 "use strict";
     10 
     11 async function runTest(src, process, decoder) {
     12  info(`Add media tabs: ${src}`);
     13  let tab = await addMediaTab(src);
     14 
     15  info("Play tab");
     16  await play(tab, process, decoder);
     17 
     18  info("Stop tab");
     19  await stop(tab);
     20 
     21  info("Remove tab");
     22  await BrowserTestUtils.removeTab(tab);
     23 }
     24 
     25 async function findGenericAudioDecoder() {
     26  const audioDecoders = (await ChromeUtils.requestProcInfo()).children.filter(
     27    p => {
     28      return (
     29        p.type === "utility" &&
     30        p.utilityActors.find(a => a.actorName === "audioDecoder_Generic")
     31      );
     32    }
     33  );
     34  Assert.strictEqual(audioDecoders.length, 1, "Only one audio decoder present");
     35  return audioDecoders[0].pid;
     36 }
     37 
     38 add_task(async function testKill() {
     39  await runTest("small-shot.ogg", "Utility Generic", "ffvpx audio decoder");
     40 
     41  await cleanUtilityProcessShutdown(
     42    "audioDecoder_Generic",
     43    true /* preferKill */
     44  );
     45 
     46  info("Waiting 15s to trigger mShutdownBlockers assertions");
     47  await new Promise(resolve => {
     48    /* eslint-disable mozilla/no-arbitrary-setTimeout */
     49    setTimeout(resolve, 15 * 1000);
     50  });
     51 
     52  ok(true, "Waited 15s to trigger mShutdownBlockers assertions: over");
     53 });
     54 
     55 add_task(async function testShutdown() {
     56  await runTest("small-shot.ogg", "Utility Generic", "ffvpx audio decoder");
     57 
     58  const audioDecoderPid = await findGenericAudioDecoder();
     59  Assert.greater(audioDecoderPid, 0, `Valid PID found: ${audioDecoderPid}`);
     60 
     61  await cleanUtilityProcessShutdown("audioDecoder_Generic");
     62 
     63  info("Waiting 15s to trigger mShutdownBlockers assertions");
     64  await new Promise(resolve => {
     65    /* eslint-disable mozilla/no-arbitrary-setTimeout */
     66    setTimeout(resolve, 15 * 1000);
     67  });
     68 
     69  ok(true, "Waited 15s to trigger mShutdownBlockers assertions: over");
     70 });