Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test OscillatorNode lifetime and sine phase</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <pre id="test"> |
michael@0 | 10 | <script src="webaudio.js" type="text/javascript"></script> |
michael@0 | 11 | <script class="testbody" type="text/javascript"> |
michael@0 | 12 | |
michael@0 | 13 | const signalLength = 2048; |
michael@0 | 14 | |
michael@0 | 15 | function createOscillator(context) { |
michael@0 | 16 | var osc = context.createOscillator(); |
michael@0 | 17 | osc.start(0); |
michael@0 | 18 | osc.stop(signalLength/context.sampleRate); |
michael@0 | 19 | return osc; |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | function connectUnreferencedOscillator(context, destination) { |
michael@0 | 23 | var osc = createOscillator(context); |
michael@0 | 24 | osc.connect(destination); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | var gTest = { |
michael@0 | 28 | length: signalLength, |
michael@0 | 29 | numberOfChannels: 1, |
michael@0 | 30 | createGraph: function(context) { |
michael@0 | 31 | var blend = context.createGain(); |
michael@0 | 32 | |
michael@0 | 33 | connectUnreferencedOscillator(context, blend); |
michael@0 | 34 | // Test that the unreferenced oscillator remains alive until it has finished. |
michael@0 | 35 | SpecialPowers.forceGC(); |
michael@0 | 36 | SpecialPowers.forceCC(); |
michael@0 | 37 | |
michael@0 | 38 | // Create another sine wave oscillator in negative time, which should |
michael@0 | 39 | // cancel when mixed with the unreferenced oscillator. |
michael@0 | 40 | var oscillator = createOscillator(context); |
michael@0 | 41 | oscillator.frequency.value = -440; |
michael@0 | 42 | oscillator.connect(blend); |
michael@0 | 43 | |
michael@0 | 44 | return blend; |
michael@0 | 45 | }, |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | runTest(); |
michael@0 | 49 | |
michael@0 | 50 | </script> |
michael@0 | 51 | </pre> |
michael@0 | 52 | </body> |
michael@0 | 53 | </html> |