| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="../resources/audit-util.js"></script> | 6 <script src="../resources/audit-util.js"></script> |
| 6 <script src="../resources/audio-testing.js"></script> | 7 <script src="../resources/audio-testing.js"></script> |
| 7 <title>AudioParam with Huge End Time</title> | 8 <title>AudioParam with Huge End Time</title> |
| 8 </head> | 9 </head> |
| 9 | 10 |
| 10 <body> | 11 <body> |
| 11 <script> | 12 <script> |
| 12 description("Test AudioParam with Huge Time Value") | |
| 13 window.jsTestIsAsync = true; | |
| 14 | |
| 15 var sampleRate = 48000; | 13 var sampleRate = 48000; |
| 16 // Render for some small (but fairly arbitrary) time. | 14 // Render for some small (but fairly arbitrary) time. |
| 17 var renderDuration = 0.125; | 15 var renderDuration = 0.125; |
| 18 // Any huge time value that won't fit in a size_t (2^64 on a 64-bit machin
e). | 16 // Any huge time value that won't fit in a size_t (2^64 on a 64-bit machin
e). |
| 19 var largeTime = 1e300; | 17 var largeTime = 1e300; |
| 20 | 18 |
| 21 var audit = Audit.createTaskRunner(); | 19 var audit = Audit.createTaskRunner(); |
| 22 | 20 |
| 23 // See crbug.com/582701. Create an audioparam with a huge end time and ve
rify that to | 21 // See crbug.com/582701. Create an audioparam with a huge end time and ve
rify that to |
| 24 // automation is run. We don't care about the actual results, just that i
t runs. | 22 // automation is run. We don't care about the actual results, just that i
t runs. |
| 25 | 23 |
| 26 // Test linear ramp with huge end time | 24 // Test linear ramp with huge end time |
| 27 audit.defineTask("linearRamp", function (done) { | 25 audit.defineTask("linearRamp", function (done) { |
| 28 var graph = createGraph(); | 26 var graph = createGraph(); |
| 29 graph.gain.gain.linearRampToValueAtTime(0.1, largeTime); | 27 graph.gain.gain.linearRampToValueAtTime(0.1, largeTime); |
| 30 | 28 |
| 31 graph.source.start(); | 29 graph.source.start(); |
| 32 graph.context.startRendering().then(function (buffer) { | 30 graph.context.startRendering().then(function (buffer) { |
| 33 testPassed("linearRampToValue(0.1, " + largeTime + ") successfully ren
dered."); | 31 Should("linearRampToValue(0.1, " + largeTime + ")", true) |
| 32 .summarize("successfully rendered", |
| 33 "unsuccessfully rendered"); |
| 34 }).then(done); | 34 }).then(done); |
| 35 }); | 35 }); |
| 36 | 36 |
| 37 // Test exponential ramp with huge end time | 37 // Test exponential ramp with huge end time |
| 38 audit.defineTask("exponentialRamp", function (done) { | 38 audit.defineTask("exponentialRamp", function (done) { |
| 39 var graph = createGraph(); | 39 var graph = createGraph(); |
| 40 graph.gain.gain.exponentialRampToValueAtTime(.1, largeTime); | 40 graph.gain.gain.exponentialRampToValueAtTime(.1, largeTime); |
| 41 | 41 |
| 42 graph.source.start(); | 42 graph.source.start(); |
| 43 graph.context.startRendering().then(function (buffer) { | 43 graph.context.startRendering().then(function (buffer) { |
| 44 testPassed("exponentialRampToValue(0.1, " + largeTime + ") successfull
y rendered."); | 44 Should("exponentialRampToValue(0.1, " + largeTime + ")", true) |
| 45 .summarize("successfully rendered", |
| 46 "unsuccessfully rendered"); |
| 45 }).then(done); | 47 }).then(done); |
| 46 }); | 48 }); |
| 47 | 49 |
| 48 audit.defineTask("finish", function (done) { | 50 audit.defineTask("finish", function (done) { |
| 49 finishJSTest(); | |
| 50 done(); | 51 done(); |
| 51 }); | 52 }); |
| 52 | 53 |
| 53 audit.runTasks(); | 54 audit.runTasks(); |
| 54 | 55 |
| 55 // Create the graph and return the context, the source, and the gain node. | 56 // Create the graph and return the context, the source, and the gain node. |
| 56 function createGraph() { | 57 function createGraph() { |
| 57 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa
mpleRate); | 58 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa
mpleRate); |
| 58 var src = context.createBufferSource(); | 59 var src = context.createBufferSource(); |
| 59 src.buffer = createConstantBuffer(context, 1, 1); | 60 src.buffer = createConstantBuffer(context, 1, 1); |
| 60 src.loop = true; | 61 src.loop = true; |
| 61 var gain = context.createGain(); | 62 var gain = context.createGain(); |
| 62 src.connect(gain); | 63 src.connect(gain); |
| 63 gain.connect(context.destination); | 64 gain.connect(context.destination); |
| 64 gain.gain.setValueAtTime(1, 0.1 / sampleRate); | 65 gain.gain.setValueAtTime(1, 0.1 / sampleRate); |
| 65 | 66 |
| 66 return { | 67 return { |
| 67 context: context, | 68 context: context, |
| 68 gain: gain, | 69 gain: gain, |
| 69 source: src | 70 source: src |
| 70 }; | 71 }; |
| 71 } | 72 } |
| 72 | 73 |
| 73 </script> | 74 </script> |
| 74 </body> | 75 </body> |
| 75 </html> | 76 </html> |
| OLD | NEW |