content/media/webaudio/test/test_oscillatorNode2.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webaudio/test/test_oscillatorNode2.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test OscillatorNode lifetime and sine phase</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.10 +</head>
    1.11 +<body>
    1.12 +<pre id="test">
    1.13 +<script src="webaudio.js" type="text/javascript"></script>
    1.14 +<script class="testbody" type="text/javascript">
    1.15 +
    1.16 +const signalLength = 2048;
    1.17 +
    1.18 +function createOscillator(context) {
    1.19 +  var osc = context.createOscillator();
    1.20 +  osc.start(0);
    1.21 +  osc.stop(signalLength/context.sampleRate);
    1.22 +  return osc;
    1.23 +}
    1.24 +
    1.25 +function connectUnreferencedOscillator(context, destination) {
    1.26 +  var osc = createOscillator(context);
    1.27 +  osc.connect(destination);
    1.28 +}
    1.29 +
    1.30 +var gTest = {
    1.31 +  length: signalLength,
    1.32 +  numberOfChannels: 1,
    1.33 +  createGraph: function(context) {
    1.34 +    var blend = context.createGain();
    1.35 +
    1.36 +    connectUnreferencedOscillator(context, blend);
    1.37 +    // Test that the unreferenced oscillator remains alive until it has finished.
    1.38 +    SpecialPowers.forceGC();
    1.39 +    SpecialPowers.forceCC();
    1.40 +
    1.41 +    // Create another sine wave oscillator in negative time, which should
    1.42 +    // cancel when mixed with the unreferenced oscillator.
    1.43 +    var oscillator = createOscillator(context);
    1.44 +    oscillator.frequency.value = -440;
    1.45 +    oscillator.connect(blend);
    1.46 +
    1.47 +    return blend;
    1.48 +  },
    1.49 +};
    1.50 +
    1.51 +runTest();
    1.52 +
    1.53 +</script>
    1.54 +</pre>
    1.55 +</body>
    1.56 +</html>

mercurial