Bug 1531472 - Part 1: Use the faster getNoiseStream instead of getUserMedia to prevent timeouts. r=jib
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 05 Mar 2019 21:58:39 +0000
changeset 462907 2509291a92682b47f2564aa0b58dbeda4a565fb5
parent 462906 ef6b5013eceeeb98ac47892cbbd8d4521c5869ef
child 462908 ca64604d4b781aa8191144e97b660ae3b09fae6e
push id79909
push userbcampen@mozilla.com
push dateThu, 07 Mar 2019 15:24:32 +0000
treeherderautoland@2509291a9268 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1531472
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531472 - Part 1: Use the faster getNoiseStream instead of getUserMedia to prevent timeouts. r=jib Depends on D21939 Differential Revision: https://phabricator.services.mozilla.com/D21940
testing/web-platform/tests/webrtc/RTCRtpSender-replaceTrack.https.html
--- a/testing/web-platform/tests/webrtc/RTCRtpSender-replaceTrack.https.html
+++ b/testing/web-platform/tests/webrtc/RTCRtpSender-replaceTrack.https.html
@@ -1,13 +1,14 @@
 <!doctype html>
 <meta charset=utf-8>
 <title>RTCRtpSender.prototype.replaceTrack</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
+<script src="RTCPeerConnection-helper.js"></script>
 <script>
   'use strict';
 
   // Test is based on the following editor draft:
   // https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
 
   /*
     5.2.  RTCRtpSender Interface
@@ -25,17 +26,17 @@
   /*
     5.2.  replaceTrack
       4.  If connection's [[isClosed]] slot is true, return a promise rejected
           with a newly created InvalidStateError and abort these steps.
    */
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
     const [track] = stream.getTracks();
 
     const transceiver = pc.addTransceiver('audio');
     const { sender } = transceiver;
     pc.close();
 
     return promise_rejects(t, 'InvalidStateError',
@@ -46,17 +47,17 @@
     5.2.  replaceTrack
       7.  If withTrack is non-null and withTrack.kind differs from the
           transceiver kind of transceiver, return a promise rejected with a
           newly created TypeError.
    */
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream = await navigator.mediaDevices.getUserMedia({video: true});
+    const stream = await getNoiseStream({video: true});
     t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
     const [track] = stream.getTracks();
 
     const transceiver = pc.addTransceiver('audio');
     const { sender } = transceiver;
 
     return promise_rejects(t, new TypeError(),
       sender.replaceTrack(track));
@@ -65,17 +66,17 @@
   /*
     5.2.  replaceTrack
       5.  If transceiver.stopped is true, return a promise rejected with a newly
           created InvalidStateError.
    */
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
     const [track] = stream.getTracks();
 
     const transceiver = pc.addTransceiver('audio');
     const { sender } = transceiver;
     transceiver.stop();
 
     return promise_rejects(t, 'InvalidStateError',
@@ -86,37 +87,37 @@
     5.2.  replaceTrack
       8.  If transceiver is not yet associated with a media description [JSEP]
           (section 3.4.1.), then set sender's track attribute to withTrack, and
           return a promise resolved with undefined.
    */
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
     const [track] = stream.getTracks();
 
     const transceiver = pc.addTransceiver('audio');
     const { sender } = transceiver;
     assert_equals(sender.track, null);
 
     return sender.replaceTrack(track)
     .then(() => {
       assert_equals(sender.track, track);
     });
   }, 'Calling replaceTrack on sender with null track and not set to session description should resolve with sender.track set to given track');
 
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream1 = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream1 = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream1.getTracks().forEach(track => track.stop()));
     const [track1] = stream1.getTracks();
-    const stream2 = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream2 = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream2.getTracks().forEach(track => track.stop()));
     const [track2] = stream2.getTracks();
 
     const transceiver = pc.addTransceiver(track1);
     const { sender } = transceiver;
 
     assert_equals(sender.track, track1);
 
@@ -124,17 +125,17 @@
     .then(() => {
       assert_equals(sender.track, track2);
     });
   }, 'Calling replaceTrack on sender not set to session description should resolve with sender.track set to given track');
 
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
     const [track] = stream.getTracks();
 
     const transceiver = pc.addTransceiver(track);
     const { sender } = transceiver;
 
     assert_equals(sender.track, track);
 
@@ -153,17 +154,17 @@
               Negotiation is not needed if withTrack is null.
 
           3.  Queue a task that runs the following steps:
               2.  Set sender's track attribute to withTrack.
    */
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
     const [track] = stream.getTracks();
 
     const transceiver = pc.addTransceiver(track);
     const { sender } = transceiver;
 
     assert_equals(sender.track, track);
 
@@ -185,20 +186,20 @@
               ended (which appears as though the track was muted).
 
           3.  Queue a task that runs the following steps:
               2.  Set sender's track attribute to withTrack.
    */
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream1 = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream1 = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream1.getTracks().forEach(track => track.stop()));
     const [track1] = stream1.getTracks();
-    const stream2 = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream2 = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream2.getTracks().forEach(track => track.stop()));
     const [track2] = stream1.getTracks();
 
     const transceiver = pc.addTransceiver(track1);
     const { sender } = transceiver;
     assert_equals(sender.track, track1);
 
     track1.stop();
@@ -221,20 +222,20 @@
               enough to not require re-negotiation)
 
           3.  Queue a task that runs the following steps:
               2.  Set sender's track attribute to withTrack.
    */
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
-    const stream1 = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream1 = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream1.getTracks().forEach(track => track.stop()));
     const [track1] = stream1.getTracks();
-    const stream2 = await navigator.mediaDevices.getUserMedia({audio: true});
+    const stream2 = await getNoiseStream({audio: true});
     t.add_cleanup(() => stream2.getTracks().forEach(track => track.stop()));
     const [track2] = stream1.getTracks();
 
     const transceiver = pc.addTransceiver(track1);
     const { sender } = transceiver;
     assert_equals(sender.track, track1);
 
     return pc.createOffer()