mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1168788
- Check for devices should check for audio or video not just audio. r=mikedeboer
This commit is contained in:
parent
753fc29e29
commit
b519e0c54f
@ -435,7 +435,7 @@ loop.store.ActiveRoomStore = (function() {
|
||||
// XXX Ideally we'd do this check before joining a room, but we're waiting
|
||||
// for the UX for that. See bug 1166824. In the meantime this gives us
|
||||
// additional information for analysis.
|
||||
loop.shared.utils.hasAudioDevices(function(hasAudio) {
|
||||
loop.shared.utils.hasAudioOrVideoDevices(function(hasAudio) {
|
||||
if (hasAudio) {
|
||||
// MEDIA_WAIT causes the views to dispatch sharedActions.SetupStreamElements,
|
||||
// which in turn starts the sdk obtaining the device permission.
|
||||
|
@ -312,12 +312,12 @@ var inChrome = typeof Components != "undefined" && "utils" in Components;
|
||||
* @param {Function} callback Called with a boolean which is true if there
|
||||
* are audio devices present.
|
||||
*/
|
||||
function hasAudioDevices(callback) {
|
||||
function hasAudioOrVideoDevices(callback) {
|
||||
// mediaDevices is the official API for the spec.
|
||||
if ("mediaDevices" in rootNavigator) {
|
||||
rootNavigator.mediaDevices.enumerateDevices().then(function(result) {
|
||||
function checkForInput(device) {
|
||||
return device.kind === "audioinput";
|
||||
return device.kind === "audioinput" || device.kind === "videoinput";
|
||||
}
|
||||
|
||||
callback(result.some(checkForInput));
|
||||
@ -329,7 +329,7 @@ var inChrome = typeof Components != "undefined" && "utils" in Components;
|
||||
} else if ("MediaStreamTrack" in rootObject) {
|
||||
rootObject.MediaStreamTrack.getSources(function(result) {
|
||||
function checkForInput(device) {
|
||||
return device.kind === "audio";
|
||||
return device.kind === "audio" || device.kind === "video";
|
||||
}
|
||||
|
||||
callback(result.some(checkForInput));
|
||||
@ -745,7 +745,7 @@ var inChrome = typeof Components != "undefined" && "utils" in Components;
|
||||
isFirefoxOS: isFirefoxOS,
|
||||
isOpera: isOpera,
|
||||
getUnsupportedPlatform: getUnsupportedPlatform,
|
||||
hasAudioDevices: hasAudioDevices,
|
||||
hasAudioOrVideoDevices: hasAudioOrVideoDevices,
|
||||
locationData: locationData,
|
||||
atob: atob,
|
||||
btoa: btoa,
|
||||
|
@ -640,7 +640,7 @@ describe("loop.store.ActiveRoomStore", function () {
|
||||
});
|
||||
|
||||
it("should set the state to MEDIA_WAIT if media devices are present", function() {
|
||||
sandbox.stub(loop.shared.utils, "hasAudioDevices").callsArgWith(0, true);
|
||||
sandbox.stub(loop.shared.utils, "hasAudioOrVideoDevices").callsArgWith(0, true);
|
||||
|
||||
store.joinRoom();
|
||||
|
||||
@ -648,7 +648,7 @@ describe("loop.store.ActiveRoomStore", function () {
|
||||
});
|
||||
|
||||
it("should not set the state to MEDIA_WAIT if no media devices are present", function() {
|
||||
sandbox.stub(loop.shared.utils, "hasAudioDevices").callsArgWith(0, false);
|
||||
sandbox.stub(loop.shared.utils, "hasAudioOrVideoDevices").callsArgWith(0, false);
|
||||
|
||||
store.joinRoom();
|
||||
|
||||
@ -656,7 +656,7 @@ describe("loop.store.ActiveRoomStore", function () {
|
||||
});
|
||||
|
||||
it("should dispatch `ConnectionFailure` if no media devices are present", function() {
|
||||
sandbox.stub(loop.shared.utils, "hasAudioDevices").callsArgWith(0, false);
|
||||
sandbox.stub(loop.shared.utils, "hasAudioOrVideoDevices").callsArgWith(0, false);
|
||||
|
||||
store.joinRoom();
|
||||
|
||||
|
@ -141,7 +141,7 @@ describe("loop.shared.utils", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("hasAudioDevices", function() {
|
||||
describe("#hasAudioOrVideoDevices", function() {
|
||||
var fakeNavigatorObject, fakeWindowObject;
|
||||
|
||||
beforeEach(function() {
|
||||
@ -168,17 +168,18 @@ describe("loop.shared.utils", function() {
|
||||
delete fakeNavigatorObject.mediaDevices;
|
||||
delete fakeWindowObject.MediaStreamTrack;
|
||||
|
||||
sharedUtils.hasAudioDevices(function(result) {
|
||||
sharedUtils.hasAudioOrVideoDevices(function(result) {
|
||||
expect(result).eql(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should return false if no audio devices exist according to navigator.mediaDevices", function(done) {
|
||||
it("should return false if no audio nor video devices exist according to navigator.mediaDevices", function(done) {
|
||||
delete fakeWindowObject.MediaStreamTrack;
|
||||
|
||||
fakeNavigatorObject.mediaDevices.enumerateDevices.returns(Promise.resolve([]));
|
||||
sharedUtils.hasAudioDevices(function(result) {
|
||||
|
||||
sharedUtils.hasAudioOrVideoDevices(function(result) {
|
||||
try {
|
||||
expect(result).eql(false);
|
||||
done();
|
||||
@ -193,11 +194,6 @@ describe("loop.shared.utils", function() {
|
||||
|
||||
fakeNavigatorObject.mediaDevices.enumerateDevices.returns(
|
||||
Promise.resolve([{
|
||||
deviceId: "15234",
|
||||
groupId: "",
|
||||
kind: "videoinput",
|
||||
label: ""
|
||||
}, {
|
||||
deviceId: "54321",
|
||||
groupId: "",
|
||||
kind: "audioinput",
|
||||
@ -205,7 +201,7 @@ describe("loop.shared.utils", function() {
|
||||
}])
|
||||
);
|
||||
|
||||
sharedUtils.hasAudioDevices(function(result) {
|
||||
sharedUtils.hasAudioOrVideoDevices(function(result) {
|
||||
try {
|
||||
expect(result).eql(true);
|
||||
done();
|
||||
@ -215,11 +211,33 @@ describe("loop.shared.utils", function() {
|
||||
});
|
||||
});
|
||||
|
||||
it("should return false if no audio devices exist according to window.MediaStreamTrack", function(done) {
|
||||
it("should return true if video devices exist according to navigator.mediaDevices", function(done) {
|
||||
delete fakeWindowObject.MediaStreamTrack;
|
||||
|
||||
fakeNavigatorObject.mediaDevices.enumerateDevices.returns(
|
||||
Promise.resolve([{
|
||||
deviceId: "15234",
|
||||
groupId: "",
|
||||
kind: "videoinput",
|
||||
label: ""
|
||||
}])
|
||||
);
|
||||
|
||||
sharedUtils.hasAudioOrVideoDevices(function(result) {
|
||||
try {
|
||||
expect(result).eql(true);
|
||||
done();
|
||||
} catch (ex) {
|
||||
done(ex);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should return false if no audio nor video devices exist according to window.MediaStreamTrack", function(done) {
|
||||
delete fakeNavigatorObject.mediaDevices;
|
||||
|
||||
fakeWindowObject.MediaStreamTrack.getSources.callsArgWith(0, []);
|
||||
sharedUtils.hasAudioDevices(function(result) {
|
||||
sharedUtils.hasAudioOrVideoDevices(function(result) {
|
||||
try {
|
||||
expect(result).eql(false);
|
||||
done();
|
||||
@ -233,18 +251,33 @@ describe("loop.shared.utils", function() {
|
||||
delete fakeNavigatorObject.mediaDevices;
|
||||
|
||||
fakeWindowObject.MediaStreamTrack.getSources.callsArgWith(0, [{
|
||||
facing: "",
|
||||
id: "15234",
|
||||
kind: "video",
|
||||
label: ""
|
||||
}, {
|
||||
facing: "",
|
||||
id: "54321",
|
||||
kind: "audio",
|
||||
label: ""
|
||||
}]);
|
||||
|
||||
sharedUtils.hasAudioDevices(function(result) {
|
||||
sharedUtils.hasAudioOrVideoDevices(function(result) {
|
||||
try {
|
||||
expect(result).eql(true);
|
||||
done();
|
||||
} catch (ex) {
|
||||
done(ex);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should return true if video devices exist according to window.MediaStreamTrack", function(done) {
|
||||
delete fakeNavigatorObject.mediaDevices;
|
||||
|
||||
fakeWindowObject.MediaStreamTrack.getSources.callsArgWith(0, [{
|
||||
facing: "",
|
||||
id: "15234",
|
||||
kind: "video",
|
||||
label: ""
|
||||
}]);
|
||||
|
||||
sharedUtils.hasAudioOrVideoDevices(function(result) {
|
||||
try {
|
||||
expect(result).eql(true);
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user