blob: 504d23633ce6d2b7d94d6c3d0d5ef69eeb3606e0 [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 not rendered when tainted by a remote audio resource when CORS is not enabled.");
window.jsTestIsAsync = true;
function go() {
let audio = new Audio();
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(() => {
shouldBe("outputArray", "silentArray");
finishJSTest();
});
});
}
window.addEventListener('load', go);
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>