Bug 1408456 - Convert test_analyserScale.html to a web-platform-test: test-analyser-scale.html. r?karlt
MozReview-Commit-ID: CUhtCzfoi95
--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -29,16 +29,17 @@ support-files =
ting-48k-1ch.wav
ting-48k-2ch.wav
sine-440-10s.opus
webaudio.js
[test_analyserNode.html]
skip-if = !asan || toolkit != android
[test_analyserScale.html]
+skip-if = !asan || toolkit != android
[test_analyserNodeOutput.html]
[test_analyserNodePassThrough.html]
[test_analyserNodeWithGain.html]
skip-if = !asan || toolkit != android
[test_analyserNodeMinimum.html]
[test_AudioBuffer.html]
[test_audioBufferSourceNode.html]
[test_audioBufferSourceNodeEnded.html]
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -380073,16 +380073,22 @@
]
],
"webaudio/the-audio-api/the-analysernode-interface/test-analyser-gain.html": [
[
"/webaudio/the-audio-api/the-analysernode-interface/test-analyser-gain.html",
{}
]
],
+ "webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html": [
+ [
+ "/webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html",
+ {}
+ ]
+ ],
"webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html": [
[
"/webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html",
{}
]
],
"webaudio/the-audio-api/the-audiobuffer-interface/idl-test.html": [
[
@@ -631574,16 +631580,20 @@
"webaudio/the-audio-api/the-analysernode-interface/.gitkeep": [
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
"support"
],
"webaudio/the-audio-api/the-analysernode-interface/test-analyser-gain.html": [
"c3f5f5969ed0ab58a9df332196e138aef8e693f3",
"testharness"
],
+ "webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html": [
+ "1909a2970f0529ad0433c8e6e75733695d44d3e0",
+ "testharness"
+ ],
"webaudio/the-audio-api/the-analysernode-interface/test-analysernode.html": [
"8478aa405a4641a9c47554529762e85a37d7593a",
"testharness"
],
"webaudio/the-audio-api/the-audiobuffer-interface/.gitkeep": [
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
"support"
],
copy from dom/media/webaudio/test/test_analyserScale.html
copy to testing/web-platform/tests/webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html
--- a/dom/media/webaudio/test/test_analyserScale.html
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-analysernode-interface/test-analyser-scale.html
@@ -1,59 +1,49 @@
-<!DOCTYPE HTML>
+<!DOCTYPE html>
<html>
<head>
- <title>Test AnalyserNode when the input is scaled </title>
- <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="webaudio.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-SimpleTest.waitForExplicitFinish();
-addLoadEvent(function() {
+ <meta charset="utf-8">
+ <title>Test AnalyserNode when the input is scaled</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script>
+ var context = new AudioContext();
- var context = new AudioContext();
-
- var gain = context.createGain();
- var analyser = context.createAnalyser();
- var osc = context.createOscillator();
-
+ var gain = context.createGain();
+ var analyser = context.createAnalyser();
+ var osc = context.createOscillator();
- osc.connect(gain);
- gain.connect(analyser);
+ osc.connect(gain);
+ gain.connect(analyser);
- osc.start();
+ osc.start();
- var array = new Uint8Array(analyser.frequencyBinCount);
+ var array = new Uint8Array(analyser.frequencyBinCount);
- function getAnalyserData() {
- gain.gain.setValueAtTime(currentGain, context.currentTime);
- analyser.getByteTimeDomainData(array);
- var inrange = true;
- var max = -1;
- for (var i = 0; i < array.length; i++) {
- if (array[i] > max) {
- max = Math.abs(array[i] - 128);
+ function getAnalyserData() {
+ gain.gain.setValueAtTime(currentGain, context.currentTime);
+ analyser.getByteTimeDomainData(array);
+ var inrange = true;
+ var max = -1;
+ for (var i = 0; i < array.length; i++) {
+ if (array[i] > max) {
+ max = Math.abs(array[i] - 128);
+ }
}
+ if (max <= currentGain * 128) {
+ assert_true(true, "Analyser got scaled data for " + currentGain);
+ currentGain = tests.shift();
+ if (currentGain == undefined) {
+ done();
+ return;
+ }
+ }
+ requestAnimationFrame(getAnalyserData);
}
- if (max <= currentGain * 128) {
- ok(true, "Analyser got scaled data for " + currentGain);
- currentGain = tests.shift();
- if (currentGain == undefined) {
- SimpleTest.finish();
- return;
- }
- }
+
+ var tests = [1.0, 0.5, 0.0];
+ var currentGain = tests.shift();
requestAnimationFrame(getAnalyserData);
- }
-
- var tests = [1.0, 0.5, 0.0];
- var currentGain = tests.shift();
- requestAnimationFrame(getAnalyserData);
-});
-
-</script>
-</pre>
+ </script>
+</head>
</body>
</html>