haikuwebkit/LayoutTests/webrtc/rtcpeerconnection-error-mes...

79 lines
2.9 KiB
HTML
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/184675@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211436 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-31 17:52:33 +00:00
<!DOCTYPE html>
<div id="log"></div>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script>
function log(msg)
{
document.getElementById("log").innerHTML += msg + "<br>";
}
function printMethodError(method, target)
{
try {
method.call(target);
assert_unreached();
} catch(e) {
log(e);
}
}
function printPromiseMethodError(method, target)
{
return method.call(target).then(assert_unreached, (e) => {
log("Promise rejected with: " + e);
});
}
function printGetterError(object, getterName, target)
{
const property = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName);
if (property === undefined) {
log(object + " has no property named " + getterName);
return;
}
printMethodError(property.get, target);
}
promise_test(function(test) {
// This test prints exceptions to check the format of their messages.
var pc = new RTCPeerConnection();
var candidate = new RTCIceCandidate({ candidate: "foo", sdpMid: "bar" });
var results = [
printPromiseMethodError(pc.createOffer, candidate),
printPromiseMethodError(pc.createAnswer, candidate),
printPromiseMethodError(pc.setLocalDescription, candidate),
printPromiseMethodError(pc.setRemoteDescription, candidate),
printPromiseMethodError(pc.addIceCandidate, candidate),
printGetterError(pc, "localDescription", candidate),
printGetterError(pc, "currentLocalDescription", candidate),
printGetterError(pc, "pendingLocalDescription", candidate),
printGetterError(pc, "remoteDescription", candidate),
printGetterError(pc, "currentRemoteDescription", candidate),
printGetterError(pc, "pendingRemoteDescription", candidate),
printGetterError(pc, "signalingState", candidate),
printGetterError(pc, "iceGatheringState", candidate),
printGetterError(pc, "iceConnectionState", candidate),
printGetterError(pc, "connectionState", candidate),
printGetterError(pc, "canTrickleIceCandidates", candidate),
printGetterError(pc, "defaultIceServers", candidate),
printMethodError(pc.getConfiguration, candidate),
printMethodError(pc.setConfiguration, candidate),
printMethodError(pc.close, candidate),
printGetterError(pc, "onnegotiationneeded", candidate),
printGetterError(pc, "onicecandidate", candidate),
printGetterError(pc, "onicecandidateerror", candidate),
printGetterError(pc, "onsignalingstatechange", candidate),
printGetterError(pc, "oniceconnectionstatechange", candidate),
printGetterError(pc, "onicegatheringstatechange", candidate),
printGetterError(pc, "onconnectionstatechange", candidate),
];
return Promise.all(results);
}, "Exercising TypeError messages in RTCPeerConnection");
</script>