Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/webrtc/rtcpeerconnection/rtcpeerconnection-constructor.html

Issue 2448433002: Import wpt@bd99724e428dae78082983eab4675480c43f6234 (Closed)
Patch Set: more Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset=utf-8>
3 <title>RTCPeerConnection constructor</title>
4 <script src=/resources/testharness.js></script>
5 <script src=/resources/testharnessreport.js></script>
6 <script>
7 test(function() {
8 assert_equals(RTCPeerConnection.length, 0);
9 }, 'RTCPeerConnection.length');
10
11 // These are used for string and number dictionary members to see if they are
12 // being accessed at all.
13 const toStringThrows = { toString: function() { throw new Error; } };
14 const toNumberThrows = Symbol();
15
16 // Test the first argument of the constructor. The key is the argument itself,
17 // and the value is the first argument for assert_throws, or false if no
18 // exception should be thrown.
19 const testArgs = {
20 // No argument or equivalent.
21 '': false,
22 'null': false,
23 'undefined': false,
24 '{}': false,
25
26 // iceServers
27 '{ iceServers: null }': new TypeError,
28 '{ iceServers: undefined }': false,
29 '{ iceServers: [] }': false,
30 '{ iceServers: [{}] }': new TypeError,
31 '{ iceServers: [null] }': new TypeError,
32 '{ iceServers: [undefined] }': new TypeError,
33 '{ iceServers: [{ urls: "stun:stun1.example.net" }] }': false,
34 '{ iceServers: [{ urls: [] }] }': false,
35 '{ iceServers: [{ urls: ["stun:stun1.example.net"] }] }': false,
36 '{ iceServers: [{ urls: ["stun:stun1.example.net", "stun:stun2.example.net"] } ] }': false,
37 // username and password required for turn: and turns:
38 '{ iceServers: [{ urls: "turns:turn.example.org", username: "user", credential : "cred" }] }': false,
39 '{ iceServers: [{ urls: "turn:turn.example.net", username: "user", credential: "cred" }] }': false,
40 '{ iceServers: [{ urls: ["turns:turn.example.org", "turn:turn.example.net"], u sername: "user", credential: "cred" }] }': false,
41 '{ iceServers: [{ urls: "stun:stun1.example.net", credentialType: "password" } ] }': false,
42 '{ iceServers: [{ urls: "stun:stun1.example.net", credentialType: "token" }] } ': false,
43 '{ iceServers: [{ urls: "turn:turn.example.net" }] }': 'InvalidAccessError',
44 '{ iceServers: [{ urls: "turn:turn.example.net", username: "user" }] }': 'Inva lidAccessError',
45 '{ iceServers: [{ urls: "turn:turn.example.net", credential: "cred" }] }': 'In validAccessError',
46 '{ iceServers: [{ urls: "turns:turn.example.org" }] }': 'InvalidAccessError',
47 '{ iceServers: [{ urls: "turns:turn.example.org", username: "user" }] }': 'Inv alidAccessError',
48 '{ iceServers: [{ urls: "turns:turn.example.org", credential: "cred" }] }': 'I nvalidAccessError',
49 '{ iceServers: [{ urls: "relative-url" }] }': 'SyntaxError',
50 '{ iceServers: [{ urls: "http://example.com" }] }': 'SyntaxError',
51 // credentialType
52 '{ iceServers: [{ urls: [] }] }': false,
53 '{ iceServers: [{ urls: [], credentialType: "password" }] }': false,
54 '{ iceServers: [{ urls: [], credentialType: "token" }] }': false,
55 '{ iceServers: [{ urls: [], credentialType: "invalid" }] }': new TypeError,
56 // Blink and Gecko fall back to url, but it's not in the spec.
57 '{ iceServers: [{ url: "stun:stun1.example.net" }] }': new TypeError,
58
59 // iceTransportPolicy
60 '{ iceTransportPolicy: null }': new TypeError,
61 '{ iceTransportPolicy: undefined }': false,
62 '{ iceTransportPolicy: "relay" }': false,
63 '{ iceTransportPolicy: "all" }': false,
64 '{ iceTransportPolicy: "invalid" }': new TypeError,
65 // "none" is in Blink and Gecko's IDL, but not in the spec.
66 '{ iceTransportPolicy: "none" }': new TypeError,
67 // iceTransportPolicy is called iceTransports in Blink.
68 '{ iceTransports: "invalid" }': false,
69 '{ iceTransports: "none" }': false,
70
71 // bundlePolicy
72 '{ bundlePolicy: null }': new TypeError,
73 '{ bundlePolicy: undefined }': false,
74 '{ bundlePolicy: "balanced" }': false,
75 '{ bundlePolicy: "max-compat" }': false,
76 '{ bundlePolicy: "max-bundle" }': false,
77 '{ bundlePolicy: "invalid" }': new TypeError,
78
79 // rtcpMuxPolicy
80 '{ rtcpMuxPolicy: null }': new TypeError,
81 '{ rtcpMuxPolicy: undefined }': false,
82 '{ rtcpMuxPolicy: "negotiate" }': false,
83 '{ rtcpMuxPolicy: "require" }': false,
84 '{ rtcpMuxPolicy: "invalid" }': new TypeError,
85
86 // peerIdentity
87 '{ peerIdentity: toStringThrows }': new Error,
88
89 // certificates
90 '{ certificates: null }': new TypeError,
91 '{ certificates: undefined }': false,
92 '{ certificates: [] }': false,
93 '{ certificates: [null] }': new TypeError,
94 '{ certificates: [undefined] }': new TypeError,
95
96 // iceCandidatePoolSize
97 '{ iceCandidatePoolSize: toNumberThrows }': new TypeError,
98 }
99
100 for (const arg in testArgs) {
101 const expr = 'new RTCPeerConnection(' + arg + ')';
102 test(function() {
103 const throws = testArgs[arg];
104 if (throws) {
105 assert_throws(throws, function() {
106 eval(expr);
107 });
108 } else {
109 eval(expr);
110 }
111 }, expr);
112 }
113
114 promise_test(function() {
115 return RTCPeerConnection.generateCertificate({ name: "ECDSA", namedCurve: "P-2 56" })
116 .then(certificate => new RTCPeerConnection({ certificates: [certificate] } ));
117 }, 'new RTCPeerConnection({ certificates: [certificate] })');
118
119 promise_test(function() {
120 return RTCPeerConnection.generateCertificate({ name: "ECDSA", namedCurve: "P-2 56", expires: 0 })
121 .then(certificate => {
122 assert_less_than_equal(certificate.expires, Date.now());
123 assert_throws('InvalidAccessError', function() {
124 new RTCPeerConnection({ certificates: [certificate] });
125 });
126 });
127 }, 'new RTCPeerConnection({ certificates: [expiredCertificate] })');
128
129 // The initial values of attributes of RTCPeerConnection.
130 const initialState = {
131 'localDescription': null,
132 'currentLocalDescription': null,
133 'pendingLocalDescription': null,
134 'remoteDescription': null,
135 'currentRemoteDescription': null,
136 'pendingRemoteDescription': null,
137 'signalingState': 'stable',
138 'iceGatheringState': 'new',
139 'iceConnectionState': 'new',
140 'connectionState': 'new',
141 'canTrickleIceCandidates': null,
142 // TODO: defaultIceServers
143 };
144
145 for (const attr in initialState) {
146 test(function() {
147 // Use one RTCPeerConnection instance for all initial value tests.
148 if (!window.pc) {
149 window.pc = new RTCPeerConnection;
150 }
151 assert_equals(pc[attr], initialState[attr]);
152 }, attr + ' initial value');
153 }
154 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698