diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/browser-element/mochitest/file_browserElement_AudioChannelMutedByDefault.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/browser-element/mochitest/file_browserElement_AudioChannelMutedByDefault.html')
-rw-r--r-- | dom/browser-element/mochitest/file_browserElement_AudioChannelMutedByDefault.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/dom/browser-element/mochitest/file_browserElement_AudioChannelMutedByDefault.html b/dom/browser-element/mochitest/file_browserElement_AudioChannelMutedByDefault.html new file mode 100644 index 000000000..ea4f3bde1 --- /dev/null +++ b/dom/browser-element/mochitest/file_browserElement_AudioChannelMutedByDefault.html @@ -0,0 +1,65 @@ +<html> +<body> +<script> +var audio = new Audio("audio.ogg"); +var context = new AudioContext(); +var node = context.createMediaElementSource(audio); +var sp = context.createScriptProcessor(2048, 1); +node.connect(sp); +var expectedSamplesCount; +var nonzeroSamplesCount = 0; +var isStarted = false; + +function ok(aVal, aMsg) { + alert((!!aVal ? "OK" : "KO") + ", " + aMsg); +} + +function finish() { + audio.onended = null; + audio.pause(); + alert("DONE"); +} + +function processSamples(e) { + var buf = e.inputBuffer.getChannelData(0); + for (var i = 0; i < buf.length; ++i) { + if (buf[i] != 0) { + if (!isStarted) { + isStarted = true; + ok(true, "Start process audio sample."); + } + nonzeroSamplesCount++; + } + } + + if (nonzeroSamplesCount >= expectedSamplesCount) { + finish(); + } +} + +audio.oncanplaythrough = function() { + var testDuration = audio.duration > 1.0 ? 1.0 : audio.duration * 0.5; + expectedSamplesCount = Math.floor(testDuration * context.sampleRate); + sp.onaudioprocess = processSamples; +}; + +function runCommands() +{ + switch(location.hash) { + case '#play': + ok(true, "Audio starts playing.") + audio.play(); + audio.onended = () => { + audio.onended = null; + ok(false, "Audio shouldn't go ended in this test!") + }; + break; + default : + ok(false, "Undefined command!"); + } +} + +window.addEventListener('hashchange', runCommands); +</script> +</body> +</html> |