summaryrefslogtreecommitdiffstats
path: root/dom/media/webaudio/test/test_notAllowedToStartAudioContextGC.html
blob: b8715c16449a878a5e9e5fe537e2302fb44e82c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!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>