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

This commit is contained in:
Ehsan Akhgari 2015-08-01 10:17:56 -04:00
Родитель 7315345693
Коммит 9e8a849881
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_openDialogChromeOnly.html]
[test_open_null_features.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Fails on b2g-desktop, tracked in bug 1011874

Двоичные данные
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 media-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 media-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, "media-playback", false);
ok(true, "Observer set");
runTest();
},
function() {
video.play();
},
function() {
video.pause();
},
function() {
observerService.removeObserver(observer, "media-playback");
ok(true, "Observer removed");
runTest();
}
];
function runTest() {
if (!tests.length) {
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
runTest();
</script>
</body>
</html>

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

@ -4504,6 +4504,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();