Bug 1064223 - Remove support for constraint-like RTCOfferOptions predecessor. r=mt
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -674,17 +674,17 @@ RTCPeerConnection.prototype = {
// This entry-point handles both new and legacy call sig. Decipher which one
let onSuccess;
if (typeof optionsOrOnSuccess == "function") {
onSuccess = optionsOrOnSuccess;
} else {
options = optionsOrOnSuccess;
}
return this._legacyCatch(onSuccess, onError, () => {
- // TODO: Remove old constraint-like RTCOptions support soon (Bug 1064223).
+ // TODO: Remove error on constraint-like RTCOptions next cycle (1197021).
// Note that webidl bindings make o.mandatory implicit but not o.optional.
function convertLegacyOptions(o) {
// Detect (mandatory OR optional) AND no other top-level members.
let lcy = ((o.mandatory && Object.keys(o.mandatory).length) || o.optional) &&
Object.keys(o).length == (o.mandatory? 1 : 0) + (o.optional? 1 : 0);
if (!lcy) {
return false;
}
@@ -711,20 +711,21 @@ RTCPeerConnection.prototype = {
if (o[k] === undefined) {
delete o[k];
}
});
return true;
}
if (options && convertLegacyOptions(options)) {
- this.logWarning(
- "Mandatory/optional in createOffer options is deprecated! Use " +
+ this.logError(
+ "Mandatory/optional in createOffer options no longer works! Use " +
JSON.stringify(options) + " instead (note the case difference)!",
null, 0);
+ options = {};
}
let origin = Cu.getWebIDLCallerPrincipal().origin;
return this._chain(() => {
let p = Promise.all([this.getPermission(), this._certificateReady])
.then(() => new this._win.Promise((resolve, reject) => {
this._onCreateOfferSuccess = resolve;
this._onCreateOfferFailure = reject;
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -84,16 +84,17 @@ skip-if = buildapp == 'b2g' || buildapp
[test_peerConnection_bug825703.html]
[test_peerConnection_bug827843.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
[test_peerConnection_bug834153.html]
[test_peerConnection_bug1013809.html]
skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
[test_peerConnection_bug1042791.html]
skip-if = buildapp == 'b2g' || buildapp == 'mulet' || os == 'android' # bug 1043403 # Bug 1141029 Mulet parity with B2G Desktop for TC
+[test_peerConnection_bug1064223.html]
[test_peerConnection_capturedVideo.html]
tags=capturestream
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
[test_peerConnection_captureStream_canvas_2d.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
[test_peerConnection_captureStream_canvas_webgl.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
# [test_peerConnection_certificates.html] # bug 1180968
--- a/dom/media/tests/mochitest/pc.js
+++ b/dom/media/tests/mochitest/pc.js
@@ -1249,72 +1249,16 @@ PeerConnectionWrapper.prototype = {
*/
countTracksInConstraint : function(type, constraints) {
if (!Array.isArray(constraints)) {
return 0;
}
return constraints.reduce((sum, c) => sum + (c[type] ? 1 : 0), 0);
},
- /**
- * Checks for audio in given offer options.
- *
- * @param options
- * The options to be examined.
- */
- audioInOfferOptions : function(options) {
- if (!options) {
- return 0;
- }
-
- var offerToReceiveAudio = options.offerToReceiveAudio;
-
- // TODO: Remove tests of old constraint-like RTCOptions soon (Bug 1064223).
- if (options.mandatory && options.mandatory.OfferToReceiveAudio !== undefined) {
- offerToReceiveAudio = options.mandatory.OfferToReceiveAudio;
- } else if (options.optional && options.optional[0] &&
- options.optional[0].OfferToReceiveAudio !== undefined) {
- offerToReceiveAudio = options.optional[0].OfferToReceiveAudio;
- }
-
- if (offerToReceiveAudio) {
- return 1;
- } else {
- return 0;
- }
- },
-
- /**
- * Checks for video in given offer options.
- *
- * @param options
- * The options to be examined.
- */
- videoInOfferOptions : function(options) {
- if (!options) {
- return 0;
- }
-
- var offerToReceiveVideo = options.offerToReceiveVideo;
-
- // TODO: Remove tests of old constraint-like RTCOptions soon (Bug 1064223).
- if (options.mandatory && options.mandatory.OfferToReceiveVideo !== undefined) {
- offerToReceiveVideo = options.mandatory.OfferToReceiveVideo;
- } else if (options.optional && options.optional[0] &&
- options.optional[0].OfferToReceiveVideo !== undefined) {
- offerToReceiveVideo = options.optional[0].OfferToReceiveVideo;
- }
-
- if (offerToReceiveVideo) {
- return 1;
- } else {
- return 0;
- }
- },
-
checkLocalMediaTracks : function() {
var observed = {};
info(this + " Checking local tracks " + JSON.stringify(this.expectedLocalTrackInfoById));
this._pc.getSenders().forEach(sender => {
this.checkTrackIsExpected(sender.track, this.expectedLocalTrackInfoById, observed);
});
Object.keys(this.expectedLocalTrackInfoById).forEach(
@@ -1381,32 +1325,32 @@ PeerConnectionWrapper.prototype = {
} else {
this.remoteRequiresTrickleIce = requiresTrickleIce;
}
//TODO: how can we check for absence/presence of m=application?
var audioTracks =
this.countTracksInConstraint('audio', offerConstraintsList) ||
- this.audioInOfferOptions(offerOptions);
+ ((offerOptions && offerOptions.offerToReceiveAudio) ? 1 : 0);
info("expected audio tracks: " + audioTracks);
if (audioTracks == 0) {
ok(!desc.sdp.includes("m=audio"), "audio m-line is absent from SDP");
} else {
ok(desc.sdp.includes("m=audio"), "audio m-line is present in SDP");
ok(desc.sdp.includes("a=rtpmap:109 opus/48000/2"), "OPUS codec is present in SDP");
//TODO: ideally the rtcp-mux should be for the m=audio, and not just
// anywhere in the SDP (JS SDP parser bug 1045429)
ok(desc.sdp.includes("a=rtcp-mux"), "RTCP Mux is offered in SDP");
}
var videoTracks =
this.countTracksInConstraint('video', offerConstraintsList) ||
- this.videoInOfferOptions(offerOptions);
+ ((offerOptions && offerOptions.offerToReceiveVideo) ? 1 : 0);
info("expected video tracks: " + videoTracks);
if (videoTracks == 0) {
ok(!desc.sdp.includes("m=video"), "video m-line is absent from SDP");
} else {
ok(desc.sdp.includes("m=video"), "video m-line is present in SDP");
if (this.h264) {
ok(desc.sdp.includes("a=rtpmap:126 H264/90000"), "H.264 codec is present in SDP");
@@ -1762,21 +1706,21 @@ PeerConnectionWrapper.prototype = {
isnot(numIceConnections, 0, "Number of ICE connections according to stats is not zero");
if (answer.sdp.includes('a=group:BUNDLE')) {
is(numIceConnections, 1, "stats reports exactly 1 ICE connection");
} else {
// This code assumes that no media sections have been rejected due to
// codec mismatch or other unrecoverable negotiation failures.
var numAudioTracks =
this.countTracksInConstraint('audio', offerConstraintsList) ||
- this.audioInOfferOptions(offerOptions);
+ ((offerOptions && offerOptions.offerToReceiveAudio) ? 1 : 0);
var numVideoTracks =
this.countTracksInConstraint('video', offerConstraintsList) ||
- this.videoInOfferOptions(offerOptions);
+ ((offerOptions && offerOptions.offerToReceiveVideo) ? 1 : 0);
var numDataTracks = this.dataChannels.length;
var numAudioVideoDataTracks = numAudioTracks + numVideoTracks + numDataTracks;
info("expected audio + video + data tracks: " + numAudioVideoDataTracks);
is(numAudioVideoDataTracks, numIceConnections, "stats ICE connections matches expected A/V tracks");
}
},
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_bug1064223.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+ createHTML({
+ bug: "1064223",
+ title: "CreateOffer fails without streams or modern RTCOfferOptions"
+ });
+
+ runNetworkTest(function () {
+ var pc = new mozRTCPeerConnection();
+ var options = { mandatory: { OfferToReceiveVideo: true } }; // obsolete
+
+ pc.createOffer(options).then(() => ok(false, "createOffer must fail"),
+ e => is(e.name, "InternalError",
+ "createOffer must fail"))
+ .catch(e => ok(false, e.message))
+ .then(() => {
+ pc.close();
+ networkTestFinished();
+ })
+ .catch(e => ok(false, e.message));
+ });
+</script>
+</pre>
+</body>
+</html>
--- a/dom/media/tests/mochitest/test_peerConnection_offerRequiresReceiveAudio.html
+++ b/dom/media/tests/mochitest/test_peerConnection_offerRequiresReceiveAudio.html
@@ -9,17 +9,15 @@
createHTML({
bug: "850275",
title: "Simple offer media constraint test with audio"
});
runNetworkTest(function() {
var test = new PeerConnectionTest();
test.setMediaConstraints([], [{audio: true}]);
- // TODO: Stop using old constraint-like RTCOptions soon (Bug 1064223).
- // Watch out for case-difference when fixing: { offerToReceiveAudio: true }
- test.setOfferOptions({ mandatory: { OfferToReceiveAudio: true } });
+ test.setOfferOptions({ offerToReceiveAudio: true });
test.run();
});
</script>
</pre>
</body>
</html>
--- a/dom/media/tests/mochitest/test_peerConnection_offerRequiresReceiveVideo.html
+++ b/dom/media/tests/mochitest/test_peerConnection_offerRequiresReceiveVideo.html
@@ -9,17 +9,15 @@
createHTML({
bug: "850275",
title: "Simple offer media constraint test with video"
});
runNetworkTest(function() {
var test = new PeerConnectionTest();
test.setMediaConstraints([], [{video: true}]);
- // TODO: Stop using old constraint-like RTCOptions soon (Bug 1064223).
- // Watch out for case-difference when fixing: { offerToReceiveVideo: true }
- test.setOfferOptions({ optional: [{ OfferToReceiveVideo: true }] });
+ test.setOfferOptions({ offerToReceiveVideo: true });
test.run();
});
</script>
</pre>
</body>
</html>