Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /** |
michael@0 | 2 | * Default list of commands to execute for a PeerConnection test. |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | var STABLE = "stable"; |
michael@0 | 6 | var HAVE_LOCAL_OFFER = "have-local-offer"; |
michael@0 | 7 | var HAVE_REMOTE_OFFER = "have-remote-offer"; |
michael@0 | 8 | var CLOSED = "closed"; |
michael@0 | 9 | |
michael@0 | 10 | var commandsPeerConnection = [ |
michael@0 | 11 | [ |
michael@0 | 12 | 'PC_LOCAL_GUM', |
michael@0 | 13 | function (test) { |
michael@0 | 14 | test.pcLocal.getAllUserMedia(function () { |
michael@0 | 15 | test.next(); |
michael@0 | 16 | }); |
michael@0 | 17 | } |
michael@0 | 18 | ], |
michael@0 | 19 | [ |
michael@0 | 20 | 'PC_REMOTE_GUM', |
michael@0 | 21 | function (test) { |
michael@0 | 22 | test.pcRemote.getAllUserMedia(function () { |
michael@0 | 23 | test.next(); |
michael@0 | 24 | }); |
michael@0 | 25 | } |
michael@0 | 26 | ], |
michael@0 | 27 | [ |
michael@0 | 28 | 'PC_LOCAL_CHECK_INITIAL_SIGNALINGSTATE', |
michael@0 | 29 | function (test) { |
michael@0 | 30 | is(test.pcLocal.signalingState, STABLE, |
michael@0 | 31 | "Initial local signalingState is 'stable'"); |
michael@0 | 32 | test.next(); |
michael@0 | 33 | } |
michael@0 | 34 | ], |
michael@0 | 35 | [ |
michael@0 | 36 | 'PC_REMOTE_CHECK_INITIAL_SIGNALINGSTATE', |
michael@0 | 37 | function (test) { |
michael@0 | 38 | is(test.pcRemote.signalingState, STABLE, |
michael@0 | 39 | "Initial remote signalingState is 'stable'"); |
michael@0 | 40 | test.next(); |
michael@0 | 41 | } |
michael@0 | 42 | ], |
michael@0 | 43 | [ |
michael@0 | 44 | 'PC_LOCAL_CREATE_OFFER', |
michael@0 | 45 | function (test) { |
michael@0 | 46 | test.createOffer(test.pcLocal, function () { |
michael@0 | 47 | is(test.pcLocal.signalingState, STABLE, |
michael@0 | 48 | "Local create offer does not change signaling state"); |
michael@0 | 49 | if (!test.pcRemote) { |
michael@0 | 50 | send_message({"offer": test.pcLocal._last_offer, |
michael@0 | 51 | "media_constraints": test.pcLocal.constraints}); |
michael@0 | 52 | } |
michael@0 | 53 | test.next(); |
michael@0 | 54 | }); |
michael@0 | 55 | } |
michael@0 | 56 | ], |
michael@0 | 57 | [ |
michael@0 | 58 | 'PC_LOCAL_SET_LOCAL_DESCRIPTION', |
michael@0 | 59 | function (test) { |
michael@0 | 60 | test.setLocalDescription(test.pcLocal, test.pcLocal._last_offer, HAVE_LOCAL_OFFER, function () { |
michael@0 | 61 | is(test.pcLocal.signalingState, HAVE_LOCAL_OFFER, |
michael@0 | 62 | "signalingState after local setLocalDescription is 'have-local-offer'"); |
michael@0 | 63 | test.next(); |
michael@0 | 64 | }); |
michael@0 | 65 | } |
michael@0 | 66 | ], |
michael@0 | 67 | [ |
michael@0 | 68 | 'PC_REMOTE_GET_OFFER', |
michael@0 | 69 | function (test) { |
michael@0 | 70 | if (test.pcLocal) { |
michael@0 | 71 | test._local_offer = test.pcLocal._last_offer; |
michael@0 | 72 | test._local_constraints = test.pcLocal.constraints; |
michael@0 | 73 | test.next(); |
michael@0 | 74 | } else { |
michael@0 | 75 | wait_for_message().then(function(message) { |
michael@0 | 76 | ok("offer" in message, "Got an offer message"); |
michael@0 | 77 | test._local_offer = new mozRTCSessionDescription(message.offer); |
michael@0 | 78 | test._local_constraints = message.media_constraints; |
michael@0 | 79 | test.next(); |
michael@0 | 80 | }); |
michael@0 | 81 | } |
michael@0 | 82 | } |
michael@0 | 83 | ], |
michael@0 | 84 | [ |
michael@0 | 85 | 'PC_REMOTE_SET_REMOTE_DESCRIPTION', |
michael@0 | 86 | function (test) { |
michael@0 | 87 | test.setRemoteDescription(test.pcRemote, test._local_offer, HAVE_REMOTE_OFFER, function () { |
michael@0 | 88 | is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER, |
michael@0 | 89 | "signalingState after remote setRemoteDescription is 'have-remote-offer'"); |
michael@0 | 90 | test.next(); |
michael@0 | 91 | }); |
michael@0 | 92 | } |
michael@0 | 93 | ], |
michael@0 | 94 | [ |
michael@0 | 95 | 'PC_REMOTE_CREATE_ANSWER', |
michael@0 | 96 | function (test) { |
michael@0 | 97 | test.createAnswer(test.pcRemote, function () { |
michael@0 | 98 | is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER, |
michael@0 | 99 | "Remote createAnswer does not change signaling state"); |
michael@0 | 100 | if (!test.pcLocal) { |
michael@0 | 101 | send_message({"answer": test.pcRemote._last_answer, |
michael@0 | 102 | "media_constraints": test.pcRemote.constraints}); |
michael@0 | 103 | } |
michael@0 | 104 | test.next(); |
michael@0 | 105 | }); |
michael@0 | 106 | } |
michael@0 | 107 | ], |
michael@0 | 108 | [ |
michael@0 | 109 | 'PC_LOCAL_GET_ANSWER', |
michael@0 | 110 | function (test) { |
michael@0 | 111 | if (test.pcRemote) { |
michael@0 | 112 | test._remote_answer = test.pcRemote._last_answer; |
michael@0 | 113 | test._remote_constraints = test.pcRemote.constraints; |
michael@0 | 114 | test.next(); |
michael@0 | 115 | } else { |
michael@0 | 116 | wait_for_message().then(function(message) { |
michael@0 | 117 | ok("answer" in message, "Got an answer message"); |
michael@0 | 118 | test._remote_answer = new mozRTCSessionDescription(message.answer); |
michael@0 | 119 | test._remote_constraints = message.media_constraints; |
michael@0 | 120 | test.next(); |
michael@0 | 121 | }); |
michael@0 | 122 | } |
michael@0 | 123 | } |
michael@0 | 124 | ], |
michael@0 | 125 | [ |
michael@0 | 126 | 'PC_LOCAL_SET_REMOTE_DESCRIPTION', |
michael@0 | 127 | function (test) { |
michael@0 | 128 | test.setRemoteDescription(test.pcLocal, test._remote_answer, STABLE, function () { |
michael@0 | 129 | is(test.pcLocal.signalingState, STABLE, |
michael@0 | 130 | "signalingState after local setRemoteDescription is 'stable'"); |
michael@0 | 131 | test.next(); |
michael@0 | 132 | }); |
michael@0 | 133 | } |
michael@0 | 134 | ], |
michael@0 | 135 | [ |
michael@0 | 136 | 'PC_REMOTE_SET_LOCAL_DESCRIPTION', |
michael@0 | 137 | function (test) { |
michael@0 | 138 | test.setLocalDescription(test.pcRemote, test.pcRemote._last_answer, STABLE, function () { |
michael@0 | 139 | is(test.pcRemote.signalingState, STABLE, |
michael@0 | 140 | "signalingState after remote setLocalDescription is 'stable'"); |
michael@0 | 141 | test.next(); |
michael@0 | 142 | }); |
michael@0 | 143 | } |
michael@0 | 144 | ], |
michael@0 | 145 | [ |
michael@0 | 146 | 'PC_LOCAL_WAIT_FOR_ICE_CONNECTED', |
michael@0 | 147 | function (test) { |
michael@0 | 148 | var myTest = test; |
michael@0 | 149 | var myPc = myTest.pcLocal; |
michael@0 | 150 | |
michael@0 | 151 | function onIceConnectedSuccess () { |
michael@0 | 152 | ok(true, "pc_local: ICE switched to 'connected' state"); |
michael@0 | 153 | myTest.next(); |
michael@0 | 154 | }; |
michael@0 | 155 | function onIceConnectedFailed () { |
michael@0 | 156 | dump("ERROR: pc_local: SDP offer: " + myTest._local_offer.sdp.replace(/[\r]/g, '')); |
michael@0 | 157 | dump("ERROR: pc_local: SDP answer: " + myTest._remote_answer.sdp.replace(/[\r]/g, '')); |
michael@0 | 158 | ok(false, "pc_local: ICE failed to switch to 'connected' state: " + myPc.iceConnectionState); |
michael@0 | 159 | myTest.next(); |
michael@0 | 160 | }; |
michael@0 | 161 | |
michael@0 | 162 | if (myPc.isIceConnected()) { |
michael@0 | 163 | ok(true, "pc_local: ICE is in connected state"); |
michael@0 | 164 | myTest.next(); |
michael@0 | 165 | } else if (myPc.isIceConnectionPending()) { |
michael@0 | 166 | myPc.waitForIceConnected(onIceConnectedSuccess, onIceConnectedFailed); |
michael@0 | 167 | } else { |
michael@0 | 168 | dump("ERROR: pc_local: SDP offer: " + myTest._local_offer.sdp.replace(/[\r]/g, '')); |
michael@0 | 169 | dump("ERROR: pc_local: SDP answer: " + myTest._remote_answer.sdp.replace(/[\r]/g, '')); |
michael@0 | 170 | ok(false, "pc_local: ICE is already in bad state: " + myPc.iceConnectionState); |
michael@0 | 171 | myTest.next(); |
michael@0 | 172 | } |
michael@0 | 173 | } |
michael@0 | 174 | ], |
michael@0 | 175 | [ |
michael@0 | 176 | 'PC_REMOTE_WAIT_FOR_ICE_CONNECTED', |
michael@0 | 177 | function (test) { |
michael@0 | 178 | var myTest = test; |
michael@0 | 179 | var myPc = myTest.pcRemote; |
michael@0 | 180 | |
michael@0 | 181 | function onIceConnectedSuccess () { |
michael@0 | 182 | ok(true, "pc_remote: ICE switched to 'connected' state"); |
michael@0 | 183 | myTest.next(); |
michael@0 | 184 | }; |
michael@0 | 185 | function onIceConnectedFailed () { |
michael@0 | 186 | dump("ERROR: pc_remote: SDP offer: " + myTest._local_offer.sdp.replace(/[\r]/g, '')); |
michael@0 | 187 | dump("ERROR: pc_remote: SDP answer: " + myTest._remote_answer.sdp.replace(/[\r]/g, '')); |
michael@0 | 188 | ok(false, "pc_remote: ICE failed to switch to 'connected' state: " + myPc.iceConnectionState); |
michael@0 | 189 | myTest.next(); |
michael@0 | 190 | }; |
michael@0 | 191 | |
michael@0 | 192 | if (myPc.isIceConnected()) { |
michael@0 | 193 | ok(true, "pc_remote: ICE is in connected state"); |
michael@0 | 194 | myTest.next(); |
michael@0 | 195 | } else if (myPc.isIceConnectionPending()) { |
michael@0 | 196 | myPc.waitForIceConnected(onIceConnectedSuccess, onIceConnectedFailed); |
michael@0 | 197 | } else { |
michael@0 | 198 | dump("ERROR: pc_remote: SDP offer: " + myTest._local_offer.sdp.replace(/[\r]/g, '')); |
michael@0 | 199 | dump("ERROR: pc_remote: SDP answer: " + myTest._remote_answer.sdp.replace(/[\r]/g, '')); |
michael@0 | 200 | ok(false, "pc_remote: ICE is already in bad state: " + myPc.iceConnectionState); |
michael@0 | 201 | myTest.next(); |
michael@0 | 202 | } |
michael@0 | 203 | } |
michael@0 | 204 | ], |
michael@0 | 205 | [ |
michael@0 | 206 | 'PC_LOCAL_CHECK_MEDIA_STREAMS', |
michael@0 | 207 | function (test) { |
michael@0 | 208 | test.pcLocal.checkMediaStreams(test._remote_constraints); |
michael@0 | 209 | test.next(); |
michael@0 | 210 | } |
michael@0 | 211 | ], |
michael@0 | 212 | [ |
michael@0 | 213 | 'PC_REMOTE_CHECK_MEDIA_STREAMS', |
michael@0 | 214 | function (test) { |
michael@0 | 215 | test.pcRemote.checkMediaStreams(test._local_constraints); |
michael@0 | 216 | test.next(); |
michael@0 | 217 | } |
michael@0 | 218 | ], |
michael@0 | 219 | [ |
michael@0 | 220 | 'PC_LOCAL_CHECK_MEDIA_FLOW_PRESENT', |
michael@0 | 221 | function (test) { |
michael@0 | 222 | test.pcLocal.checkMediaFlowPresent(function () { |
michael@0 | 223 | test.next(); |
michael@0 | 224 | }); |
michael@0 | 225 | } |
michael@0 | 226 | ], |
michael@0 | 227 | [ |
michael@0 | 228 | 'PC_REMOTE_CHECK_MEDIA_FLOW_PRESENT', |
michael@0 | 229 | function (test) { |
michael@0 | 230 | test.pcRemote.checkMediaFlowPresent(function () { |
michael@0 | 231 | test.next(); |
michael@0 | 232 | }); |
michael@0 | 233 | } |
michael@0 | 234 | ], |
michael@0 | 235 | [ |
michael@0 | 236 | 'PC_LOCAL_CHECK_STATS', |
michael@0 | 237 | function (test) { |
michael@0 | 238 | test.pcLocal.getStats(null, function(stats) { |
michael@0 | 239 | test.pcLocal.checkStats(stats); |
michael@0 | 240 | test.next(); |
michael@0 | 241 | }); |
michael@0 | 242 | } |
michael@0 | 243 | ], |
michael@0 | 244 | [ |
michael@0 | 245 | 'PC_REMOTE_CHECK_STATS', |
michael@0 | 246 | function (test) { |
michael@0 | 247 | test.pcRemote.getStats(null, function(stats) { |
michael@0 | 248 | test.pcRemote.checkStats(stats); |
michael@0 | 249 | test.next(); |
michael@0 | 250 | }); |
michael@0 | 251 | } |
michael@0 | 252 | ] |
michael@0 | 253 | ]; |
michael@0 | 254 | |
michael@0 | 255 | |
michael@0 | 256 | /** |
michael@0 | 257 | * Default list of commands to execute for a Datachannel test. |
michael@0 | 258 | */ |
michael@0 | 259 | var commandsDataChannel = [ |
michael@0 | 260 | [ |
michael@0 | 261 | 'PC_LOCAL_GUM', |
michael@0 | 262 | function (test) { |
michael@0 | 263 | test.pcLocal.getAllUserMedia(function () { |
michael@0 | 264 | test.next(); |
michael@0 | 265 | }); |
michael@0 | 266 | } |
michael@0 | 267 | ], |
michael@0 | 268 | [ |
michael@0 | 269 | 'PC_LOCAL_INITIAL_SIGNALINGSTATE', |
michael@0 | 270 | function (test) { |
michael@0 | 271 | is(test.pcLocal.signalingState, STABLE, |
michael@0 | 272 | "Initial local signalingState is stable"); |
michael@0 | 273 | test.next(); |
michael@0 | 274 | } |
michael@0 | 275 | ], |
michael@0 | 276 | [ |
michael@0 | 277 | 'PC_REMOTE_GUM', |
michael@0 | 278 | function (test) { |
michael@0 | 279 | test.pcRemote.getAllUserMedia(function () { |
michael@0 | 280 | test.next(); |
michael@0 | 281 | }); |
michael@0 | 282 | } |
michael@0 | 283 | ], |
michael@0 | 284 | [ |
michael@0 | 285 | 'PC_REMOTE_INITIAL_SIGNALINGSTATE', |
michael@0 | 286 | function (test) { |
michael@0 | 287 | is(test.pcRemote.signalingState, STABLE, |
michael@0 | 288 | "Initial remote signalingState is stable"); |
michael@0 | 289 | test.next(); |
michael@0 | 290 | } |
michael@0 | 291 | ], |
michael@0 | 292 | [ |
michael@0 | 293 | 'PC_LOCAL_CREATE_DATA_CHANNEL', |
michael@0 | 294 | function (test) { |
michael@0 | 295 | var channel = test.pcLocal.createDataChannel({}); |
michael@0 | 296 | |
michael@0 | 297 | is(channel.binaryType, "blob", channel + " is of binary type 'blob'"); |
michael@0 | 298 | is(channel.readyState, "connecting", channel + " is in state: 'connecting'"); |
michael@0 | 299 | |
michael@0 | 300 | is(test.pcLocal.signalingState, STABLE, |
michael@0 | 301 | "Create datachannel does not change signaling state"); |
michael@0 | 302 | |
michael@0 | 303 | test.next(); |
michael@0 | 304 | } |
michael@0 | 305 | ], |
michael@0 | 306 | [ |
michael@0 | 307 | 'PC_LOCAL_CREATE_OFFER', |
michael@0 | 308 | function (test) { |
michael@0 | 309 | test.pcLocal.createOffer(function (offer) { |
michael@0 | 310 | is(test.pcLocal.signalingState, STABLE, |
michael@0 | 311 | "Local create offer does not change signaling state"); |
michael@0 | 312 | ok(offer.sdp.contains("m=application"), |
michael@0 | 313 | "m=application is contained in the SDP"); |
michael@0 | 314 | test.next(); |
michael@0 | 315 | }); |
michael@0 | 316 | } |
michael@0 | 317 | ], |
michael@0 | 318 | [ |
michael@0 | 319 | 'PC_LOCAL_SET_LOCAL_DESCRIPTION', |
michael@0 | 320 | function (test) { |
michael@0 | 321 | test.setLocalDescription(test.pcLocal, test.pcLocal._last_offer, HAVE_LOCAL_OFFER, |
michael@0 | 322 | function () { |
michael@0 | 323 | is(test.pcLocal.signalingState, HAVE_LOCAL_OFFER, |
michael@0 | 324 | "signalingState after local setLocalDescription is 'have-local-offer'"); |
michael@0 | 325 | test.next(); |
michael@0 | 326 | }); |
michael@0 | 327 | } |
michael@0 | 328 | ], |
michael@0 | 329 | [ |
michael@0 | 330 | 'PC_REMOTE_SET_REMOTE_DESCRIPTION', |
michael@0 | 331 | function (test) { |
michael@0 | 332 | test.setRemoteDescription(test.pcRemote, test.pcLocal._last_offer, HAVE_REMOTE_OFFER, |
michael@0 | 333 | function () { |
michael@0 | 334 | is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER, |
michael@0 | 335 | "signalingState after remote setRemoteDescription is 'have-remote-offer'"); |
michael@0 | 336 | test.next(); |
michael@0 | 337 | }); |
michael@0 | 338 | } |
michael@0 | 339 | ], |
michael@0 | 340 | [ |
michael@0 | 341 | 'PC_REMOTE_CREATE_ANSWER', |
michael@0 | 342 | function (test) { |
michael@0 | 343 | test.createAnswer(test.pcRemote, function () { |
michael@0 | 344 | is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER, |
michael@0 | 345 | "Remote create offer does not change signaling state"); |
michael@0 | 346 | test.next(); |
michael@0 | 347 | }); |
michael@0 | 348 | } |
michael@0 | 349 | ], |
michael@0 | 350 | [ |
michael@0 | 351 | 'PC_LOCAL_SET_REMOTE_DESCRIPTION', |
michael@0 | 352 | function (test) { |
michael@0 | 353 | test.setRemoteDescription(test.pcLocal, test.pcRemote._last_answer, STABLE, |
michael@0 | 354 | function () { |
michael@0 | 355 | is(test.pcLocal.signalingState, STABLE, |
michael@0 | 356 | "signalingState after local setRemoteDescription is 'stable'"); |
michael@0 | 357 | test.next(); |
michael@0 | 358 | }); |
michael@0 | 359 | } |
michael@0 | 360 | ], |
michael@0 | 361 | [ |
michael@0 | 362 | 'PC_REMOTE_SET_LOCAL_DESCRIPTION', |
michael@0 | 363 | function (test) { |
michael@0 | 364 | test.setLocalDescription(test.pcRemote, test.pcRemote._last_answer, STABLE, |
michael@0 | 365 | function (sourceChannel, targetChannel) { |
michael@0 | 366 | is(sourceChannel.readyState, "open", test.pcLocal + " is in state: 'open'"); |
michael@0 | 367 | is(targetChannel.readyState, "open", test.pcRemote + " is in state: 'open'"); |
michael@0 | 368 | |
michael@0 | 369 | is(test.pcRemote.signalingState, STABLE, |
michael@0 | 370 | "signalingState after remote setLocalDescription is 'stable'"); |
michael@0 | 371 | test.next(); |
michael@0 | 372 | } |
michael@0 | 373 | ); |
michael@0 | 374 | } |
michael@0 | 375 | ], |
michael@0 | 376 | [ |
michael@0 | 377 | 'PC_LOCAL_CHECK_MEDIA_STREAMS', |
michael@0 | 378 | function (test) { |
michael@0 | 379 | test.pcLocal.checkMediaStreams(test.pcRemote.constraints); |
michael@0 | 380 | test.next(); |
michael@0 | 381 | } |
michael@0 | 382 | ], |
michael@0 | 383 | [ |
michael@0 | 384 | 'PC_REMOTE_CHECK_MEDIA_STREAMS', |
michael@0 | 385 | function (test) { |
michael@0 | 386 | test.pcRemote.checkMediaStreams(test.pcLocal.constraints); |
michael@0 | 387 | test.next(); |
michael@0 | 388 | } |
michael@0 | 389 | ], |
michael@0 | 390 | [ |
michael@0 | 391 | 'PC_LOCAL_CHECK_MEDIA_FLOW_PRESENT', |
michael@0 | 392 | function (test) { |
michael@0 | 393 | test.pcLocal.checkMediaFlowPresent(function () { |
michael@0 | 394 | test.next(); |
michael@0 | 395 | }); |
michael@0 | 396 | } |
michael@0 | 397 | ], |
michael@0 | 398 | [ |
michael@0 | 399 | 'PC_REMOTE_CHECK_MEDIA_FLOW_PRESENT', |
michael@0 | 400 | function (test) { |
michael@0 | 401 | test.pcRemote.checkMediaFlowPresent(function () { |
michael@0 | 402 | test.next(); |
michael@0 | 403 | }); |
michael@0 | 404 | } |
michael@0 | 405 | ], |
michael@0 | 406 | [ |
michael@0 | 407 | 'SEND_MESSAGE', |
michael@0 | 408 | function (test) { |
michael@0 | 409 | var message = "Lorem ipsum dolor sit amet"; |
michael@0 | 410 | |
michael@0 | 411 | test.send(message, function (channel, data) { |
michael@0 | 412 | is(data, message, "Message correctly transmitted from pcLocal to pcRemote."); |
michael@0 | 413 | |
michael@0 | 414 | test.next(); |
michael@0 | 415 | }); |
michael@0 | 416 | } |
michael@0 | 417 | ], |
michael@0 | 418 | [ |
michael@0 | 419 | 'SEND_BLOB', |
michael@0 | 420 | function (test) { |
michael@0 | 421 | var contents = ["At vero eos et accusam et justo duo dolores et ea rebum."]; |
michael@0 | 422 | var blob = new Blob(contents, { "type" : "text/plain" }); |
michael@0 | 423 | |
michael@0 | 424 | test.send(blob, function (channel, data) { |
michael@0 | 425 | ok(data instanceof Blob, "Received data is of instance Blob"); |
michael@0 | 426 | is(data.size, blob.size, "Received data has the correct size."); |
michael@0 | 427 | |
michael@0 | 428 | getBlobContent(data, function (recv_contents) { |
michael@0 | 429 | is(recv_contents, contents, "Received data has the correct content."); |
michael@0 | 430 | |
michael@0 | 431 | test.next(); |
michael@0 | 432 | }); |
michael@0 | 433 | }); |
michael@0 | 434 | } |
michael@0 | 435 | ], |
michael@0 | 436 | [ |
michael@0 | 437 | 'CREATE_SECOND_DATA_CHANNEL', |
michael@0 | 438 | function (test) { |
michael@0 | 439 | test.createDataChannel({ }, function (sourceChannel, targetChannel) { |
michael@0 | 440 | is(sourceChannel.readyState, "open", sourceChannel + " is in state: 'open'"); |
michael@0 | 441 | is(targetChannel.readyState, "open", targetChannel + " is in state: 'open'"); |
michael@0 | 442 | |
michael@0 | 443 | is(targetChannel.binaryType, "blob", targetChannel + " is of binary type 'blob'"); |
michael@0 | 444 | is(targetChannel.readyState, "open", targetChannel + " is in state: 'open'"); |
michael@0 | 445 | |
michael@0 | 446 | test.next(); |
michael@0 | 447 | }); |
michael@0 | 448 | } |
michael@0 | 449 | ], |
michael@0 | 450 | [ |
michael@0 | 451 | 'SEND_MESSAGE_THROUGH_LAST_OPENED_CHANNEL', |
michael@0 | 452 | function (test) { |
michael@0 | 453 | var channels = test.pcRemote.dataChannels; |
michael@0 | 454 | var message = "Lorem ipsum dolor sit amet"; |
michael@0 | 455 | |
michael@0 | 456 | test.send(message, function (channel, data) { |
michael@0 | 457 | is(channels.indexOf(channel), channels.length - 1, "Last channel used"); |
michael@0 | 458 | is(data, message, "Received message has the correct content."); |
michael@0 | 459 | |
michael@0 | 460 | test.next(); |
michael@0 | 461 | }); |
michael@0 | 462 | } |
michael@0 | 463 | ], |
michael@0 | 464 | [ |
michael@0 | 465 | 'SEND_MESSAGE_THROUGH_FIRST_CHANNEL', |
michael@0 | 466 | function (test) { |
michael@0 | 467 | var message = "Message through 1st channel"; |
michael@0 | 468 | var options = { |
michael@0 | 469 | sourceChannel: test.pcLocal.dataChannels[0], |
michael@0 | 470 | targetChannel: test.pcRemote.dataChannels[0] |
michael@0 | 471 | }; |
michael@0 | 472 | |
michael@0 | 473 | test.send(message, function (channel, data) { |
michael@0 | 474 | is(test.pcRemote.dataChannels.indexOf(channel), 0, "1st channel used"); |
michael@0 | 475 | is(data, message, "Received message has the correct content."); |
michael@0 | 476 | |
michael@0 | 477 | test.next(); |
michael@0 | 478 | }, options); |
michael@0 | 479 | } |
michael@0 | 480 | ], |
michael@0 | 481 | [ |
michael@0 | 482 | 'CREATE_NEGOTIATED_DATA_CHANNEL', |
michael@0 | 483 | function (test) { |
michael@0 | 484 | var options = {negotiated:true, id: 5, protocol:"foo/bar", ordered:false, |
michael@0 | 485 | maxRetransmits:500}; |
michael@0 | 486 | test.createDataChannel(options, function (sourceChannel2, targetChannel2) { |
michael@0 | 487 | is(sourceChannel2.readyState, "open", sourceChannel2 + " is in state: 'open'"); |
michael@0 | 488 | is(targetChannel2.readyState, "open", targetChannel2 + " is in state: 'open'"); |
michael@0 | 489 | |
michael@0 | 490 | is(targetChannel2.binaryType, "blob", targetChannel2 + " is of binary type 'blob'"); |
michael@0 | 491 | is(targetChannel2.readyState, "open", targetChannel2 + " is in state: 'open'"); |
michael@0 | 492 | |
michael@0 | 493 | if (options.id != undefined) { |
michael@0 | 494 | is(sourceChannel2.id, options.id, sourceChannel2 + " id is:" + sourceChannel2.id); |
michael@0 | 495 | } else { |
michael@0 | 496 | options.id = sourceChannel2.id; |
michael@0 | 497 | } |
michael@0 | 498 | var reliable = !options.ordered ? false : (options.maxRetransmits || options.maxRetransmitTime); |
michael@0 | 499 | is(sourceChannel2.protocol, options.protocol, sourceChannel2 + " protocol is:" + sourceChannel2.protocol); |
michael@0 | 500 | is(sourceChannel2.reliable, reliable, sourceChannel2 + " reliable is:" + sourceChannel2.reliable); |
michael@0 | 501 | /* |
michael@0 | 502 | These aren't exposed by IDL yet |
michael@0 | 503 | is(sourceChannel2.ordered, options.ordered, sourceChannel2 + " ordered is:" + sourceChannel2.ordered); |
michael@0 | 504 | is(sourceChannel2.maxRetransmits, options.maxRetransmits, sourceChannel2 + " maxRetransmits is:" + |
michael@0 | 505 | sourceChannel2.maxRetransmits); |
michael@0 | 506 | is(sourceChannel2.maxRetransmitTime, options.maxRetransmitTime, sourceChannel2 + " maxRetransmitTime is:" + |
michael@0 | 507 | sourceChannel2.maxRetransmitTime); |
michael@0 | 508 | */ |
michael@0 | 509 | |
michael@0 | 510 | is(targetChannel2.id, options.id, targetChannel2 + " id is:" + targetChannel2.id); |
michael@0 | 511 | is(targetChannel2.protocol, options.protocol, targetChannel2 + " protocol is:" + targetChannel2.protocol); |
michael@0 | 512 | is(targetChannel2.reliable, reliable, targetChannel2 + " reliable is:" + targetChannel2.reliable); |
michael@0 | 513 | /* |
michael@0 | 514 | These aren't exposed by IDL yet |
michael@0 | 515 | is(targetChannel2.ordered, options.ordered, targetChannel2 + " ordered is:" + targetChannel2.ordered); |
michael@0 | 516 | is(targetChannel2.maxRetransmits, options.maxRetransmits, targetChannel2 + " maxRetransmits is:" + |
michael@0 | 517 | targetChannel2.maxRetransmits); |
michael@0 | 518 | is(targetChannel2.maxRetransmitTime, options.maxRetransmitTime, targetChannel2 + " maxRetransmitTime is:" + |
michael@0 | 519 | targetChannel2.maxRetransmitTime); |
michael@0 | 520 | */ |
michael@0 | 521 | |
michael@0 | 522 | test.next(); |
michael@0 | 523 | }); |
michael@0 | 524 | } |
michael@0 | 525 | ], |
michael@0 | 526 | [ |
michael@0 | 527 | 'SEND_MESSAGE_THROUGH_LAST_OPENED_CHANNEL2', |
michael@0 | 528 | function (test) { |
michael@0 | 529 | var channels = test.pcRemote.dataChannels; |
michael@0 | 530 | var message = "Lorem ipsum dolor sit amet"; |
michael@0 | 531 | |
michael@0 | 532 | test.send(message, function (channel, data) { |
michael@0 | 533 | is(channels.indexOf(channel), channels.length - 1, "Last channel used"); |
michael@0 | 534 | is(data, message, "Received message has the correct content."); |
michael@0 | 535 | |
michael@0 | 536 | test.next(); |
michael@0 | 537 | }); |
michael@0 | 538 | } |
michael@0 | 539 | ], |
michael@0 | 540 | [ |
michael@0 | 541 | 'CLOSE_LAST_OPENED_DATA_CHANNEL2', |
michael@0 | 542 | function (test) { |
michael@0 | 543 | var channels = test.pcRemote.dataChannels; |
michael@0 | 544 | |
michael@0 | 545 | test.closeDataChannel(channels.length - 1, function (channel) { |
michael@0 | 546 | is(channel.readyState, "closed", "Channel is in state: 'closed'"); |
michael@0 | 547 | |
michael@0 | 548 | test.next(); |
michael@0 | 549 | }); |
michael@0 | 550 | } |
michael@0 | 551 | ], |
michael@0 | 552 | [ |
michael@0 | 553 | 'CLOSE_LAST_OPENED_DATA_CHANNEL', |
michael@0 | 554 | function (test) { |
michael@0 | 555 | var channels = test.pcRemote.dataChannels; |
michael@0 | 556 | |
michael@0 | 557 | test.closeDataChannel(channels.length - 1, function (channel) { |
michael@0 | 558 | is(channel.readyState, "closed", "Channel is in state: 'closed'"); |
michael@0 | 559 | |
michael@0 | 560 | test.next(); |
michael@0 | 561 | }); |
michael@0 | 562 | } |
michael@0 | 563 | ] |
michael@0 | 564 | ]; |