Bug 1190040 - Part 1: Do not dispatch media-playback notifications for media elements that do not have an audio track; r=cpearce

This commit is contained in:
Ehsan Akhgari 2015-08-05 10:35:29 -04:00
Родитель 226e6417ae
Коммит 41ec611711
4 изменённых файлов: 88 добавлений и 0 удалений

Просмотреть файл

@ -242,6 +242,7 @@ support-files =
file_webaudioLoop.html
file_webaudioLoop2.html
file_pluginAudio.html
noaudio.webm
referrer_helper.js
referrer_testserver.sjs
script_postmessages_fileList.js
@ -299,6 +300,7 @@ skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e1
[test_named_frames.html]
[test_navigator_resolve_identity.html]
[test_navigator_language.html]
[test_noAudioNotification.html]
[test_noAudioNotificationOnMutedElement.html]
[test_noAudioNotificationOnMutedOrVolume0Element.html]
[test_noAudioNotificationOnVolume0Element.html]

Двоичные данные
dom/base/test/noaudio.webm Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,81 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for video controller in windows</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<pre id="test">
</pre>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var observer = {
observe: function(subject, topic, data) {
ok(false, "should not receive audio-playback notification!");
}
};
var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
.getService(SpecialPowers.Ci.nsIObserverService);
var video = document.createElement("video");
video.loop = true;
video.src = "noaudio.webm";
video.onplay = video.onpause = function() {
// Yield to the event loop a few times to make sure that audio-playback is not dispatched.
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
runTest();
});
});
});
};
var tests = [
function() {
SpecialPowers.pushPrefEnv({"set": [["media.useAudioChannelService", true]]}, runTest);
},
function() {
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
runTest();
},
function() {
video.play();
},
function() {
video.pause();
},
function() {
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}
];
function runTest() {
if (!tests.length) {
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
runTest();
</script>
</body>
</html>

Просмотреть файл

@ -4509,6 +4509,11 @@ void HTMLMediaElement::UpdateAudioChannelPlayingState()
void
HTMLMediaElement::NotifyAudioChannelAgent(bool aPlaying)
{
// Don't do anything if this element doesn't have any audio tracks.
if (!HasAudio()) {
return;
}
// Immediately check if this should go to the MSG instead of the normal
// media playback route.
WindowAudioCaptureChanged();