RTCPeerConnection methods can take dictionaries as input
https://bugs.webkit.org/show_bug.cgi?id=167590
Patch by Youenn Fablet <youenn@apple.com> on 2017-01-31
Reviewed by Alex Christensen.
Source/WebCore:
Test: webrtc/rtcpeerconnection-error-messages.html
Made addIceCandidate/setRemoteDescription/setLocalDescription take either dictionaries or objects as parameter.
Spec only mandates this for addIceCandidate, but sites may be using the old version for setRemoteDescription and setLocalDescription.
Updated RTCPeerConnection methods error messages.
* Modules/mediastream/RTCPeerConnection.js:
(getLocalStreams):
(getStreamById):
(addStream):
(createOffer):
(createAnswer):
(setLocalDescription):
(setRemoteDescription):
(addIceCandidate):
(getStats):
* Modules/mediastream/RTCPeerConnectionInternals.js:
LayoutTests:
Replacing fast/mediastream/RTCPeerConnection-js-built-ins-check-this.html by webrtc/rtcpeerconnection-error-messages.html.
It is a bit more thorough and does not hard code the error message.
* fast/mediastream/RTCPeerConnection-addIceCandidate-expected.txt:
* fast/mediastream/RTCPeerConnection-addIceCandidate.html:
* fast/mediastream/RTCPeerConnection-js-built-ins-check-this-expected.txt: Removed.
* fast/mediastream/RTCPeerConnection-js-built-ins-check-this.html: Removed.
* fast/mediastream/RTCPeerConnection-setLocalDescription-offer-expected.txt:
* fast/mediastream/RTCPeerConnection-setLocalDescription-offer.html:
* fast/mediastream/RTCPeerConnection-setRemoteDescription-offer-expected.txt:
* fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html:
* webrtc/rtcpeerconnection-error-messages-expected.txt: Added.
* webrtc/rtcpeerconnection-error-messages.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@211436 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate-expected.txt b/LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate-expected.txt
index 70f9cfa..d41c940 100644
--- a/LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate-expected.txt
+++ b/LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate-expected.txt
@@ -23,7 +23,7 @@
PASS promise pc.addIceCandidate(new RTCIceCandidate({candidate: 'bad content', sdpMLineIndex: sdpMLineIndex})) rejected with OperationError (DOM Exception 34): Invalid candidate content
*** Test some OK input
-PASS promise pc.addIceCandidate(new RTCIceCandidate({candidate: validCandidate, sdpMid: sdpMid})) fulfilled with undefined
+PASS promise pc.addIceCandidate({candidate: validCandidate, sdpMid: sdpMid}) fulfilled with undefined
PASS promise pc.addIceCandidate(new RTCIceCandidate({candidate: validCandidate, sdpMLineIndex: sdpMLineIndex})) fulfilled with undefined
*** A valid sdpMid takes precedesce over a bad sdpMLineIndex
PASS promise pc.addIceCandidate(new RTCIceCandidate({candidate: validCandidate, sdpMid: sdpMid, sdpMLineIndex: badSdpMLineIndex})) fulfilled with undefined
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate.html b/LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate.html
index a45dd92..9f383ff 100644
--- a/LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate.html
+++ b/LayoutTests/fast/mediastream/RTCPeerConnection-addIceCandidate.html
@@ -74,9 +74,11 @@
})
.then(function () {
debug("<br>*** Test some OK input");
- return promiseShouldResolve("pc.addIceCandidate(new RTCIceCandidate({candidate: validCandidate, sdpMid: sdpMid}))");
+ // Testing passing a RTCIceCandidateInit
+ return promiseShouldResolve("pc.addIceCandidate({candidate: validCandidate, sdpMid: sdpMid})");
})
.then(function () {
+ // Testing passing a RTCIceCandidate
return promiseShouldResolve("pc.addIceCandidate(new RTCIceCandidate({candidate: validCandidate, sdpMLineIndex: sdpMLineIndex}))");
})
.then(function () {
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-js-built-ins-check-this-expected.txt b/LayoutTests/fast/mediastream/RTCPeerConnection-js-built-ins-check-this-expected.txt
deleted file mode 100644
index 589fefd..0000000
--- a/LayoutTests/fast/mediastream/RTCPeerConnection-js-built-ins-check-this-expected.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-Verify that the RTCPeerConnection JS built-in methods check calling 'this'
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS promise RTCPeerConnection.prototype.createOffer.call({}) rejected with TypeError: Function should be called on an RTCPeerConnection
-PASS promise RTCPeerConnection.prototype.createAnswer.call({}) rejected with TypeError: Function should be called on an RTCPeerConnection
-PASS promise RTCPeerConnection.prototype.setLocalDescription.call({}) rejected with TypeError: Function should be called on an RTCPeerConnection
-PASS promise RTCPeerConnection.prototype.setRemoteDescription.call({}) rejected with TypeError: Function should be called on an RTCPeerConnection
-PASS promise RTCPeerConnection.prototype.addIceCandidate.call({}) rejected with TypeError: Function should be called on an RTCPeerConnection
-FAIL promise RTCPeerConnection.prototype.getStats.call({}, null) rejected with TypeError: Can only call RTCPeerConnection.getStats on instances of RTCPeerConnection; expected reason TypeError: Function should be called on an RTCPeerConnection
-PASS promise objectWithPcPrototype.createOffer() rejected with TypeError: Function should be called on an RTCPeerConnection
-PASS promise objectWithPcPrototype.createAnswer() rejected with TypeError: Function should be called on an RTCPeerConnection
-PASS promise objectWithPcPrototype.setLocalDescription() rejected with TypeError: Function should be called on an RTCPeerConnection
-PASS promise objectWithPcPrototype.setRemoteDescription() rejected with TypeError: Function should be called on an RTCPeerConnection
-PASS promise objectWithPcPrototype.addIceCandidate() rejected with TypeError: Function should be called on an RTCPeerConnection
-FAIL promise objectWithPcPrototype.getStats() rejected with TypeError: Can only call RTCPeerConnection.getStats on instances of RTCPeerConnection; expected reason TypeError: Function should be called on an RTCPeerConnection
-PASS End of test promise chain
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-js-built-ins-check-this.html b/LayoutTests/fast/mediastream/RTCPeerConnection-js-built-ins-check-this.html
deleted file mode 100644
index 0def683..0000000
--- a/LayoutTests/fast/mediastream/RTCPeerConnection-js-built-ins-check-this.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <script src="../../resources/js-test-pre.js"></script>
- <script src="resources/promise-utils.js"></script>
- </head>
- <body>
- <script>
- description("Verify that the RTCPeerConnection JS built-in methods check calling 'this'");
-
- const reason = "TypeError: Function should be called on an RTCPeerConnection";
-
- function Foo() {}
- Foo.prototype = RTCPeerConnection.prototype;
- let objectWithPcPrototype = new Foo();
-
- promiseShouldReject("RTCPeerConnection.prototype.createOffer.call({})", "reason")
- .then(() => promiseShouldReject("RTCPeerConnection.prototype.createAnswer.call({})", "reason"))
- .then(() => promiseShouldReject("RTCPeerConnection.prototype.setLocalDescription.call({})", "reason"))
- .then(() => promiseShouldReject("RTCPeerConnection.prototype.setRemoteDescription.call({})", "reason"))
- .then(() => promiseShouldReject("RTCPeerConnection.prototype.addIceCandidate.call({})", "reason"))
- .then(() => promiseShouldReject("RTCPeerConnection.prototype.getStats.call({}, null)", "reason"))
-
- .then(() => promiseShouldReject("objectWithPcPrototype.createOffer()", "reason"))
- .then(() => promiseShouldReject("objectWithPcPrototype.createAnswer()", "reason"))
- .then(() => promiseShouldReject("objectWithPcPrototype.setLocalDescription()", "reason"))
- .then(() => promiseShouldReject("objectWithPcPrototype.setRemoteDescription()", "reason"))
- .then(() => promiseShouldReject("objectWithPcPrototype.addIceCandidate()", "reason"))
- .then(() => promiseShouldReject("objectWithPcPrototype.getStats()", "reason"))
-
- .then(() => {
- testPassed("End of test promise chain");
- finishJSTest();
- })
- .catch(error => {
- testFailed("Error in promise chain: " + error);
- finishJSTest();
- });
-
- window.jsTestIsAsync = true;
- window.successfullyParsed = true;
-
- </script>
- <script src="../../resources/js-test-post.js"></script>
- </body>
-</html>
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer-expected.txt b/LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer-expected.txt
index e09011f..c479b2d 100644
--- a/LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer-expected.txt
+++ b/LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer-expected.txt
@@ -31,8 +31,8 @@
PASS pc.signalingState is 'have-local-offer'
*** Try setting local descriptions with bad types for the current state
-PASS promise pc.setLocalDescription(new RTCSessionDescription({type:'answer', sdp:firstOffer.sdp})); rejected with InvalidStateError (DOM Exception 11): Description type incompatible with current signaling state
-PASS promise pc.setLocalDescription(new RTCSessionDescription({type:'pranswer', sdp:firstOffer.sdp})); rejected with InvalidStateError (DOM Exception 11): Description type incompatible with current signaling state
+PASS promise pc.setLocalDescription({type:'answer', sdp:firstOffer.sdp}); rejected with InvalidStateError (DOM Exception 11): Description type incompatible with current signaling state
+PASS promise pc.setLocalDescription({type:'pranswer', sdp:firstOffer.sdp}); rejected with InvalidStateError (DOM Exception 11): Description type incompatible with current signaling state
*** Add videoTrack
PASS pc.getTransceivers().length is 2
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer.html b/LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer.html
index 1274d8f..001a56d 100644
--- a/LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer.html
+++ b/LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer.html
@@ -84,10 +84,10 @@
debug("");
debug("*** Try setting local descriptions with bad types for the current state");
- return promiseShouldReject("pc.setLocalDescription(new RTCSessionDescription({type:'answer', sdp:firstOffer.sdp}));");
+ return promiseShouldReject("pc.setLocalDescription({type:'answer', sdp:firstOffer.sdp});");
})
.then(function () {
- return promiseShouldReject("pc.setLocalDescription(new RTCSessionDescription({type:'pranswer', sdp:firstOffer.sdp}));");
+ return promiseShouldReject("pc.setLocalDescription({type:'pranswer', sdp:firstOffer.sdp});");
})
.then(function () {
debug("");
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer-expected.txt b/LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer-expected.txt
index 40a7688..1b75679 100644
--- a/LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer-expected.txt
+++ b/LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer-expected.txt
@@ -33,8 +33,8 @@
PASS pc.signalingState is 'have-remote-offer'
*** Try setting local descriptions with bad types for the current state
-PASS promise pc.setRemoteDescription(new RTCSessionDescription({type:'answer', sdp:remoteOffer1.sdp})); rejected with InvalidStateError (DOM Exception 11): Description type incompatible with current signaling state
-PASS promise pc.setRemoteDescription(new RTCSessionDescription({type:'pranswer', sdp:remoteOffer1.sdp})); rejected with InvalidStateError (DOM Exception 11): Description type incompatible with current signaling state
+PASS promise pc.setRemoteDescription({type:'answer', sdp:remoteOffer1.sdp}); rejected with InvalidStateError (DOM Exception 11): Description type incompatible with current signaling state
+PASS promise pc.setRemoteDescription({type:'pranswer', sdp:remoteOffer1.sdp}); rejected with InvalidStateError (DOM Exception 11): Description type incompatible with current signaling state
*** Create (remote) offer with video (remoteOffer2)
*** Done, start testing with remoteOffer2
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html b/LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html
index df91a62..17549a5 100644
--- a/LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html
+++ b/LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer.html
@@ -106,10 +106,10 @@
debug("");
debug("*** Try setting local descriptions with bad types for the current state");
- return promiseShouldReject("pc.setRemoteDescription(new RTCSessionDescription({type:'answer', sdp:remoteOffer1.sdp}));");
+ return promiseShouldReject("pc.setRemoteDescription({type:'answer', sdp:remoteOffer1.sdp});");
})
.then(function () {
- return promiseShouldReject("pc.setRemoteDescription(new RTCSessionDescription({type:'pranswer', sdp:remoteOffer1.sdp}));");
+ return promiseShouldReject("pc.setRemoteDescription({type:'pranswer', sdp:remoteOffer1.sdp});");
})
.then(function () {
debug("");