blob: 8f0332fbb012756f203f88170d714adac5737af2 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/compatibility.js"></script>
</head>
<body>
<script>
description("Tests the OfflineAudioContext constructor");
var context;
// Make sure we don't crash when giving 0 as number of frames.
shouldThrow("new OfflineAudioContext(1, 0, 44100)");
// Make sure we don't throw exceptions for supported ranges of sample rates for an OfflineAudioContext.
shouldNotThrow("context = new OfflineAudioContext(2, 512, 3000)");
shouldBeEqualToNumber("context.length", 512);
shouldNotThrow("context = new OfflineAudioContext(2, 1024, 192000)");
shouldBeEqualToNumber("context.length", 1024);
shouldNotThrow("context = new OfflineAudioContext(2, 2048, 8000)");
shouldBeEqualToNumber("context.length", 2048);
shouldNotThrow("context = new OfflineAudioContext(2, 4096, 11025)");
shouldBeEqualToNumber("context.length", 4096);
shouldNotThrow("context = new OfflineAudioContext(2, 512, 22050)");
shouldBeEqualToNumber("context.length", 512);
shouldNotThrow("context = new OfflineAudioContext(2, 512, 44100)");
shouldBeEqualToNumber("context.length", 512);
shouldNotThrow("context = new OfflineAudioContext(2, 512, 48000)");
shouldBeEqualToNumber("context.length", 512);
shouldNotThrow("context = new OfflineAudioContext(2, 512, 88200)");
shouldBeEqualToNumber("context.length", 512);
// Make sure length is read-only.
shouldNotThrow("context.length = 99");
shouldBeEqualToNumber("context.length", 512);
shouldNotThrow("context = new OfflineAudioContext(2, 512, 96000)");
// Make sure we throw exceptions for non-finite sample rates.
shouldThrow("context = new OfflineAudioContext(1, 0, NaN)");
shouldThrow("context = new OfflineAudioContext(1, 0, Infinity)");
// Verify channel counts and other destination attributes are set correctly.
shouldNotThrow("context = new OfflineAudioContext(7, 512, 48000)");
shouldBeEqualToNumber("context.destination.channelCount", 7);
shouldBeEqualToNumber("context.destination.maxChannelCount", 7);
shouldBeEqualToString("context.destination.channelCountMode", "explicit");
shouldBeEqualToString("context.destination.channelInterpretation", "speakers");
</script>
</body>
</html>