dom/media/webaudio/test/test_notAllowedToStartAudioContextGC.html
author Ting-Yu Lin <tlin@mozilla.com>
Sat, 01 Apr 2023 04:17:05 +0000
changeset 658805 7437637d0b5c2745440bfeba4adb64689d24044f
parent 530211 95805db3a142ece63d388abec9fd1414ae905a3e
permissions -rw-r--r--
Bug 1055894 - Add GetLogicalNormalRect() and adapt some callers of GetNormalRect(). r=emilio This patch makes the API nicer, and shouldn't change the behavior. Differential Revision: https://phabricator.services.mozilla.com/D174344

<!DOCTYPE HTML>
<html>
<head>
  <title>Test GC for not-allow-to-start audio context</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">

SimpleTest.requestFlakyTimeout(`Checking that something does not happen`);

SimpleTest.waitForExplicitFinish();

var destId;

function observer(subject, topic, data) {
  let id = parseInt(data);
  ok(id != destId, "dropping another node, not the context's destination");
}

SpecialPowers.addAsyncObserver(observer, "webaudio-node-demise", false);
SimpleTest.registerCleanupFunction(function() {
  SpecialPowers.removeAsyncObserver(observer, "webaudio-node-demise");
});

SpecialPowers.pushPrefEnv({"set": [["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED],
                                   ["media.autoplay.blocking_policy", 0]]},
                          startTest);

function startTest() {
  info("- create audio context -");
  let ac = new AudioContext();

  info("- get node Id -");
  destId = SpecialPowers.getPrivilegedProps(ac.destination, "id");

  info("- trigger GCs -");
  SpecialPowers.forceGC();
  SpecialPowers.forceCC();
  SpecialPowers.forceGC();

  info("- after three GCs -");

  // We're doing this async so that we can receive observerservice messages.
  setTimeout(function() {
    ok(true, `AudioContext that has been prevented
              from starting has correctly survived GC`)
    SimpleTest.finish();
  }, 1);
}

</script>
</pre>
</body>
</html>