Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / test / data / media / peerconnection-call.html
index e76ef26..511380d 100644 (file)
@@ -18,7 +18,6 @@
   // Default transform functions, overridden by some test cases.
   var transformSdp = function(sdp) { return sdp; };
   var transformRemoteSdp = function(sdp) { return sdp; };
-  var transformCandidate = function(candidate) { return candidate; };
   var onLocalDescriptionError = function(error) { failTest(error); };
   var onRemoteDescriptionError = function(error) { failTest(error); };
 
         'inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj'
   };
 
-  // When using GICE, the ICE credentials can be chosen by javascript.
-  var EXTERNAL_GICE_UFRAG = '1234567890123456';
-  var EXTERNAL_GICE_PWD = '123456789012345678901234';
-
   setAllEventsOccuredHandler(reportTestSuccess);
 
   // Test that we can setup call with an audio and video track.
     detectVideoPlaying('remote-view-2', onRemoteStream2);
   }
 
+  // First makes a call between pc1 and pc2, and then construct a new media
+  // stream using the remote audio and video tracks, connect the new media
+  // stream to a video element. These operations should not crash Chrome.
+  function ConnectChromiumSinkToRemoteAudioTrack() {
+    createConnections(null);
+    navigator.webkitGetUserMedia({audio: true, video: true},
+                                 addStreamToBothConnectionsAndNegotiate,
+                                 printGetUserMediaError);
+
+    detectVideoPlaying('remote-view-2', function() {
+      // Construct a new media stream with remote tracks.
+      var newStream = new webkitMediaStream();
+      newStream.addTrack(
+          gSecondConnection.getRemoteStreams()[0].getAudioTracks()[0]);
+      newStream.addTrack(
+          gSecondConnection.getRemoteStreams()[0].getVideoTracks()[0]);
+      var videoElement = document.createElement('video');
+
+      // No crash for this operation.
+      videoElement.src = URL.createObjectURL(newStream);
+      waitForVideo('remote-view-2');
+    });
+  }
+  
   // Test that we can setup call with an audio and video track and
   // simulate that the remote peer don't support MSID.
   function callWithoutMsidAndBundle() {
     transformSdp = function(sdp) {
       return removeBundle(useGice(useExternalSdes(sdp)));
     };
-    transformCandidate = addGiceCredsToCandidate;
     createConnections({
       'mandatory': {'RtpDataChannels': true, 'DtlsSrtpKeyAgreement': false}
     });
     detectVideoPlaying('remote-view-2', onCallEstablished);
   }
 
+  function testCreateOfferOptions() {
+    createConnections(null);
+    var offerOptions = {
+      'offerToReceiveAudio': false,
+      'offerToReceiveVideo': true
+    };
+
+    gFirstConnection.createOffer(
+        function(offer) {
+          assertEquals(-1, offer.sdp.search('m=audio'));
+          assertNotEquals(-1, offer.sdp.search('m=video'));
+
+          reportTestSuccess();
+        },
+        function(error) { failTest(error); },
+        offerOptions);
+  }
+
   function enableRemoteVideo(peerConnection, enabled) {
     remoteStream = peerConnection.getRemoteStreams()[0];
     remoteVideoTrack = remoteStream.getVideoTracks()[0];
   }
 
   function receiveOffer(offerSdp, caller, callee) {
-    console.log("Receiving offer...");
+    console.log("Receiving offer...\n" + offerSdp);
     offerSdp = transformRemoteSdp(offerSdp);
 
     var parsedOffer = new RTCSessionDescription({ type: 'offer',
     sdp = sdp.replace(/t=.*\r\n/g, function(subString) {
       return subString + 'a=ice-options:google-ice\r\n';
     });
-    sdp = sdp.replace(/a=ice-ufrag:.*\r\n/g,
-                      'a=ice-ufrag:' + EXTERNAL_GICE_UFRAG + '\r\n');
-    sdp = sdp.replace(/a=ice-pwd:.*\r\n/g,
-                      'a=ice-pwd:' + EXTERNAL_GICE_PWD + '\r\n');
     return sdp;
   }
 
     callee.onicecandidate = function(event) { onIceCandidate(event, caller); }
   }
 
-  function addGiceCredsToCandidate(candidate) {
-    return candidate.trimRight() +
-        ' username ' + EXTERNAL_GICE_UFRAG + ' password ' + EXTERNAL_GICE_PWD;
-  }
-
   function onIceCandidate(event, target) {
     if (event.candidate) {
       var candidate = new RTCIceCandidate(event.candidate);
-      candidate.candidate = transformCandidate(candidate.candidate);
       target.addIceCandidate(candidate);
     }
   }