diff --git a/dom/media/MediaDevices.cpp b/dom/media/MediaDevices.cpp index 2be6f8c35102..e9a9e53c10d8 100644 --- a/dom/media/MediaDevices.cpp +++ b/dom/media/MediaDevices.cpp @@ -93,11 +93,13 @@ already_AddRefed MediaDevices::GetUserMedia( } } } + bool haveFake = aConstraints.mFake.WasPassed() && aConstraints.mFake.Value(); const OwningBooleanOrMediaTrackConstraints& audio = aConstraints.mAudio; bool isMicrophone = - audio.IsBoolean() - ? audio.GetAsBoolean() - : !audio.GetAsMediaTrackConstraints().mMediaSource.WasPassed(); + !haveFake && + (audio.IsBoolean() + ? audio.GetAsBoolean() + : !audio.GetAsMediaTrackConstraints().mMediaSource.WasPassed()); RefPtr self(this); MediaManager::Get() ->GetUserMedia(owner, aConstraints, aCallerType) diff --git a/dom/media/webrtc/tests/mochitests/head.js b/dom/media/webrtc/tests/mochitests/head.js index 5ab6d7509c97..75bdc38aedf1 100644 --- a/dom/media/webrtc/tests/mochitests/head.js +++ b/dom/media/webrtc/tests/mochitests/head.js @@ -418,6 +418,15 @@ function pushPrefs(...p) { return SpecialPowers.pushPrefEnv({ set: p }); } +async function withPrefs(prefs, func) { + await SpecialPowers.pushPrefEnv({ set: prefs }); + try { + return await func(); + } finally { + await SpecialPowers.popPrefEnv(); + } +} + function setupEnvironment() { var defaultMochitestPrefs = { set: [ diff --git a/dom/media/webrtc/tests/mochitests/mochitest.ini b/dom/media/webrtc/tests/mochitests/mochitest.ini index 1704a900031f..a974a53e1beb 100644 --- a/dom/media/webrtc/tests/mochitests/mochitest.ini +++ b/dom/media/webrtc/tests/mochitests/mochitest.ini @@ -61,6 +61,7 @@ scheme=http [test_enumerateDevices.html] [test_enumerateDevices_navigation.html] skip-if = true # Disabled because it is a racy test and causes timeouts, see bug 1650932 +[test_enumerateDevices_getUserMediaFake.html] [test_groupId.html] [test_setSinkId.html] skip-if = diff --git a/dom/media/webrtc/tests/mochitests/test_enumerateDevices_getUserMediaFake.html b/dom/media/webrtc/tests/mochitests/test_enumerateDevices_getUserMediaFake.html new file mode 100644 index 000000000000..4ffb39c3bb4e --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_enumerateDevices_getUserMediaFake.html @@ -0,0 +1,75 @@ + + + + + + + + + +