Make mDNS ICE Candidate an experimental flag again
[WebKit-https.git] / LayoutTests / webrtc / rtcpeerconnection-error-messages.html
1 <!DOCTYPE html>
2 <div id="log"></div>
3 <script src='../resources/testharness.js'></script>
4 <script src='../resources/testharnessreport.js'></script>
5 <script>
6 function log(msg)
7 {
8     document.getElementById("log").innerHTML += msg + "<br>";
9 }
10
11 function printMethodError(method, target)
12 {
13     try {
14         method.call(target);
15         assert_unreached();
16     } catch(e) {
17          log(e);
18     }
19 }
20
21 function printPromiseMethodError(method, target)
22 {
23     return method.call(target).then(assert_unreached, (e) => {
24          log("Promise rejected with: " + e);
25     });
26 }
27
28 function printGetterError(object, getterName, target)
29 {
30     const property = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName);
31     if (property  === undefined) {
32         log(object + " has no property named " + getterName);
33         return;
34     }
35     printMethodError(property.get, target);
36 }
37
38 promise_test(function(test) {
39     // This test prints exceptions to check the format of their messages.
40
41     var pc = new RTCPeerConnection();
42     var candidate = new RTCIceCandidate({ candidate: "foo", sdpMid: "bar" });
43
44     var results = [
45         printPromiseMethodError(pc.createOffer, candidate),
46         printPromiseMethodError(pc.createAnswer, candidate),
47         printPromiseMethodError(pc.setLocalDescription, candidate),
48         printPromiseMethodError(pc.setRemoteDescription, candidate),
49         printPromiseMethodError(pc.addIceCandidate, candidate),
50
51         printGetterError(pc, "localDescription", candidate),
52         printGetterError(pc, "currentLocalDescription", candidate),
53         printGetterError(pc, "pendingLocalDescription", candidate),
54         printGetterError(pc, "remoteDescription", candidate),
55         printGetterError(pc, "currentRemoteDescription", candidate),
56         printGetterError(pc, "pendingRemoteDescription", candidate),
57         printGetterError(pc, "signalingState", candidate),
58         printGetterError(pc, "iceGatheringState", candidate),
59         printGetterError(pc, "iceConnectionState", candidate),
60         printGetterError(pc, "connectionState", candidate),
61         printGetterError(pc, "canTrickleIceCandidates", candidate),
62         printGetterError(pc, "defaultIceServers", candidate),
63
64         printMethodError(pc.getConfiguration, candidate),
65         printMethodError(pc.setConfiguration, candidate),
66         printMethodError(pc.close, candidate),
67
68         printGetterError(pc, "onnegotiationneeded", candidate),
69         printGetterError(pc, "onicecandidate", candidate),
70         printGetterError(pc, "onicecandidateerror", candidate),
71         printGetterError(pc, "onsignalingstatechange", candidate),
72         printGetterError(pc, "oniceconnectionstatechange", candidate),
73         printGetterError(pc, "onicegatheringstatechange", candidate),
74         printGetterError(pc, "onconnectionstatechange", candidate),
75     ];
76     return Promise.all(results);
77 }, "Exercising TypeError messages in RTCPeerConnection");
78 </script>