dom/media/tests/mochitest/templates.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/media/tests/mochitest/templates.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,564 @@
     1.4 +/**
     1.5 + * Default list of commands to execute for a PeerConnection test.
     1.6 + */
     1.7 +
     1.8 +var STABLE = "stable";
     1.9 +var HAVE_LOCAL_OFFER = "have-local-offer";
    1.10 +var HAVE_REMOTE_OFFER = "have-remote-offer";
    1.11 +var CLOSED = "closed";
    1.12 +
    1.13 +var commandsPeerConnection = [
    1.14 +  [
    1.15 +    'PC_LOCAL_GUM',
    1.16 +    function (test) {
    1.17 +      test.pcLocal.getAllUserMedia(function () {
    1.18 +        test.next();
    1.19 +      });
    1.20 +    }
    1.21 +  ],
    1.22 +  [
    1.23 +    'PC_REMOTE_GUM',
    1.24 +    function (test) {
    1.25 +      test.pcRemote.getAllUserMedia(function () {
    1.26 +        test.next();
    1.27 +      });
    1.28 +    }
    1.29 +  ],
    1.30 +  [
    1.31 +    'PC_LOCAL_CHECK_INITIAL_SIGNALINGSTATE',
    1.32 +    function (test) {
    1.33 +      is(test.pcLocal.signalingState, STABLE,
    1.34 +         "Initial local signalingState is 'stable'");
    1.35 +      test.next();
    1.36 +    }
    1.37 +  ],
    1.38 +  [
    1.39 +    'PC_REMOTE_CHECK_INITIAL_SIGNALINGSTATE',
    1.40 +    function (test) {
    1.41 +      is(test.pcRemote.signalingState, STABLE,
    1.42 +         "Initial remote signalingState is 'stable'");
    1.43 +      test.next();
    1.44 +    }
    1.45 +  ],
    1.46 +  [
    1.47 +    'PC_LOCAL_CREATE_OFFER',
    1.48 +    function (test) {
    1.49 +      test.createOffer(test.pcLocal, function () {
    1.50 +        is(test.pcLocal.signalingState, STABLE,
    1.51 +           "Local create offer does not change signaling state");
    1.52 +        if (!test.pcRemote) {
    1.53 +          send_message({"offer": test.pcLocal._last_offer,
    1.54 +                        "media_constraints": test.pcLocal.constraints});
    1.55 +        }
    1.56 +        test.next();
    1.57 +      });
    1.58 +    }
    1.59 +  ],
    1.60 +  [
    1.61 +    'PC_LOCAL_SET_LOCAL_DESCRIPTION',
    1.62 +    function (test) {
    1.63 +      test.setLocalDescription(test.pcLocal, test.pcLocal._last_offer, HAVE_LOCAL_OFFER, function () {
    1.64 +        is(test.pcLocal.signalingState, HAVE_LOCAL_OFFER,
    1.65 +           "signalingState after local setLocalDescription is 'have-local-offer'");
    1.66 +        test.next();
    1.67 +      });
    1.68 +    }
    1.69 +  ],
    1.70 +  [
    1.71 +    'PC_REMOTE_GET_OFFER',
    1.72 +    function (test) {
    1.73 +      if (test.pcLocal) {
    1.74 +        test._local_offer = test.pcLocal._last_offer;
    1.75 +        test._local_constraints = test.pcLocal.constraints;
    1.76 +        test.next();
    1.77 +      } else {
    1.78 +        wait_for_message().then(function(message) {
    1.79 +          ok("offer" in message, "Got an offer message");
    1.80 +          test._local_offer = new mozRTCSessionDescription(message.offer);
    1.81 +          test._local_constraints = message.media_constraints;
    1.82 +          test.next();
    1.83 +        });
    1.84 +      }
    1.85 +    }
    1.86 +  ],
    1.87 +  [
    1.88 +    'PC_REMOTE_SET_REMOTE_DESCRIPTION',
    1.89 +    function (test) {
    1.90 +      test.setRemoteDescription(test.pcRemote, test._local_offer, HAVE_REMOTE_OFFER, function () {
    1.91 +        is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER,
    1.92 +           "signalingState after remote setRemoteDescription is 'have-remote-offer'");
    1.93 +        test.next();
    1.94 +      });
    1.95 +    }
    1.96 +  ],
    1.97 +  [
    1.98 +    'PC_REMOTE_CREATE_ANSWER',
    1.99 +    function (test) {
   1.100 +      test.createAnswer(test.pcRemote, function () {
   1.101 +        is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER,
   1.102 +           "Remote createAnswer does not change signaling state");
   1.103 +        if (!test.pcLocal) {
   1.104 +          send_message({"answer": test.pcRemote._last_answer,
   1.105 +                        "media_constraints": test.pcRemote.constraints});
   1.106 +        }
   1.107 +        test.next();
   1.108 +      });
   1.109 +    }
   1.110 +  ],
   1.111 +  [
   1.112 +    'PC_LOCAL_GET_ANSWER',
   1.113 +    function (test) {
   1.114 +      if (test.pcRemote) {
   1.115 +        test._remote_answer = test.pcRemote._last_answer;
   1.116 +        test._remote_constraints = test.pcRemote.constraints;
   1.117 +        test.next();
   1.118 +      } else {
   1.119 +        wait_for_message().then(function(message) {
   1.120 +          ok("answer" in message, "Got an answer message");
   1.121 +          test._remote_answer = new mozRTCSessionDescription(message.answer);
   1.122 +          test._remote_constraints = message.media_constraints;
   1.123 +          test.next();
   1.124 +        });
   1.125 +      }
   1.126 +    }
   1.127 +  ],
   1.128 +  [
   1.129 +    'PC_LOCAL_SET_REMOTE_DESCRIPTION',
   1.130 +    function (test) {
   1.131 +      test.setRemoteDescription(test.pcLocal, test._remote_answer, STABLE, function () {
   1.132 +        is(test.pcLocal.signalingState, STABLE,
   1.133 +           "signalingState after local setRemoteDescription is 'stable'");
   1.134 +        test.next();
   1.135 +      });
   1.136 +    }
   1.137 +  ],
   1.138 +  [
   1.139 +    'PC_REMOTE_SET_LOCAL_DESCRIPTION',
   1.140 +    function (test) {
   1.141 +      test.setLocalDescription(test.pcRemote, test.pcRemote._last_answer, STABLE, function () {
   1.142 +        is(test.pcRemote.signalingState, STABLE,
   1.143 +           "signalingState after remote setLocalDescription is 'stable'");
   1.144 +        test.next();
   1.145 +      });
   1.146 +    }
   1.147 +  ],
   1.148 +  [
   1.149 +    'PC_LOCAL_WAIT_FOR_ICE_CONNECTED',
   1.150 +    function (test) {
   1.151 +      var myTest = test;
   1.152 +      var myPc = myTest.pcLocal;
   1.153 +
   1.154 +      function onIceConnectedSuccess () {
   1.155 +        ok(true, "pc_local: ICE switched to 'connected' state");
   1.156 +        myTest.next();
   1.157 +      };
   1.158 +      function onIceConnectedFailed () {
   1.159 +        dump("ERROR: pc_local: SDP offer: " + myTest._local_offer.sdp.replace(/[\r]/g, ''));
   1.160 +        dump("ERROR: pc_local: SDP answer: " + myTest._remote_answer.sdp.replace(/[\r]/g, ''));
   1.161 +        ok(false, "pc_local: ICE failed to switch to 'connected' state: " + myPc.iceConnectionState);
   1.162 +        myTest.next();
   1.163 +      };
   1.164 +
   1.165 +      if (myPc.isIceConnected()) {
   1.166 +        ok(true, "pc_local: ICE is in connected state");
   1.167 +        myTest.next();
   1.168 +      } else if (myPc.isIceConnectionPending()) {
   1.169 +        myPc.waitForIceConnected(onIceConnectedSuccess, onIceConnectedFailed);
   1.170 +      } else {
   1.171 +        dump("ERROR: pc_local: SDP offer: " + myTest._local_offer.sdp.replace(/[\r]/g, ''));
   1.172 +        dump("ERROR: pc_local: SDP answer: " + myTest._remote_answer.sdp.replace(/[\r]/g, ''));
   1.173 +        ok(false, "pc_local: ICE is already in bad state: " + myPc.iceConnectionState);
   1.174 +        myTest.next();
   1.175 +      }
   1.176 +    }
   1.177 +  ],
   1.178 +  [
   1.179 +    'PC_REMOTE_WAIT_FOR_ICE_CONNECTED',
   1.180 +    function (test) {
   1.181 +      var myTest = test;
   1.182 +      var myPc = myTest.pcRemote;
   1.183 +
   1.184 +      function onIceConnectedSuccess () {
   1.185 +        ok(true, "pc_remote: ICE switched to 'connected' state");
   1.186 +        myTest.next();
   1.187 +      };
   1.188 +      function onIceConnectedFailed () {
   1.189 +        dump("ERROR: pc_remote: SDP offer: " + myTest._local_offer.sdp.replace(/[\r]/g, ''));
   1.190 +        dump("ERROR: pc_remote: SDP answer: " + myTest._remote_answer.sdp.replace(/[\r]/g, ''));
   1.191 +        ok(false, "pc_remote: ICE failed to switch to 'connected' state: " + myPc.iceConnectionState);
   1.192 +        myTest.next();
   1.193 +      };
   1.194 +
   1.195 +      if (myPc.isIceConnected()) {
   1.196 +        ok(true, "pc_remote: ICE is in connected state");
   1.197 +        myTest.next();
   1.198 +      } else if (myPc.isIceConnectionPending()) {
   1.199 +        myPc.waitForIceConnected(onIceConnectedSuccess, onIceConnectedFailed);
   1.200 +      } else {
   1.201 +        dump("ERROR: pc_remote: SDP offer: " + myTest._local_offer.sdp.replace(/[\r]/g, ''));
   1.202 +        dump("ERROR: pc_remote: SDP answer: " + myTest._remote_answer.sdp.replace(/[\r]/g, ''));
   1.203 +        ok(false, "pc_remote: ICE is already in bad state: " + myPc.iceConnectionState);
   1.204 +        myTest.next();
   1.205 +      }
   1.206 +    }
   1.207 +  ],
   1.208 +  [
   1.209 +    'PC_LOCAL_CHECK_MEDIA_STREAMS',
   1.210 +    function (test) {
   1.211 +      test.pcLocal.checkMediaStreams(test._remote_constraints);
   1.212 +      test.next();
   1.213 +    }
   1.214 +  ],
   1.215 +  [
   1.216 +    'PC_REMOTE_CHECK_MEDIA_STREAMS',
   1.217 +    function (test) {
   1.218 +      test.pcRemote.checkMediaStreams(test._local_constraints);
   1.219 +      test.next();
   1.220 +    }
   1.221 +  ],
   1.222 +  [
   1.223 +    'PC_LOCAL_CHECK_MEDIA_FLOW_PRESENT',
   1.224 +    function (test) {
   1.225 +      test.pcLocal.checkMediaFlowPresent(function () {
   1.226 +        test.next();
   1.227 +      });
   1.228 +    }
   1.229 +  ],
   1.230 +  [
   1.231 +    'PC_REMOTE_CHECK_MEDIA_FLOW_PRESENT',
   1.232 +    function (test) {
   1.233 +      test.pcRemote.checkMediaFlowPresent(function () {
   1.234 +        test.next();
   1.235 +      });
   1.236 +    }
   1.237 +  ],
   1.238 +  [
   1.239 +    'PC_LOCAL_CHECK_STATS',
   1.240 +    function (test) {
   1.241 +      test.pcLocal.getStats(null, function(stats) {
   1.242 +        test.pcLocal.checkStats(stats);
   1.243 +        test.next();
   1.244 +      });
   1.245 +    }
   1.246 +  ],
   1.247 +  [
   1.248 +    'PC_REMOTE_CHECK_STATS',
   1.249 +    function (test) {
   1.250 +      test.pcRemote.getStats(null, function(stats) {
   1.251 +        test.pcRemote.checkStats(stats);
   1.252 +        test.next();
   1.253 +      });
   1.254 +    }
   1.255 +  ]
   1.256 +];
   1.257 +
   1.258 +
   1.259 +/**
   1.260 + * Default list of commands to execute for a Datachannel test.
   1.261 + */
   1.262 +var commandsDataChannel = [
   1.263 +  [
   1.264 +    'PC_LOCAL_GUM',
   1.265 +    function (test) {
   1.266 +      test.pcLocal.getAllUserMedia(function () {
   1.267 +        test.next();
   1.268 +      });
   1.269 +    }
   1.270 +  ],
   1.271 +  [
   1.272 +    'PC_LOCAL_INITIAL_SIGNALINGSTATE',
   1.273 +    function (test) {
   1.274 +      is(test.pcLocal.signalingState, STABLE,
   1.275 +         "Initial local signalingState is stable");
   1.276 +      test.next();
   1.277 +    }
   1.278 +  ],
   1.279 +  [
   1.280 +    'PC_REMOTE_GUM',
   1.281 +    function (test) {
   1.282 +      test.pcRemote.getAllUserMedia(function () {
   1.283 +      test.next();
   1.284 +      });
   1.285 +    }
   1.286 +  ],
   1.287 +  [
   1.288 +    'PC_REMOTE_INITIAL_SIGNALINGSTATE',
   1.289 +    function (test) {
   1.290 +      is(test.pcRemote.signalingState, STABLE,
   1.291 +         "Initial remote signalingState is stable");
   1.292 +      test.next();
   1.293 +    }
   1.294 +  ],
   1.295 +  [
   1.296 +    'PC_LOCAL_CREATE_DATA_CHANNEL',
   1.297 +    function (test) {
   1.298 +      var channel = test.pcLocal.createDataChannel({});
   1.299 +
   1.300 +      is(channel.binaryType, "blob", channel + " is of binary type 'blob'");
   1.301 +      is(channel.readyState, "connecting", channel + " is in state: 'connecting'");
   1.302 +
   1.303 +      is(test.pcLocal.signalingState, STABLE,
   1.304 +         "Create datachannel does not change signaling state");
   1.305 +
   1.306 +      test.next();
   1.307 +    }
   1.308 +  ],
   1.309 +  [
   1.310 +    'PC_LOCAL_CREATE_OFFER',
   1.311 +    function (test) {
   1.312 +      test.pcLocal.createOffer(function (offer) {
   1.313 +        is(test.pcLocal.signalingState, STABLE,
   1.314 +           "Local create offer does not change signaling state");
   1.315 +        ok(offer.sdp.contains("m=application"),
   1.316 +           "m=application is contained in the SDP");
   1.317 +        test.next();
   1.318 +      });
   1.319 +    }
   1.320 +  ],
   1.321 +  [
   1.322 +    'PC_LOCAL_SET_LOCAL_DESCRIPTION',
   1.323 +    function (test) {
   1.324 +      test.setLocalDescription(test.pcLocal, test.pcLocal._last_offer, HAVE_LOCAL_OFFER,
   1.325 +        function () {
   1.326 +        is(test.pcLocal.signalingState, HAVE_LOCAL_OFFER,
   1.327 +           "signalingState after local setLocalDescription is 'have-local-offer'");
   1.328 +        test.next();
   1.329 +      });
   1.330 +    }
   1.331 +  ],
   1.332 +  [
   1.333 +    'PC_REMOTE_SET_REMOTE_DESCRIPTION',
   1.334 +    function (test) {
   1.335 +      test.setRemoteDescription(test.pcRemote, test.pcLocal._last_offer, HAVE_REMOTE_OFFER,
   1.336 +        function () {
   1.337 +        is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER,
   1.338 +           "signalingState after remote setRemoteDescription is 'have-remote-offer'");
   1.339 +        test.next();
   1.340 +      });
   1.341 +    }
   1.342 +  ],
   1.343 +  [
   1.344 +    'PC_REMOTE_CREATE_ANSWER',
   1.345 +    function (test) {
   1.346 +      test.createAnswer(test.pcRemote, function () {
   1.347 +        is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER,
   1.348 +           "Remote create offer does not change signaling state");
   1.349 +        test.next();
   1.350 +      });
   1.351 +    }
   1.352 +  ],
   1.353 +  [
   1.354 +    'PC_LOCAL_SET_REMOTE_DESCRIPTION',
   1.355 +    function (test) {
   1.356 +      test.setRemoteDescription(test.pcLocal, test.pcRemote._last_answer, STABLE,
   1.357 +        function () {
   1.358 +        is(test.pcLocal.signalingState, STABLE,
   1.359 +           "signalingState after local setRemoteDescription is 'stable'");
   1.360 +        test.next();
   1.361 +      });
   1.362 +    }
   1.363 +  ],
   1.364 +  [
   1.365 +    'PC_REMOTE_SET_LOCAL_DESCRIPTION',
   1.366 +    function (test) {
   1.367 +      test.setLocalDescription(test.pcRemote, test.pcRemote._last_answer, STABLE,
   1.368 +        function (sourceChannel, targetChannel) {
   1.369 +          is(sourceChannel.readyState, "open", test.pcLocal + " is in state: 'open'");
   1.370 +          is(targetChannel.readyState, "open", test.pcRemote + " is in state: 'open'");
   1.371 +
   1.372 +          is(test.pcRemote.signalingState, STABLE,
   1.373 +             "signalingState after remote setLocalDescription is 'stable'");
   1.374 +          test.next();
   1.375 +        }
   1.376 +      );
   1.377 +    }
   1.378 +  ],
   1.379 +  [
   1.380 +    'PC_LOCAL_CHECK_MEDIA_STREAMS',
   1.381 +    function (test) {
   1.382 +      test.pcLocal.checkMediaStreams(test.pcRemote.constraints);
   1.383 +      test.next();
   1.384 +    }
   1.385 +  ],
   1.386 +  [
   1.387 +    'PC_REMOTE_CHECK_MEDIA_STREAMS',
   1.388 +    function (test) {
   1.389 +      test.pcRemote.checkMediaStreams(test.pcLocal.constraints);
   1.390 +      test.next();
   1.391 +    }
   1.392 +  ],
   1.393 +  [
   1.394 +    'PC_LOCAL_CHECK_MEDIA_FLOW_PRESENT',
   1.395 +    function (test) {
   1.396 +      test.pcLocal.checkMediaFlowPresent(function () {
   1.397 +        test.next();
   1.398 +      });
   1.399 +    }
   1.400 +  ],
   1.401 +  [
   1.402 +    'PC_REMOTE_CHECK_MEDIA_FLOW_PRESENT',
   1.403 +    function (test) {
   1.404 +      test.pcRemote.checkMediaFlowPresent(function () {
   1.405 +        test.next();
   1.406 +      });
   1.407 +    }
   1.408 +  ],
   1.409 +  [
   1.410 +    'SEND_MESSAGE',
   1.411 +    function (test) {
   1.412 +      var message = "Lorem ipsum dolor sit amet";
   1.413 +
   1.414 +      test.send(message, function (channel, data) {
   1.415 +        is(data, message, "Message correctly transmitted from pcLocal to pcRemote.");
   1.416 +
   1.417 +        test.next();
   1.418 +      });
   1.419 +    }
   1.420 +  ],
   1.421 +  [
   1.422 +    'SEND_BLOB',
   1.423 +    function (test) {
   1.424 +      var contents = ["At vero eos et accusam et justo duo dolores et ea rebum."];
   1.425 +      var blob = new Blob(contents, { "type" : "text/plain" });
   1.426 +
   1.427 +      test.send(blob, function (channel, data) {
   1.428 +        ok(data instanceof Blob, "Received data is of instance Blob");
   1.429 +        is(data.size, blob.size, "Received data has the correct size.");
   1.430 +
   1.431 +        getBlobContent(data, function (recv_contents) {
   1.432 +          is(recv_contents, contents, "Received data has the correct content.");
   1.433 +
   1.434 +          test.next();
   1.435 +        });
   1.436 +      });
   1.437 +    }
   1.438 +  ],
   1.439 +  [
   1.440 +    'CREATE_SECOND_DATA_CHANNEL',
   1.441 +    function (test) {
   1.442 +      test.createDataChannel({ }, function (sourceChannel, targetChannel) {
   1.443 +        is(sourceChannel.readyState, "open", sourceChannel + " is in state: 'open'");
   1.444 +        is(targetChannel.readyState, "open", targetChannel + " is in state: 'open'");
   1.445 +
   1.446 +        is(targetChannel.binaryType, "blob", targetChannel + " is of binary type 'blob'");
   1.447 +        is(targetChannel.readyState, "open", targetChannel + " is in state: 'open'");
   1.448 +
   1.449 +        test.next();
   1.450 +      });
   1.451 +    }
   1.452 +  ],
   1.453 +  [
   1.454 +    'SEND_MESSAGE_THROUGH_LAST_OPENED_CHANNEL',
   1.455 +    function (test) {
   1.456 +      var channels = test.pcRemote.dataChannels;
   1.457 +      var message = "Lorem ipsum dolor sit amet";
   1.458 +
   1.459 +      test.send(message, function (channel, data) {
   1.460 +        is(channels.indexOf(channel), channels.length - 1, "Last channel used");
   1.461 +        is(data, message, "Received message has the correct content.");
   1.462 +
   1.463 +        test.next();
   1.464 +      });
   1.465 +    }
   1.466 +  ],
   1.467 +  [
   1.468 +    'SEND_MESSAGE_THROUGH_FIRST_CHANNEL',
   1.469 +    function (test) {
   1.470 +      var message = "Message through 1st channel";
   1.471 +      var options = {
   1.472 +        sourceChannel: test.pcLocal.dataChannels[0],
   1.473 +        targetChannel: test.pcRemote.dataChannels[0]
   1.474 +      };
   1.475 +
   1.476 +      test.send(message, function (channel, data) {
   1.477 +        is(test.pcRemote.dataChannels.indexOf(channel), 0, "1st channel used");
   1.478 +        is(data, message, "Received message has the correct content.");
   1.479 +
   1.480 +        test.next();
   1.481 +      }, options);
   1.482 +    }
   1.483 +  ],
   1.484 +  [
   1.485 +    'CREATE_NEGOTIATED_DATA_CHANNEL',
   1.486 +    function (test) {
   1.487 +      var options = {negotiated:true, id: 5, protocol:"foo/bar", ordered:false,
   1.488 +		     maxRetransmits:500};
   1.489 +      test.createDataChannel(options, function (sourceChannel2, targetChannel2) {
   1.490 +        is(sourceChannel2.readyState, "open", sourceChannel2 + " is in state: 'open'");
   1.491 +        is(targetChannel2.readyState, "open", targetChannel2 + " is in state: 'open'");
   1.492 +
   1.493 +        is(targetChannel2.binaryType, "blob", targetChannel2 + " is of binary type 'blob'");
   1.494 +        is(targetChannel2.readyState, "open", targetChannel2 + " is in state: 'open'");
   1.495 +
   1.496 +        if (options.id != undefined) {
   1.497 +          is(sourceChannel2.id, options.id, sourceChannel2 + " id is:" + sourceChannel2.id);
   1.498 +	} else {
   1.499 +	  options.id = sourceChannel2.id;
   1.500 +	}
   1.501 +	var reliable = !options.ordered ? false : (options.maxRetransmits || options.maxRetransmitTime);
   1.502 +        is(sourceChannel2.protocol, options.protocol, sourceChannel2 + " protocol is:" + sourceChannel2.protocol);
   1.503 +        is(sourceChannel2.reliable, reliable, sourceChannel2 + " reliable is:" + sourceChannel2.reliable);
   1.504 +/*
   1.505 +  These aren't exposed by IDL yet
   1.506 +        is(sourceChannel2.ordered, options.ordered, sourceChannel2 + " ordered is:" + sourceChannel2.ordered);
   1.507 +        is(sourceChannel2.maxRetransmits, options.maxRetransmits, sourceChannel2 + " maxRetransmits is:" +
   1.508 +	   sourceChannel2.maxRetransmits);
   1.509 +        is(sourceChannel2.maxRetransmitTime, options.maxRetransmitTime, sourceChannel2 + " maxRetransmitTime is:" +
   1.510 +	   sourceChannel2.maxRetransmitTime);
   1.511 +*/
   1.512 +
   1.513 +        is(targetChannel2.id, options.id, targetChannel2 + " id is:" + targetChannel2.id);
   1.514 +        is(targetChannel2.protocol, options.protocol, targetChannel2 + " protocol is:" + targetChannel2.protocol);
   1.515 +        is(targetChannel2.reliable, reliable, targetChannel2 + " reliable is:" + targetChannel2.reliable);
   1.516 +/*
   1.517 +  These aren't exposed by IDL yet
   1.518 +       is(targetChannel2.ordered, options.ordered, targetChannel2 + " ordered is:" + targetChannel2.ordered);
   1.519 +        is(targetChannel2.maxRetransmits, options.maxRetransmits, targetChannel2 + " maxRetransmits is:" +
   1.520 +	   targetChannel2.maxRetransmits);
   1.521 +        is(targetChannel2.maxRetransmitTime, options.maxRetransmitTime, targetChannel2 + " maxRetransmitTime is:" +
   1.522 +	   targetChannel2.maxRetransmitTime);
   1.523 +*/
   1.524 +
   1.525 +        test.next();
   1.526 +      });
   1.527 +    }
   1.528 +  ],
   1.529 +  [
   1.530 +    'SEND_MESSAGE_THROUGH_LAST_OPENED_CHANNEL2',
   1.531 +    function (test) {
   1.532 +      var channels = test.pcRemote.dataChannels;
   1.533 +      var message = "Lorem ipsum dolor sit amet";
   1.534 +
   1.535 +      test.send(message, function (channel, data) {
   1.536 +        is(channels.indexOf(channel), channels.length - 1, "Last channel used");
   1.537 +        is(data, message, "Received message has the correct content.");
   1.538 +
   1.539 +        test.next();
   1.540 +      });
   1.541 +    }
   1.542 +  ],
   1.543 +  [
   1.544 +    'CLOSE_LAST_OPENED_DATA_CHANNEL2',
   1.545 +    function (test) {
   1.546 +      var channels = test.pcRemote.dataChannels;
   1.547 +
   1.548 +      test.closeDataChannel(channels.length - 1, function (channel) {
   1.549 +        is(channel.readyState, "closed", "Channel is in state: 'closed'");
   1.550 +
   1.551 +        test.next();
   1.552 +      });
   1.553 +    }
   1.554 +  ],
   1.555 +  [
   1.556 +    'CLOSE_LAST_OPENED_DATA_CHANNEL',
   1.557 +    function (test) {
   1.558 +      var channels = test.pcRemote.dataChannels;
   1.559 +
   1.560 +      test.closeDataChannel(channels.length - 1, function (channel) {
   1.561 +        is(channel.readyState, "closed", "Channel is in state: 'closed'");
   1.562 +
   1.563 +        test.next();
   1.564 +      });
   1.565 +    }
   1.566 +  ]
   1.567 +];

mercurial