зеркало из https://github.com/mozilla/gecko-dev.git
Bug 849230 - Limit the range of sample rates accepted by AudioContext.createBuffer according to the spec; r=padenot
This commit is contained in:
Родитель
13bcb99fd4
Коммит
57f1fe49f8
|
@ -79,6 +79,11 @@ AudioContext::CreateBuffer(JSContext* aJSContext, uint32_t aNumberOfChannels,
|
|||
uint32_t aLength, float aSampleRate,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (aSampleRate < 8000 || aSampleRate > 96000) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aLength > INT32_MAX) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script src="webaudio.js" type="text/javascript"></script>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -34,6 +35,14 @@ addLoadEvent(function() {
|
|||
}
|
||||
ok(!foundNonZero, "Buffer " + i + " should be initialized to 0");
|
||||
}
|
||||
expectException(function() {
|
||||
context.createBuffer(2, 2048, 7999);
|
||||
}, DOMException.DOM_SYNTAX_ERR);
|
||||
expectException(function() {
|
||||
context.createBuffer(2, 2048, 96001);
|
||||
}, DOMException.DOM_SYNTAX_ERR);
|
||||
context.createBuffer(2, 2048, 8000); // no exception
|
||||
context.createBuffer(2, 2048, 96000); // no exception
|
||||
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
|
||||
AudioContext().createBuffer(0, 0, 0);
|
||||
var ctx = new AudioContext();
|
||||
ctx.createBuffer(0, 0, ctx.sampleRate);
|
||||
ok(true, "The test should not crash during CC");
|
||||
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче