1 function runLateStartTest(audit, context, node) {
3 // Set up a dummy signal path to keep the audio context running and spend
4 // processing time before calling start(0).
5 var osc = context.createOscillator();
6 var silent = context.createGain();
9 silent.connect(context.destination);
10 silent.gain.setValueAtTime(0.0, 0);
13 node.connect(context.destination);
15 // Task: define |onstatechange| and start rendering.
16 audit.defineTask('test-late-start', function (done) {
18 // Trigger playback at 0 second. The assumptions are:
20 // 1) The specified timing of start() call is already passed in terms of
21 // the context time. So the argument |0| will be clamped to the current
23 // 2) The |onstatechange| event will be fired later than the 0 second
26 // See issue: crbug.com/462167
27 context.onstatechange = function () {
28 if (context.state === 'running') {
33 // Start rendering and verify result: this verifies if 1) the rendered
34 // buffer contains at least one non-zero value and 2) the non-zero value is
35 // found later than the first output sample.
36 context.startRendering().then(function (buffer) {
38 var nonZeroValueIndex = -1;
39 var channelData = buffer.getChannelData(0);
40 for (var i = 0; i < channelData.length; i++) {
41 if (channelData[i] !== 0) {
42 nonZeroValueIndex = i;
47 if (nonZeroValueIndex === -1) {
48 testFailed('The rendered buffer was all zeros.');
49 } else if (nonZeroValueIndex === 0) {
50 testFailed('The first sample was non-zero value. It should be zero.');
52 testPassed('The rendered buffer contains non-zero values after the first sample.');
59 audit.defineTask('finish-test', function (done) {