Bug 1308605 - Fail with OverconstrainedError on bad constraint.
MozReview-Commit-ID: JJ1Y3G5b1wl
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1508,28 +1508,23 @@ public:
}
if (mAudioDevice) {
mAudioDevice->Deallocate();
}
}
}
if (errorMsg) {
LOG(("%s %d", errorMsg, rv));
- switch (rv) {
- case NS_ERROR_NOT_AVAILABLE: {
- MOZ_ASSERT(badConstraint);
- Fail(NS_LITERAL_STRING("OverconstrainedError"),
- NS_LITERAL_STRING(""),
- NS_ConvertUTF8toUTF16(badConstraint));
- break;
- }
- default:
- Fail(NS_LITERAL_STRING("NotReadableError"),
- NS_ConvertUTF8toUTF16(errorMsg));
- break;
+ if (badConstraint) {
+ Fail(NS_LITERAL_STRING("OverconstrainedError"),
+ NS_LITERAL_STRING(""),
+ NS_ConvertUTF8toUTF16(badConstraint));
+ } else {
+ Fail(NS_LITERAL_STRING("NotReadableError"),
+ NS_ConvertUTF8toUTF16(errorMsg));
}
return NS_OK;
}
PeerIdentity* peerIdentity = nullptr;
if (!mConstraints.mPeerIdentity.IsEmpty()) {
peerIdentity = new PeerIdentity(mConstraints.mPeerIdentity);
}
@@ -3536,17 +3531,17 @@ GetUserMediaCallbackMediaStreamListener:
}
RefPtr<PledgeVoid> p = mgr->mOutstandingVoidPledges.Remove(id);
if (p) {
if (NS_SUCCEEDED(rv)) {
p->Resolve(false);
} else {
auto* window = nsGlobalWindow::GetInnerWindowWithId(windowId);
if (window) {
- if (rv == NS_ERROR_NOT_AVAILABLE) {
+ if (badConstraint) {
nsString constraint;
constraint.AssignASCII(badConstraint);
RefPtr<MediaStreamError> error =
new MediaStreamError(window->AsInner(),
NS_LITERAL_STRING("OverconstrainedError"),
NS_LITERAL_STRING(""),
constraint);
p->Reject(error);