| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <html> | 3 <html> |
| 4 <head> | 4 <head> |
| 5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audit.js"></script> |
| 8 <script src="../resources/delay-testing.js"></script> | 9 <script src="../resources/delay-testing.js"></script> |
| 9 </head> | 10 </head> |
| 10 | 11 |
| 11 <body> | 12 <body> |
| 13 <script> |
| 14 let audit = Audit.createTaskRunner(); |
| 12 | 15 |
| 13 <div id="description"></div> | 16 audit.define("test", function (task, should) { |
| 14 <div id="console"></div> | 17 task.describe( |
| 15 | 18 "Basic functionality of DelayNode with a non-default max delay time") |
| 16 <script> | |
| 17 description("Tests basic functionality of DelayNode with a non-default max delay
time."); | |
| 18 | |
| 19 function runTest() { | |
| 20 if (window.testRunner) { | |
| 21 testRunner.dumpAsText(); | |
| 22 testRunner.waitUntilDone(); | |
| 23 } | |
| 24 | |
| 25 window.jsTestIsAsync = true; | |
| 26 | 19 |
| 27 // Create offline audio context. | 20 // Create offline audio context. |
| 28 var context = new OfflineAudioContext(1, sampleRate * renderLengthSeconds, s
ampleRate); | 21 var context = new OfflineAudioContext(1, sampleRate * renderLengthSeconds, s
ampleRate); |
| 29 var toneBuffer = createToneBuffer(context, 20, 20 * toneLengthSeconds, sampl
eRate); // 20Hz tone | 22 var toneBuffer = createToneBuffer(context, 20, 20 * toneLengthSeconds, sampl
eRate); // 20Hz tone |
| 30 | 23 |
| 31 var bufferSource = context.createBufferSource(); | 24 var bufferSource = context.createBufferSource(); |
| 32 bufferSource.buffer = toneBuffer; | 25 bufferSource.buffer = toneBuffer; |
| 33 | 26 |
| 34 // Create a delay node with an explicit max delay time (greater than the def
ault of 1 second). | 27 // Create a delay node with an explicit max delay time (greater than the def
ault of 1 second). |
| 35 var delay = context.createDelay(2); | 28 var delay = context.createDelay(2); |
| 36 // Set the delay time to a value greater than the default max delay so we ca
n verify the delay | 29 // Set the delay time to a value greater than the default max delay so we ca
n verify the delay |
| 37 // is working for this case. | 30 // is working for this case. |
| 38 delayTimeSeconds = 1.5; | 31 delayTimeSeconds = 1.5; |
| 39 delay.delayTime.value = delayTimeSeconds; | 32 delay.delayTime.value = delayTimeSeconds; |
| 40 | 33 |
| 41 bufferSource.connect(delay); | 34 bufferSource.connect(delay); |
| 42 delay.connect(context.destination); | 35 delay.connect(context.destination); |
| 43 bufferSource.start(0); | 36 bufferSource.start(0); |
| 44 | 37 |
| 45 context.oncomplete = checkDelayedResult(toneBuffer); | 38 context.startRendering() |
| 46 context.startRendering(); | 39 .then(buffer => checkDelayedResult(buffer, toneBuffer, should)) |
| 47 } | 40 .then(() => task.done()); |
| 41 }); |
| 48 | 42 |
| 49 runTest(); | 43 audit.run(); |
| 50 | |
| 51 </script> | 44 </script> |
| 52 | 45 |
| 53 </body> | 46 </body> |
| 54 </html> | 47 </html> |
| OLD | NEW |