Bug 1478837 - Reinstate a few Web Audio API tests in the mochitest directory. r=karlt

MozReview-Commit-ID: 6Bqjuj1BwAJ

--HG--
extra : rebase_source : d2163747ec487e4bf521a27ecd95670125d5555a
This commit is contained in:
Paul Adenot 2018-08-14 12:10:00 +02:00
Родитель 9cb0e90464
Коммит 96df0fd394
6 изменённых файлов: 261 добавлений и 0 удалений

Просмотреть файл

@ -215,6 +215,11 @@ skip-if = toolkit == 'android' # bug 1091965
[test_periodicWave.html]
[test_periodicWaveDisableNormalization.html]
[test_periodicWaveBandLimiting.html]
[test_retrospective-exponentialRampToValueAtTime.html]
[test_retrospective-linearRampToValueAtTime.html]
[test_retrospective-setTargetAtTime.html]
[test_retrospective-setValueAtTime.html]
[test_retrospective-setValueCurveAtTime.html]
[test_ScriptProcessorCollected1.html]
[test_scriptProcessorNode.html]
[test_scriptProcessorNodeChannelCount.html]

Просмотреть файл

@ -0,0 +1,51 @@
<!doctype html>
<meta charset=utf-8>
<title>Test exponentialRampToValue with end time in the past</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
function do_test(t, context) {
var source = context.createConstantSource();
source.start();
var test = context.createGain();
test.gain.exponentialRampToValueAtTime(0.1, 0.5*context.currentTime);
test.gain.exponentialRampToValueAtTime(0.9, 2.0);
var reference = context.createGain();
reference.gain.exponentialRampToValueAtTime(0.1, context.currentTime);
reference.gain.exponentialRampToValueAtTime(0.9, 2.0);
source.connect(test);
source.connect(reference);
var merger = context.createChannelMerger();
test.connect(merger, 0, 0);
reference.connect(merger, 0, 1);
var processor = context.createScriptProcessor(0, 2, 0);
merger.connect(processor);
processor.onaudioprocess =
t.step_func_done((e) => {
source.stop();
processor.onaudioprocess = null;
var testValue = e.inputBuffer.getChannelData(0)[0];
var referenceValue = e.inputBuffer.getChannelData(1)[0];
assert_equals(testValue, referenceValue,
"value matches expected");
});
}
async_test(function(t) {
var context = new AudioContext;
(function waitForTimeAdvance() {
if (context.currentTime == 0) {
t.step_timeout(waitForTimeAdvance, 0);
} else {
do_test(t, context);
}
})();
});
</script>

Просмотреть файл

@ -0,0 +1,51 @@
<!doctype html>
<meta charset=utf-8>
<title>Test linearRampToValue with end time in the past</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
function do_test(t, context) {
var source = context.createConstantSource();
source.start();
var test = context.createGain();
test.gain.linearRampToValueAtTime(0.1, 0.5*context.currentTime);
test.gain.linearRampToValueAtTime(0.9, 2.0);
var reference = context.createGain();
reference.gain.linearRampToValueAtTime(0.1, context.currentTime);
reference.gain.linearRampToValueAtTime(0.9, 2.0);
source.connect(test);
source.connect(reference);
var merger = context.createChannelMerger();
test.connect(merger, 0, 0);
reference.connect(merger, 0, 1);
var processor = context.createScriptProcessor(0, 2, 0);
merger.connect(processor);
processor.onaudioprocess =
t.step_func_done((e) => {
source.stop();
processor.onaudioprocess = null;
var testValue = e.inputBuffer.getChannelData(0)[0];
var referenceValue = e.inputBuffer.getChannelData(1)[0];
assert_equals(testValue, referenceValue,
"value matches expected");
});
}
async_test(function(t) {
var context = new AudioContext;
(function waitForTimeAdvance() {
if (context.currentTime == 0) {
t.step_timeout(waitForTimeAdvance, 0);
} else {
do_test(t, context);
}
})();
});
</script>

Просмотреть файл

@ -0,0 +1,51 @@
<!doctype html>
<meta charset=utf-8>
<title>Test setTargetAtTime with start time in the past</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
function do_test(t, context) {
var source = context.createConstantSource();
source.start();
var test = context.createGain();
test.gain.setTargetAtTime(0.1, 0.5*context.currentTime, 0.1);
test.gain.linearRampToValueAtTime(0.9, 2.0);
var reference = context.createGain();
reference.gain.setTargetAtTime(0.1, context.currentTime, 0.1);
reference.gain.linearRampToValueAtTime(0.9, 2.0);
source.connect(test);
source.connect(reference);
var merger = context.createChannelMerger();
test.connect(merger, 0, 0);
reference.connect(merger, 0, 1);
var processor = context.createScriptProcessor(0, 2, 0);
merger.connect(processor);
processor.onaudioprocess =
t.step_func_done((e) => {
source.stop();
processor.onaudioprocess = null;
var testValue = e.inputBuffer.getChannelData(0)[0];
var referenceValue = e.inputBuffer.getChannelData(1)[0];
assert_equals(testValue, referenceValue,
"value matches expected");
});
}
async_test(function(t) {
var context = new AudioContext;
(function waitForTimeAdvance() {
if (context.currentTime == 0) {
t.step_timeout(waitForTimeAdvance, 0);
} else {
do_test(t, context);
}
})();
});
</script>

Просмотреть файл

@ -0,0 +1,54 @@
<!DOCTYPE html>
<title>Test setValueAtTime with startTime in the past</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function do_test(t, context) {
var source = context.createConstantSource();
source.start();
// Use a ramp of slope 1/sample to measure time.
// The end value is the extent of exact precision in single precision float.
const rampEnd = Math.pow(2, 24);
const rampEndSeconds = rampEnd / context.sampleRate;
var test = context.createGain();
test.gain.setValueAtTime(0.0, 0.5*context.currentTime);
test.gain.linearRampToValueAtTime(rampEnd, rampEndSeconds);
var reference = context.createGain();
reference.gain.setValueAtTime(0.0, context.currentTime);
reference.gain.linearRampToValueAtTime(rampEnd, rampEndSeconds);
source.connect(test);
source.connect(reference);
var merger = context.createChannelMerger();
test.connect(merger, 0, 0);
reference.connect(merger, 0, 1);
var processor = context.createScriptProcessor(0, 2, 0);
merger.connect(processor);
processor.onaudioprocess =
t.step_func_done((e) => {
source.stop();
processor.onaudioprocess = null;
var testValue = e.inputBuffer.getChannelData(0)[0];
var referenceValue = e.inputBuffer.getChannelData(1)[0];
assert_equals(testValue, referenceValue,
"ramp value matches expected");
});
}
async_test(function(t) {
var context = new AudioContext;
(function waitForTimeAdvance() {
if (context.currentTime == 0) {
t.step_timeout(waitForTimeAdvance, 0);
} else {
do_test(t, context);
}
})();
});
</script>

Просмотреть файл

@ -0,0 +1,49 @@
<!doctype html>
<meta charset=utf-8>
<title>Test SetValueCurve with start time in the past</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
function do_test(t, context) {
var source = context.createConstantSource();
source.start();
var test = context.createGain();
test.gain.setValueCurveAtTime(new Float32Array([1.0, 0.1]), 0.0, 1.0);
var reference = context.createGain();
reference.gain.setValueCurveAtTime(new Float32Array([1.0, 0.1]), 0.5*context.currentTime, 1.0);
source.connect(test);
source.connect(reference);
var merger = context.createChannelMerger();
test.connect(merger, 0, 0);
reference.connect(merger, 0, 1);
var processor = context.createScriptProcessor(0, 2, 0);
merger.connect(processor);
processor.onaudioprocess =
t.step_func_done((e) => {
source.stop();
processor.onaudioprocess = null;
var testValue = e.inputBuffer.getChannelData(0)[0];
var referenceValue = e.inputBuffer.getChannelData(1)[0];
assert_equals(testValue, referenceValue,
"value matches expected");
});
}
async_test(function(t) {
var context = new AudioContext;
(function waitForTimeAdvance() {
if (context.currentTime == 0) {
t.step_timeout(waitForTimeAdvance, 0);
} else {
do_test(t, context);
}
})();
});
</script>