blob: 467280c2b5b0b95341350bf6661b7cf53fd834d1 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../media-resources/media-file.js"></script>
</head>
<body>
<pre id="console"></pre>
<script>
description("Ensure that audio is rendered when tainted by a remote audio resource when CORS is enabled.");
window.jsTestIsAsync = true;
function go() {
let audio = new Audio();
audio.crossOrigin = "anonymous";
let mediaFile = findMediaFile("audio", "../../media/resources/1000Hz-sin");
let type = mimeTypeForExtension(mediaFile.split('.').pop());
audio.src = "http://localhost:8080/security/resources/video-cross-origin-allow.py?name=" + mediaFile + "&type=" + type;
context = new AudioContext();
let mediaSource = context.createMediaElementSource(audio);
let analyser = context.createAnalyser();
analyser.fftSize = 32;
mediaSource.connect(analyser);
context.resume().then(() => {
audio.play();
});
window.outputArray = new Float32Array(analyser.frequencyBinCount);
window.silentArray = new Float32Array(analyser.frequencyBinCount);
silentArray.fill(-Infinity);
var intervalToken = setInterval(() => {
analyser.getFloatFrequencyData(outputArray);
}, 30);
audio.addEventListener("ended", event => {
clearInterval(intervalToken);
context.suspend().then(() => {
shouldNotBe("outputArray", "silentArray");
finishJSTest();
});
});
}
window.addEventListener('load', go);
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>