Bug 1219711 - Remove fakeness from webrtc tests. r=jib
authorAndreas Pehrson <pehrsons@gmail.com>
Mon, 09 Nov 2015 23:17:42 +0800
changeset 308041 9267c84ef58c101ab41c3d662249043e8af707f8
parent 308040 7b8755f0ccf56966d17e47bbabd6d35deea41cbc
child 308042 4c0e38d45f7b73e920fba13374af40bb10133c13
push id7422
push userpehrsons@gmail.com
push dateWed, 11 Nov 2015 04:19:53 +0000
reviewersjib
bugs1219711
milestone45.0a1
Bug 1219711 - Remove fakeness from webrtc tests. r=jib
dom/media/tests/mochitest/identity/identityPcTest.js
dom/media/tests/mochitest/identity/test_peerConnection_asymmetricIsolation.html
dom/media/tests/mochitest/test_enumerateDevices.html
dom/media/tests/mochitest/test_getUserMedia_basicTabshare.html
dom/media/tests/mochitest/test_getUserMedia_constraints.html
dom/media/tests/mochitest/test_getUserMedia_peerIdentity.html
dom/media/tests/mochitest/test_peerConnection_callbacks.html
dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
dom/media/tests/mochitest/test_peerConnection_replaceTrack.html
dom/media/tests/mochitest/test_peerConnection_replaceVideoThenRenegotiate.html
dom/media/tests/mochitest/test_peerConnection_throwInCallbacks.html
--- a/dom/media/tests/mochitest/identity/identityPcTest.js
+++ b/dom/media/tests/mochitest/identity/identityPcTest.js
@@ -15,17 +15,16 @@ function identityPcTest(remoteOptions) {
   });
   test.setMediaConstraints([{
     audio: true,
     video: true,
     peerIdentity: id2
   }], [remoteOptions || {
     audio: true,
     video: true,
-    fake: true,
     peerIdentity: id1
   }]);
   test.pcLocal.setIdentityProvider('test1.example.com', 'idp.js');
   test.pcRemote.setIdentityProvider('test2.example.com', 'idp.js');
   test.chain.append([
     function PEER_IDENTITY_IS_SET_CORRECTLY(test) {
       // no need to wait to check identity in this case,
       // setRemoteDescription should wait for the IdP to complete
--- a/dom/media/tests/mochitest/identity/test_peerConnection_asymmetricIsolation.html
+++ b/dom/media/tests/mochitest/identity/test_peerConnection_asymmetricIsolation.html
@@ -15,18 +15,17 @@ createHTML({
 });
 
 function theTest() {
   // Override the remote media capture options to remove isolation for the
   // remote party; the test verifies that the media it receives on the local
   // side is isolated anyway.
   identityPcTest({
     audio: true,
-    video: true,
-    fake: true
+    video: true
   });
 }
 runNetworkTest(theTest);
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_enumerateDevices.html
+++ b/dom/media/tests/mochitest/test_enumerateDevices.html
@@ -41,37 +41,34 @@ runTest(() =>
     var jsoned = JSON.parse(JSON.stringify(devices));
     is(jsoned[0].kind, devices[0].kind, "kind survived serializer");
     is(jsoned[0].deviceId, devices[0].deviceId, "deviceId survived serializer");
   })
   // Check deviceId failure paths for video.
   .then(() => mustSucceed("unknown plain deviceId on video",
                           () => navigator.mediaDevices.getUserMedia({
     video: { deviceId: "unknown9qHr8B0JIbcHlbl9xR+jMbZZ8WyoPfpCXPfc=" },
-    fake: true,
   })))
   .then(() => mustSucceed("unknown plain deviceId on audio",
                           () => navigator.mediaDevices.getUserMedia({
     audio: { deviceId: "unknown9qHr8B0JIbcHlbl9xR+jMbZZ8WyoPfpCXPfc=" },
-    fake: true,
   })))
   .then(() => mustFailWith("unknown exact deviceId on video",
                            "OverconstrainedError", "deviceId",
                            () => navigator.mediaDevices.getUserMedia({
     video: { deviceId: { exact: "unknown9qHr8B0JIbcHlbl9xR+jMbZZ8WyoPfpCXPfc=" } },
-    fake: true,
   })))
   .then(() => mustFailWith("unknown exact deviceId on audio",
                            "OverconstrainedError", "deviceId",
                            () => navigator.mediaDevices.getUserMedia({
     audio: { deviceId: { exact: "unknown9qHr8B0JIbcHlbl9xR+jMbZZ8WyoPfpCXPfc=" } },
-    fake: true,
   })))
-  // Check the special case of no devices found (these prefs override fake).
-  .then(() => pushPrefs(["media.audio_loopback_dev", "none"],
+  // Check the special case of no devices found.
+  .then(() => pushPrefs(["media.navigator.streams.fake", false],
+                        ["media.audio_loopback_dev", "none"],
                         ["media.video_loopback_dev", "none"]))
   .then(() => navigator.mediaDevices.enumerateDevices())
   .then(devices => ok(devices.length === 0, "No devices found")));
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_basicTabshare.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicTabshare.html
@@ -20,30 +20,34 @@
     const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
     if (IsMacOSX10_6orOlder() || isWinXP) {
         ok(true, "Screensharing disabled for OSX10.6 and WinXP");
         return;
     }
     var testVideo = createMediaElement('video', 'testVideo');
 
     return Promise.resolve()
-      .then(() => getUserMedia({ video: { mediaSource: "browser",
-                                          scrollWithPage: true } }))
+      .then(() => getUserMedia({
+        video: { mediaSource: "browser",
+                 scrollWithPage: true },
+        fake: false
+      }))
       .then(stream => {
         var playback = new LocalMediaStreamPlayback(testVideo, stream);
         return playback.playMediaWithDeprecatedStreamStop(false);
       })
       .then(() => getUserMedia({
         video: {
           mediaSource: "browser",
           viewportOffsetX: 0,
           viewportOffsetY: 0,
           viewportWidth: 100,
           viewportHeight: 100
-        }
+        },
+        fake: false
       }))
       .then(stream => {
         var playback = new LocalMediaStreamPlayback(testVideo, stream);
         playback.startMedia(false);
         return playback.verifyPlaying()
           .then(() => Promise.all([
             () => testVideo.srcObject.getVideoTracks()[0].applyConstraints({
               mediaSource: "browser",
--- a/dom/media/tests/mochitest/test_getUserMedia_constraints.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_constraints.html
@@ -11,26 +11,23 @@ createHTML({ title: "Test getUserMedia c
 /**
   Tests covering gUM constraints API for audio, video and fake video. Exercise
   successful parsing code and ensure that unknown required constraints and
   overconstraining cases produce appropriate errors.
 */
 var tests = [
   // Each test here tests a different constraint or codepath.
   { message: "unknown required constraint on video ignored",
-    constraints: { video: { somethingUnknown: { exact: 0 } },
-                   fake: true },
+    constraints: { video: { somethingUnknown: { exact: 0 } } },
     error: null },
   { message: "unknown required constraint on audio ignored",
-    constraints: { audio: { somethingUnknown: { exact: 0 } },
-                   fake: true },
+    constraints: { audio: { somethingUnknown: { exact: 0 } } },
     error: null },
   { message: "audio overconstrained by facingMode ignored",
-    constraints: { audio: { facingMode: { exact: 'left' } },
-                   fake: true },
+    constraints: { audio: { facingMode: { exact: 'left' } } },
     error: null },
   { message: "full screensharing requires permission",
     constraints: { video: { mediaSource: 'screen' } },
     error: "SecurityError" },
   { message: "application screensharing requires permission",
     constraints: { video: { mediaSource: 'application' } },
     error: "SecurityError" },
   { message: "window screensharing requires permission",
@@ -46,32 +43,31 @@ var tests = [
   { message: "unknown mediaSource in audio fails",
     constraints: { audio: { mediaSource: 'uncle' } },
     error: "OverconstrainedError",
     constraint: "mediaSource" },
   { message: "emtpy constraint fails",
     constraints: { },
     error: "NotSupportedError" },
   { message: "Success-path: optional video facingMode + audio ignoring facingMode",
-    constraints: { fake: true,
-                   audio: { mediaSource: 'microphone',
+    constraints: { audio: { mediaSource: 'microphone',
                             facingMode: 'left',
                             foo: 0,
                             advanced: [{ facingMode: 'environment' },
                                        { facingMode: 'user' },
                                        { bar: 0 }] },
                    video: { mediaSource: 'camera',
                             foo: 0,
                             advanced: [{ facingMode: 'environment' },
                                        { facingMode: ['user'] },
                                        { facingMode: ['left', 'right', 'user'] },
                                        { bar: 0 }] } },
     error: null },
   { message: "legacy facingMode ignored",
-    constraints: { video: { mandatory: { facingMode: 'left' } }, fake: true },
+    constraints: { video: { mandatory: { facingMode: 'left' } } },
     error: null },
 ];
 
 var mustSupport = [
   'width', 'height', 'frameRate', 'facingMode', 'deviceId',
   // Yet to add:
   //  'aspectRatio', 'frameRate', 'volume', 'sampleRate', 'sampleSize',
   //  'echoCancellation', 'latency', 'groupId'
--- a/dom/media/tests/mochitest/test_getUserMedia_peerIdentity.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_peerIdentity.html
@@ -8,17 +8,17 @@
 <pre id="test">
 <script type="application/javascript">
 createHTML({
   title: "Test getUserMedia peerIdentity Constraint",
   bug: "942367"
 });
 function theTest() {
   function testPeerIdentityConstraint(withConstraint) {
-    var config = { audio: true, video: true, fake: true };
+    var config = { audio: true, video: true };
     if (withConstraint) {
       config.peerIdentity = 'user@example.com';
     }
     info('getting media with constraints: ' + JSON.stringify(config));
     return getUserMedia(config)
       .then(stream => Promise.all([
         audioIsSilence(withConstraint, stream),
         videoIsBlack(withConstraint, stream)
--- a/dom/media/tests/mochitest/test_peerConnection_callbacks.html
+++ b/dom/media/tests/mochitest/test_peerConnection_callbacks.html
@@ -60,17 +60,17 @@ var delivered = new Promise(resolve => {
 
 runNetworkTest(function() {
   v1 = createMediaElement('video', 'v1');
   v2 = createMediaElement('video', 'v2');
   var canPlayThrough = new Promise(resolve => v2.canplaythrough = resolve);
   is(v2.currentTime, 0, "v2.currentTime is zero at outset");
 
   // not testing legacy gUM here
-  navigator.mediaDevices.getUserMedia({ fake: true, video: true, audio: true })
+  navigator.mediaDevices.getUserMedia({ video: true, audio: true })
     .then(stream => pc1.addStream(v1.mozSrcObject = stream))
     .then(() => pcall(pc1, pc1.createOffer))
     .then(offer => pcall(pc1, pc1.setLocalDescription, offer))
     .then(() => pcall(pc2, pc2.setRemoteDescription, pc1.localDescription))
     .then(() => pcall(pc2, pc2.createAnswer))
     .then(answer => pcall(pc2, pc2.setLocalDescription, answer))
     .then(() => pcall(pc1, pc1.setRemoteDescription, pc2.localDescription))
     .then(() => delivered)
--- a/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
+++ b/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
@@ -31,17 +31,17 @@
 
   runNetworkTest(function() {
     v1 = createMediaElement('video', 'v1');
     v2 = createMediaElement('video', 'v2');
     var canPlayThrough = new Promise(resolve => v2.canplaythrough = e => resolve());
 
     is(v2.currentTime, 0, "v2.currentTime is zero at outset");
 
-    navigator.mediaDevices.getUserMedia({ fake: true, video: true, audio: true })
+    navigator.mediaDevices.getUserMedia({ video: true, audio: true })
     .then(stream => pc1.addStream(v1.srcObject = stream))
     .then(() => pc1.createOffer({})) // check that createOffer accepts arg.
     .then(offer => pc1.setLocalDescription(offer))
     .then(() => pc2.setRemoteDescription(pc1.localDescription))
     .then(() => pc2.createAnswer({}))  // check that createAnswer accepts arg.
     .then(answer => pc2.setLocalDescription(answer))
     .then(() => pc1.setRemoteDescription(pc2.localDescription))
     .then(() => delivered)
--- a/dom/media/tests/mochitest/test_peerConnection_replaceTrack.html
+++ b/dom/media/tests/mochitest/test_peerConnection_replaceTrack.html
@@ -25,17 +25,17 @@
     var sender = pc.getSenders().find(sn => sn.track.kind == "video");
     var oldTrack = sender.track;
     ok(sender, "We have a sender for video");
     ok(allLocalStreamsHaveSender(pc),
        "Shouldn't have any streams without a corresponding sender");
 
     var newTrack;
     var audiotrack;
-    return navigator.mediaDevices.getUserMedia({video:true, audio:true, fake:true})
+    return navigator.mediaDevices.getUserMedia({video:true, audio:true})
       .then(newStream => {
         window.grip = newStream;
         newTrack = newStream.getVideoTracks()[0];
         audiotrack = newStream.getAudioTracks()[0];
         isnot(newTrack, sender.track, "replacing with a different track");
         ok(!pc.getLocalStreams().some(s => s == newStream),
            "from a different stream");
         return sender.replaceTrack(newTrack);
@@ -107,17 +107,18 @@
         var pc = test.pcLocal._pc;
         var sender = pc.getSenders().find(sn => sn.track.kind == "audio");
         ok(sender, "track has a sender");
         var oldSenderCount = pc.getSenders().length;
         var oldTrack = sender.track;
 
         var sourceNode = test.audioCtx.createOscillator();
         sourceNode.type = 'sine';
-        // We need a frequency not too close to the fake audio track (1kHz).
+        // We need a frequency not too close to the fake audio track
+        // (440Hz for loopback devices, 1kHz for fake tracks).
         sourceNode.frequency.value = 2000;
         sourceNode.start();
 
         var destNode = test.audioCtx.createMediaStreamDestination();
         sourceNode.connect(destNode);
         var newTrack = destNode.stream.getAudioTracks()[0];
 
         return sender.replaceTrack(newTrack)
@@ -152,17 +153,17 @@
         }
         try {
           test.pcLocal._pc.addTrack(track, stream);
           ok(false, "addTrack existing track should fail");
         } catch (e) {
           is(e.name, "InvalidParameterError",
              "addTrack existing track should fail");
         }
-        return navigator.mediaDevices.getUserMedia({video:true, fake: true})
+        return navigator.mediaDevices.getUserMedia({video:true})
           .then(differentStream => {
             var track = differentStream.getVideoTracks()[0];
             try {
               test.pcLocal._pc.addTrack(track, stream);
               ok(false, "addTrack w/wrong stream should fail");
             } catch (e) {
               is(e.name, "InvalidParameterError",
                  "addTrack w/wrong stream should fail");
--- a/dom/media/tests/mochitest/test_peerConnection_replaceVideoThenRenegotiate.html
+++ b/dom/media/tests/mochitest/test_peerConnection_replaceVideoThenRenegotiate.html
@@ -16,17 +16,17 @@
     test = new PeerConnectionTest(options);
     test.setMediaConstraints([{video:true}], [{video:true}]);
     addRenegotiation(test.chain,
       [
         function PC_LOCAL_REPLACE_VIDEO_TRACK_THEN_ADD_SECOND_STREAM(test) {
           var oldstream = test.pcLocal._pc.getLocalStreams()[0];
           var oldtrack = oldstream.getVideoTracks()[0];
           var sender = test.pcLocal._pc.getSenders()[0];
-          return navigator.mediaDevices.getUserMedia({video:true, fake:true})
+          return navigator.mediaDevices.getUserMedia({video:true})
             .then(newstream => {
               var newtrack = newstream.getVideoTracks()[0];
               return test.pcLocal.senderReplaceTrack(0, newtrack, newstream.id);
             })
             .then(() => {
               test.setMediaConstraints([{video: true}, {video: true}],
                                        [{video: true}]);
               return test.pcLocal.getAllUserMedia([{video: true}]);
--- a/dom/media/tests/mochitest/test_peerConnection_throwInCallbacks.html
+++ b/dom/media/tests/mochitest/test_peerConnection_throwInCallbacks.html
@@ -43,17 +43,17 @@ runNetworkTest(function () {
   let pc0, pc1, pc2;
   // Test failure callbacks (limited to 1 for now)
   pc0 = new RTCPeerConnection();
   pc0.createOffer(getFail(), function(err) {
     pc1 = new RTCPeerConnection();
     pc2 = new RTCPeerConnection();
 
     // Test success callbacks (happy path)
-    navigator.mozGetUserMedia({video:true, fake: true}, function(video1) {
+    navigator.mozGetUserMedia({video:true}, function(video1) {
       pc1.addStream(video1);
       pc1.createOffer(function(offer) {
         pc1.setLocalDescription(offer, function() {
           pc2.setRemoteDescription(offer, function() {
             pc2.createAnswer(function(answer) {
               pc2.setLocalDescription(answer, function() {
                 pc1.setRemoteDescription(answer, function() {
                   throw new Error("Expected");