Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test whether we can create an AudioContext interface</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="webaudio.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body> |
michael@0 | 10 | <pre id="test"> |
michael@0 | 11 | <script class="testbody" type="text/javascript"> |
michael@0 | 12 | |
michael@0 | 13 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 14 | addLoadEvent(function() { |
michael@0 | 15 | var context = new AudioContext(); |
michael@0 | 16 | var buffer = context.createBuffer(1, 2048, context.sampleRate); |
michael@0 | 17 | for (var i = 0; i < 2048; ++i) { |
michael@0 | 18 | buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | var destination = context.destination; |
michael@0 | 22 | is(destination.context, context, "Destination node has proper context"); |
michael@0 | 23 | is(destination.context, context, "Destination node has proper context"); |
michael@0 | 24 | is(destination.numberOfInputs, 1, "Destination node has 1 inputs"); |
michael@0 | 25 | is(destination.numberOfOutputs, 0, "Destination node has 0 outputs"); |
michael@0 | 26 | is(destination.channelCount, 2, "Destination node has 2 input channels by default"); |
michael@0 | 27 | is(destination.channelCountMode, "explicit", "Correct channelCountMode for the destination node"); |
michael@0 | 28 | is(destination.channelInterpretation, "speakers", "Correct channelCountInterpretation for the destination node"); |
michael@0 | 29 | ok(destination instanceof EventTarget, "AudioNodes must be EventTargets"); |
michael@0 | 30 | |
michael@0 | 31 | var source = context.createBufferSource(); |
michael@0 | 32 | is(source.context, context, "Source node has proper context"); |
michael@0 | 33 | is(source.numberOfInputs, 0, "Source node has 0 inputs"); |
michael@0 | 34 | is(source.numberOfOutputs, 1, "Source node has 1 outputs"); |
michael@0 | 35 | is(source.loop, false, "Source node is not looping"); |
michael@0 | 36 | is(source.loopStart, 0, "Correct default value for loopStart"); |
michael@0 | 37 | is(source.loopEnd, 0, "Correct default value for loopEnd"); |
michael@0 | 38 | ok(!source.buffer, "Source node should not have a buffer when it's created"); |
michael@0 | 39 | is(source.channelCount, 2, "source node has 2 input channels by default"); |
michael@0 | 40 | is(source.channelCountMode, "max", "Correct channelCountMode for the source node"); |
michael@0 | 41 | is(source.channelInterpretation, "speakers", "Correct channelCountInterpretation for the source node"); |
michael@0 | 42 | |
michael@0 | 43 | expectException(function() { |
michael@0 | 44 | source.channelCount = 0; |
michael@0 | 45 | }, DOMException.NOT_SUPPORTED_ERR); |
michael@0 | 46 | |
michael@0 | 47 | source.buffer = buffer; |
michael@0 | 48 | ok(source.buffer, "Source node should have a buffer now"); |
michael@0 | 49 | |
michael@0 | 50 | source.connect(destination); |
michael@0 | 51 | |
michael@0 | 52 | is(source.numberOfInputs, 0, "Source node has 0 inputs"); |
michael@0 | 53 | is(source.numberOfOutputs, 1, "Source node has 0 outputs"); |
michael@0 | 54 | is(destination.numberOfInputs, 1, "Destination node has 0 inputs"); |
michael@0 | 55 | is(destination.numberOfOutputs, 0, "Destination node has 0 outputs"); |
michael@0 | 56 | |
michael@0 | 57 | source.start(0); |
michael@0 | 58 | SimpleTest.executeSoon(function() { |
michael@0 | 59 | source.stop(0); |
michael@0 | 60 | source.disconnect(); |
michael@0 | 61 | |
michael@0 | 62 | SpecialPowers.clearUserPref("media.webaudio.enabled"); |
michael@0 | 63 | SimpleTest.finish(); |
michael@0 | 64 | }); |
michael@0 | 65 | }); |
michael@0 | 66 | |
michael@0 | 67 | </script> |
michael@0 | 68 | </pre> |
michael@0 | 69 | </body> |
michael@0 | 70 | </html> |