bug 815002 - fix browser_device_get_user_media.js to work with --use-test-media-devices. r=florian

This commit is contained in:
Ted Mielczarek 2014-06-02 10:41:57 -04:00
parent c6897ddf69
commit 41a877e7a5
2 changed files with 20 additions and 4 deletions

View File

@ -60,7 +60,7 @@ function expectNoObserverCalled() {
if (gObservedTopics[topic])
is(gObservedTopics[topic], 0, topic + " notification unexpected");
}
gObservedTopics = {}
gObservedTopics = {};
}
function promiseMessage(aMessage, aAction) {
@ -816,7 +816,7 @@ function test() {
finish();
});
}, true);
let rootDir = getRootDirectory(gTestPath)
let rootDir = getRootDirectory(gTestPath);
rootDir = rootDir.replace("chrome://mochitests/content/",
"https://example.com/");
content.location = rootDir + "get_user_media.html";

View File

@ -4,6 +4,19 @@
<body>
<div id="message"></div>
<script>
// Specifies whether we are using fake streams to run this automation
var useFakeStreams = true;
try {
var audioDevice = SpecialPowers.getCharPref("media.audio_loopback_dev");
var videoDevice = SpecialPowers.getCharPref("media.video_loopback_dev");
dump("TEST DEVICES: Using media devices:\n");
dump("audio: " + audioDevice + "\nvideo: " + videoDevice + "\n");
useFakeStreams = false;
} catch (e) {
dump("TEST DEVICES: No test devices found (in media.{audio,video}_loopback_dev, using fake streams.\n");
useFakeStreams = true;
}
function message(m) {
document.getElementById("message").innerHTML = m;
window.parent.postMessage(m, "*");
@ -12,8 +25,11 @@ function message(m) {
var gStream;
function requestDevice(aAudio, aVideo) {
window.navigator.mozGetUserMedia({video: aVideo, audio: aAudio, fake: true},
function(stream) {
var opts = {video: aVideo, audio: aAudio};
if (useFakeStreams) {
opts.fake = true;
}
window.navigator.mozGetUserMedia(opts, function(stream) {
gStream = stream;
message("ok");
}, function(err) { message("error: " + err); });