Bug 1187206 - Adding checks for null SDP, r=jib

This commit is contained in:
Martin Thomson 2015-08-07 16:18:58 -07:00
parent 8390ee2ff1
commit 144c43c724

View File

@ -761,6 +761,13 @@ RTCPeerConnection.prototype = {
"Invalid type " + desc.type + " provided to setLocalDescription",
"InvalidParameterError");
}
if (desc.type !== "rollback" && !desc.sdp) {
throw new this._win.DOMException(
"Empty or null SDP provided to setLocalDescription",
"InvalidParameterError");
}
return this._chain(() => new this._win.Promise((resolve, reject) => {
this._onSetLocalDescriptionSuccess = resolve;
this._onSetLocalDescriptionFailure = reject;
@ -835,21 +842,34 @@ RTCPeerConnection.prototype = {
default:
throw new this._win.DOMException(
"Invalid type " + desc.type + " provided to setRemoteDescription",
"InvalidParameterError");
}
if (!desc.sdp && desc.type !== "rollback") {
throw new this._win.DOMException(
"Empty or null SDP provided to setRemoteDescription",
"InvalidParameterError");
}
// Get caller's origin before hitting the promise chain
let origin = Cu.getWebIDLCallerPrincipal().origin;
// Do setRemoteDescription and identity validation in parallel
return this._chain(() => this._win.Promise.all([
new this._win.Promise((resolve, reject) => {
return this._chain(() => {
let setRem = new this._win.Promise((resolve, reject) => {
this._onSetRemoteDescriptionSuccess = resolve;
this._onSetRemoteDescriptionFailure = reject;
this._impl.setRemoteDescription(type, desc.sdp);
}),
this._validateIdentity(desc.sdp, origin)
])).then(() => {}); // must return undefined
});
if (desc.type === "rollback") {
return setRem;
}
// Do setRemoteDescription and identity validation in parallel
let validId = this._validateIdentity(desc.sdp, origin);
return this._win.Promise.all([setRem, validId])
.then(() => {}); // must return undefined
});
});
},