зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1235535) for possibly breaking weightmapping-12579.html CLOSED TREE
Backed out changeset 76209c880c78 (bug 1235535) Backed out changeset 0beb3e22b4b5 (bug 1235535) --HG-- extra : commitid : 2Qv8Y33oGRU
This commit is contained in:
Родитель
52ed1e6ff2
Коммит
a8e5e6c427
|
@ -182,7 +182,60 @@ function audio() {
|
|||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
var tests = [ noaudio, audio ];
|
||||
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 ];
|
||||
|
||||
function runTests() {
|
||||
if (tests.length == 0) {
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
browserElementTestHelpers.addPermission();
|
||||
|
||||
var fileURL = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AudioChannelMutedByDefault.html';
|
||||
var testFrame;
|
||||
var ac;
|
||||
|
||||
function alertListener(e) {
|
||||
var message = e.detail.message
|
||||
if (/^OK/.exec(message)) {
|
||||
ok(true, "Message from file : " + message);
|
||||
} else if (/^KO/.exec(message)) {
|
||||
error(message);
|
||||
} else if (/DONE/.exec(message)) {
|
||||
ok(true, "Audio playback success!");
|
||||
finish();
|
||||
} else {
|
||||
error("Undefined event.");
|
||||
}
|
||||
}
|
||||
|
||||
function assert(aVal, aMessage) {
|
||||
return (!aVal) ? error(aMessage) : 0;
|
||||
}
|
||||
|
||||
function error(aMessage) {
|
||||
ok(false, "Error : " + aMessage);
|
||||
finish();
|
||||
}
|
||||
|
||||
function finish() {
|
||||
testFrame.removeEventListener('mozbrowsershowmodalprompt', alertListener);
|
||||
document.body.removeChild(testFrame);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function setCommand(aArg) {
|
||||
assert(!!ac, "Audio channel doesn't exist!");
|
||||
info("# Command = " + aArg);
|
||||
testFrame.src = fileURL + '#' + aArg;
|
||||
|
||||
switch (aArg) {
|
||||
case 'play':
|
||||
ac.onactivestatechanged = () => {
|
||||
ac.onactivestatechanged = null;
|
||||
ok(true, "activestatechanged event received.");
|
||||
|
||||
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.");
|
||||
}
|
||||
});
|
||||
};
|
||||
break;
|
||||
default :
|
||||
error("Undefined command!");
|
||||
}
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setCommand('play');
|
||||
}
|
||||
|
||||
function setupTestFrame() {
|
||||
testFrame = document.createElement('iframe');
|
||||
testFrame.setAttribute('mozbrowser', 'true');
|
||||
testFrame.setAttribute('mozapp', 'http://example.org/manifest.webapp');
|
||||
testFrame.src = fileURL;
|
||||
|
||||
function loadend() {
|
||||
testFrame.removeEventListener('mozbrowserloadend', loadend);
|
||||
ok("allowedAudioChannels" in testFrame, "allowedAudioChannels exist");
|
||||
var channels = testFrame.allowedAudioChannels;
|
||||
is(channels.length, 1, "1 audio channel by default");
|
||||
|
||||
ac = channels[0];
|
||||
ok(ac instanceof BrowserElementAudioChannel, "Correct class");
|
||||
ok("getMuted" in ac, "ac.getMuted exists");
|
||||
ok("setMuted" in ac, "ac.setMuted exists");
|
||||
ok("onactivestatechanged" in ac, "onactivestatechanged exists");
|
||||
|
||||
runTests();
|
||||
}
|
||||
|
||||
info("Set EventListeners.");
|
||||
testFrame.addEventListener('mozbrowsershowmodalprompt', alertListener);
|
||||
testFrame.addEventListener('mozbrowserloadend', loadend);
|
||||
document.body.appendChild(testFrame);
|
||||
}
|
||||
|
||||
addEventListener('testready', function() {
|
||||
SpecialPowers.pushPrefEnv({'set': [["b2g.system_manifest_url", "http://mochi.test:8888/manifest.webapp"],
|
||||
["dom.audiochannel.mutedByDefault", true]]},
|
||||
function() {
|
||||
SimpleTest.executeSoon(setupTestFrame);
|
||||
});
|
||||
});
|
|
@ -1,65 +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 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>
|
|
@ -0,0 +1,45 @@
|
|||
<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>
|
|
@ -27,7 +27,6 @@ skip-if = toolkit=='gonk'
|
|||
skip-if = (toolkit == 'gonk' && !debug)
|
||||
[test_browserElement_oop_AppWindowNamespace.html]
|
||||
skip-if = (toolkit == 'gonk' && !debug)
|
||||
[test_browserElement_oop_AudioChannelMutedByDefault.html]
|
||||
[test_browserElement_oop_Auth.html]
|
||||
skip-if = (toolkit == 'gonk' && !debug)
|
||||
[test_browserElement_oop_BackForward.html]
|
||||
|
|
|
@ -10,7 +10,6 @@ support-files =
|
|||
browserElement_AllowEmbedAppsInNestedOOIframe.js
|
||||
browserElement_AppFramePermission.js
|
||||
browserElement_AppWindowNamespace.js
|
||||
browserElement_AudioChannelMutedByDefault.js
|
||||
browserElement_AudioPlayback.js
|
||||
browserElement_Auth.js
|
||||
browserElement_BackForward.js
|
||||
|
@ -91,7 +90,6 @@ support-files =
|
|||
file_browserElement_AppFramePermission.html
|
||||
file_browserElement_AppWindowNamespace.html
|
||||
file_browserElement_AudioChannel_nested.html
|
||||
file_browserElement_AudioChannelMutedByDefault.html
|
||||
file_browserElement_Viewmode.html
|
||||
file_browserElement_ThemeColor.html
|
||||
file_browserElement_BrowserWindowNamespace.html
|
||||
|
@ -145,6 +143,7 @@ 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
|
||||
|
@ -163,8 +162,6 @@ skip-if = buildapp == 'b2g'
|
|||
skip-if = toolkit == 'android' || buildapp == 'b2g'
|
||||
[test_browserElement_inproc_AppWindowNamespace.html]
|
||||
skip-if = toolkit == 'android' || buildapp == 'b2g' # android(TIMED_OUT, bug 783509) androidx86(TIMED_OUT, bug 783509)
|
||||
[test_browserElement_inproc_AudioChannelMutedByDefault.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_browserElement_inproc_AudioPlayback.html]
|
||||
[test_browserElement_inproc_Auth.html]
|
||||
skip-if = buildapp == 'b2g'
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1235535 - Audio Channel Muted-By-Default.</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7" src="browserElement_AudioChannelMutedByDefault.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1235535 - Audio Channel Muted-By-Default.</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7" src="browserElement_AudioChannelMutedByDefault.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче