Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 2 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /webaudio/the-audio-api/the-audioparam-interface/audioparam-large-endtime.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<title>
AudioParam with Huge End Time
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/webaudio/resources/audit-util.js"></script>
<script src="/webaudio/resources/audit.js"></script>
</head>
<body>
<script id="layout-test-code">
let sampleRate = 48000;
// Render for some small (but fairly arbitrary) time.
let renderDuration = 0.125;
// Any huge time value that won't fit in a size_t (2^64 on a 64-bit
// machine).
let largeTime = 1e300;
let audit = Audit.createTaskRunner();
// See crbug.com/582701. Create an audioparam with a huge end time and
// verify that to automation is run. We don't care about the actual
// results, just that it runs.
// Test linear ramp with huge end time
audit.define('linearRamp', (task, should) => {
let graph = createGraph();
graph.gain.gain.linearRampToValueAtTime(0.1, largeTime);
graph.source.start();
graph.context.startRendering()
.then(function(buffer) {
should(true, 'linearRampToValue(0.1, ' + largeTime + ')')
.message('successfully rendered', 'unsuccessfully rendered');
})
.then(() => task.done());
});
// Test exponential ramp with huge end time
audit.define('exponentialRamp', (task, should) => {
let graph = createGraph();
graph.gain.gain.exponentialRampToValueAtTime(.1, largeTime);
graph.source.start();
graph.context.startRendering()
.then(function(buffer) {
should(true, 'exponentialRampToValue(0.1, ' + largeTime + ')')
.message('successfully rendered', 'unsuccessfully rendered');
})
.then(() => task.done());
});
audit.run();
// Create the graph and return the context, the source, and the gain node.
function createGraph() {
let context =
new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
let src = context.createBufferSource();
src.buffer = createConstantBuffer(context, 1, 1);
src.loop = true;
let gain = context.createGain();
src.connect(gain);
gain.connect(context.destination);
gain.gain.setValueAtTime(1, 0.1 / sampleRate);
return {context: context, gain: gain, source: src};
}
</script>
</body>
</html>