test_notAllowedToStartAudioContextGC.html (1603B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test GC for not-allow-to-start audio context</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 7 </head> 8 <body> 9 <pre id="test"> 10 <script class="testbody" type="text/javascript"> 11 12 SimpleTest.requestFlakyTimeout(`Checking that something does not happen`); 13 14 SimpleTest.waitForExplicitFinish(); 15 16 var destId; 17 18 function observer(subject, topic, data) { 19 let id = parseInt(data); 20 ok(id != destId, "dropping another node, not the context's destination"); 21 } 22 23 SpecialPowers.addAsyncObserver(observer, "webaudio-node-demise", false); 24 SimpleTest.registerCleanupFunction(function() { 25 SpecialPowers.removeAsyncObserver(observer, "webaudio-node-demise"); 26 }); 27 28 SpecialPowers.pushPrefEnv({"set": [["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.BLOCKED], 29 ["media.autoplay.blocking_policy", 0]]}, 30 startTest); 31 32 function startTest() { 33 info("- create audio context -"); 34 let ac = new AudioContext(); 35 36 info("- get node Id -"); 37 destId = SpecialPowers.getPrivilegedProps(ac.destination, "id"); 38 39 info("- trigger GCs -"); 40 SpecialPowers.forceGC(); 41 SpecialPowers.forceCC(); 42 SpecialPowers.forceGC(); 43 44 info("- after three GCs -"); 45 46 // We're doing this async so that we can receive observerservice messages. 47 setTimeout(function() { 48 ok(true, `AudioContext that has been prevented 49 from starting has correctly survived GC`) 50 SimpleTest.finish(); 51 }, 1); 52 } 53 54 </script> 55 </pre> 56 </body> 57 </html>