Bug 1235535 - Part 1: Remove muted-by-default test. r=baku

This commit is contained in:
Alastor Wu 2016-01-05 19:25:55 +08:00
parent 929149779f
commit 08fea77244
3 changed files with 1 additions and 100 deletions

View File

@ -182,60 +182,7 @@ function audio() {
document.body.appendChild(iframe);
}
function audioMutedByDefault() {
info("Test : audio-muted-by-default");
SpecialPowers.pushPrefEnv(
{'set': [["dom.audiochannel.mutedByDefault", true]]}, function () {
var iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_processingAudioSample.html';
function audio_loadend_MutedByDefault() {
ok("allowedAudioChannels" in iframe, "allowedAudioChannels exist");
var channels = iframe.allowedAudioChannels;
is(channels.length, 1, "1 audio channel by default");
var ac = channels[0];
ok(ac instanceof BrowserElementAudioChannel, "Correct class");
ok("getMuted" in ac, "ac.getMuted exists");
ok("setMuted" in ac, "ac.setMuted exists");
ac.onactivestatechanged = function() {
ok(true, "activestatechanged event received.");
ac.onactivestatechanged = null;
new Promise(function(r, rr) {
ac.getMuted().onsuccess = function(e) {
is(e.target.result, true, "Muted channel by default");
r();
}
})
.then(function() {
ac.setMuted(false).onsuccess = function(e) {
ok(true, "Unmuted the channel.");
}
})
}
var complete = false;
iframe.addEventListener("mozbrowsershowmodalprompt", function (e) {
is(e.detail.message, "playback-success", "Audio playback success!");
if (!complete) {
document.body.removeChild(iframe);
SpecialPowers.popPrefEnv(runTests);
complete = true;
}
});
}
iframe.addEventListener('mozbrowserloadend', audio_loadend_MutedByDefault);
document.body.appendChild(iframe);
});
}
var tests = [ noaudio, audio, audioMutedByDefault ];
var tests = [ noaudio, audio ];
function runTests() {
if (tests.length == 0) {

View File

@ -1,45 +0,0 @@
<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 complete = false;
var iterationCount = 0;
function processSamples(e) {
if (complete) {
return;
}
// Start playing the audio until the AudioContext is connected and running.
if (iterationCount++ == 0) {
audio.play();
}
var buf = e.inputBuffer.getChannelData(0);
for (var i = 0; i < buf.length; ++i) {
if (buf[i] != 0) {
nonzeroSamplesCount++;
}
}
if (nonzeroSamplesCount >= expectedSamplesCount && !complete) {
alert("playback-success");
complete = true;
}
}
audio.oncanplaythrough = function() {
var testDuration = audio.duration > 2.0 ? 2.0 : audio.duration;
expectedSamplesCount = Math.floor(testDuration * context.sampleRate) ;
sp.onaudioprocess = processSamples;
};
</script>
</body>
</html>

View File

@ -143,7 +143,6 @@ support-files =
file_web_manifest.html
file_web_manifest.json
file_illegal_web_manifest.html
file_processingAudioSample.html
noaudio.webm
# Note: browserElementTestHelpers.js looks at the test's filename to determine