diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/webaudio/test/test_ScriptProcessorCollected1.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/webaudio/test/test_ScriptProcessorCollected1.html')
-rw-r--r-- | dom/media/webaudio/test/test_ScriptProcessorCollected1.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_ScriptProcessorCollected1.html b/dom/media/webaudio/test/test_ScriptProcessorCollected1.html new file mode 100644 index 000000000..931f995df --- /dev/null +++ b/dom/media/webaudio/test/test_ScriptProcessorCollected1.html @@ -0,0 +1,84 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test ScriptProcessorNode in cycle with no listener is collected</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<script class="testbody" type="text/javascript"> + +SimpleTest.waitForExplicitFinish(); + +var observer = function(subject, topic, data) { + var id = parseInt(data); + var index = ids.indexOf(id); + if (index != -1) { + ok(true, "Collected AudioNode id " + id + " at index " + index); + ids.splice(index, 1); + } +} + +SpecialPowers.addObserver(observer, "webaudio-node-demise", false); + +SimpleTest.registerCleanupFunction(function() { + if (observer) { + SpecialPowers.removeObserver(observer, "webaudio-node-demise"); + } +}); + +var ac = new AudioContext(); + +var testProcessor = ac.createScriptProcessor(256, 1, 0); +var delay = ac.createDelay(); +testProcessor.connect(delay); +delay.connect(testProcessor); + +var referenceProcessor = ac.createScriptProcessor(256, 1, 0); +var gain = ac.createGain(); +gain.connect(referenceProcessor); + +var processCount = 0; +testProcessor.onaudioprocess = function(event) { + ++processCount; + switch (processCount) { + case 1: + // Switch to listening to referenceProcessor; + referenceProcessor.onaudioprocess = event.target.onaudioprocess; + referenceProcessor = null; + event.target.onaudioprocess = null; + case 2: + // There are no references to testProcessor and so GC can begin. + SpecialPowers.forceGC(); + break; + case 3: + // Another GC should not be required after testProcessor would have + // received another audioprocess event. + SpecialPowers.forceCC(); + // Expect that webaudio-demise has been queued. + // Queue another event to check. + SimpleTest.executeSoon(function() { + SpecialPowers.removeObserver(observer, "webaudio-node-demise"); + observer = null; + event.target.onaudioprocess = null; + ok(ids.length == 0, "All expected nodes should be collected"); + SimpleTest.finish(); + }); + break; + } +}; + +function id(node) { + return SpecialPowers.getPrivilegedProps(node, "id"); +} + +// Nodes with these ids should be collected. +var ids = [ id(testProcessor), id(delay), id(gain) ]; +testProcessor = null; +delay = null; +gain = null; + +</script> +</pre> +</body> +</html> |