Bug 1450127 [wpt PR 10247] - RTCPeerConnection.getStats(MediaStreamTrack? selector = null) added., a=testonly
authorHenrik Boström <hbos@chromium.org>
Mon, 09 Apr 2018 22:07:13 +0000
changeset 467274 3d296a3a153911082974c3cbc5319784ce162fed
parent 467273 0c8e5aa16ad7b7a4dd3b151404bb9c0b2a7acd16
child 467275 d8d73c38711f670ba1e8831044cdf1f2d0716342
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1450127, 10247, 680172, 978128, 548149
milestone61.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 1450127 [wpt PR 10247] - RTCPeerConnection.getStats(MediaStreamTrack? selector = null) added., a=testonly Automatic update from web-platform-testsRTCPeerConnection.getStats(MediaStreamTrack? selector = null) added. Implements the RTCPeerConnection.getStats(MediaStreamTrack) version[1] of the stats selection algorithm behind flag. This is the equivalent of doing RTCRtpSender.getStats() or RTCRtpReceiver.getStats() for the track's sender or receiver. This is tested in external/wpt/. Due to limitations of the generated V8 bindings it is not possible to express all versions of RTCPeerConnection.getStats() at the same time in IDL. Thus this CL introduces a version of getStats() taking "optional any callbacksOrSelector" as argument, with custom binding logic performed in RTCPeerConnection.cpp. A fast/peerconnection/ LayoutTest is added to test all combinations. [1] https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-getstats Bug: 680172 Change-Id: I8c64fc64c708d266c926dfa3eb3587c4cbb31210 Reviewed-on: https://chromium-review.googlesource.com/978128 Commit-Queue: Henrik Boström <hbos@chromium.org> Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Reviewed-by: Harald Alvestrand <hta@chromium.org> Cr-Commit-Position: refs/heads/master@{#548149} wpt-commits: 7ba8056fed36440665a9ff9ee756b7146e9a1777 wpt-pr: 10247 wpt-commits: 7ba8056fed36440665a9ff9ee756b7146e9a1777 wpt-pr: 10247
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webrtc/RTCPeerConnection-track-stats.https.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -605387,17 +605387,17 @@
    "16fe3b155e55d1b66181788c93e570b36e5cc67d",
    "testharness"
   ],
   "webrtc/RTCPeerConnection-setRemoteDescription.html": [
    "2a2e3f9ff0a5912fa260d7124f7f5a9c3862c533",
    "testharness"
   ],
   "webrtc/RTCPeerConnection-track-stats.https.html": [
-   "55ab0ca3d364b020320fa45a14e50d2897dda13a",
+   "512e40d1b6f95c86b90ba7b536b6ae049f6a04c0",
    "testharness"
   ],
   "webrtc/RTCPeerConnectionIceEvent-constructor.html": [
    "f273bd7fdfc883a15e8fb16fef5309061254c6cc",
    "testharness"
   ],
   "webrtc/RTCRtpCapabilities-helper.js": [
    "22881ddd3cda1a64ff22474562de1568522e9745",
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-track-stats.https.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-track-stats.https.html
@@ -373,17 +373,17 @@
                   'original attachment');
       t.done();
     }))
     .catch(t.step_func(reason => {
       assert_unreached(reason);
     }));
   }, 'replaceTrack(): original track attachment stats present after replacing');
 
-  promise_test(async function() {
+  promise_test(async t => {
     const caller = new RTCPeerConnection();
     const callee = new RTCPeerConnection();
     let [tracks, streams] = await getUserMediaTracksAndStreams(2);
     let sender = caller.addTrack(tracks[0], streams[0]);
     callee.addTrack(tracks[1], streams[1]);
     exchangeIceCandidates(caller, callee);
     await doSignalingHandshake(caller, callee);
     await onIceConnectionStateCompleted(caller);
@@ -419,17 +419,17 @@
     assert_equals(findStatsOfType(senderReport, 'candidate-pair').length, 1,
         'senderReport should contain candidate-pair stats');
     assert_equals(findStatsOfType(senderReport, 'local-candidate').length, 1,
         'senderReport should contain local-candidate stats');
     assert_equals(findStatsOfType(senderReport, 'remote-candidate').length, 1,
         'senderReport should contain remote-candidate stats');
   }, 'RTCRtpSender.getStats() contains only outbound-rtp and related stats');
 
-  promise_test(async function() {
+  promise_test(async t => {
     const caller = new RTCPeerConnection();
     const callee = new RTCPeerConnection();
     let [tracks, streams] = await getUserMediaTracksAndStreams(2);
     let sender = caller.addTrack(tracks[0], streams[0]);
     callee.addTrack(tracks[1], streams[1]);
     exchangeIceCandidates(caller, callee);
     await doSignalingHandshake(caller, callee);
     await onIceConnectionStateCompleted(caller);
@@ -465,16 +465,82 @@
     assert_equals(findStatsOfType(receiverReport, 'candidate-pair').length, 1,
         'receiverReport should contain candidate-pair stats');
     assert_equals(findStatsOfType(receiverReport, 'local-candidate').length, 1,
         'receiverReport should contain local-candidate stats');
     assert_equals(findStatsOfType(receiverReport, 'remote-candidate').length, 1,
         'receiverReport should contain remote-candidate stats');
   }, 'RTCRtpReceiver.getStats() contains only inbound-rtp and related stats');
 
+  promise_test(async t => {
+    const caller = new RTCPeerConnection();
+    const callee = new RTCPeerConnection();
+    let [tracks, streams] = await getUserMediaTracksAndStreams(2);
+    let sender = caller.addTrack(tracks[0], streams[0]);
+    callee.addTrack(tracks[1], streams[1]);
+    exchangeIceCandidates(caller, callee);
+    await doSignalingHandshake(caller, callee);
+    await onIceConnectionStateCompleted(caller);
+
+    let senderReport = await sender.getStats();
+    let trackReport = await caller.getStats(sender.track);
+
+    senderReport.forEach(senderReportStat => {
+      let trackReportStat = trackReport.get(senderReportStat.id);
+      assert_object_equals(trackReportStat, senderReportStat);
+    });
+    trackReport.forEach(trackReportStat => {
+      let senderReportStat = senderReport.get(trackReportStat.id);
+      assert_object_equals(senderReportStat, trackReportStat);
+    });
+  }, 'RTCPeerConnection.getStats(sendingTrack) is the same as ' +
+     'RTCRtpSender.getStats()');
+
+  promise_test(async t => {
+    const caller = new RTCPeerConnection();
+    const callee = new RTCPeerConnection();
+    let [tracks, streams] = await getUserMediaTracksAndStreams(2);
+    let sender = caller.addTrack(tracks[0], streams[0]);
+    callee.addTrack(tracks[1], streams[1]);
+    exchangeIceCandidates(caller, callee);
+    await doSignalingHandshake(caller, callee);
+    await onIceConnectionStateCompleted(caller);
+    let receiver = caller.getReceivers()[0];
+
+    let receiverReport = await receiver.getStats();
+    let trackReport = await caller.getStats(receiver.track);
+
+    receiverReport.forEach(receiverReportStat => {
+      let trackReportStat = trackReport.get(receiverReportStat.id);
+      assert_object_equals(trackReportStat, receiverReportStat);
+    });
+    trackReport.forEach(trackReportStat => {
+      let receiverReportStat = receiverReport.get(trackReportStat.id);
+      assert_object_equals(receiverReportStat, trackReportStat);
+    });
+  }, 'RTCPeerConnection.getStats(receivingTrack) is the same as ' +
+     'RTCRtpReceiver.getStats()');
+
+  promise_test(async t => {
+    const pc = new RTCPeerConnection();
+    let [tracks, streams] = await getUserMediaTracksAndStreams(1);
+    await promise_rejects(t, 'InvalidAccessError', pc.getStats(tracks[0]));
+  }, 'RTCPeerConnection.getStats(track) throws InvalidAccessError when there ' +
+     'are zero senders or receivers for the track');
+
+  promise_test(async t => {
+    const pc = new RTCPeerConnection();
+    let [tracks, streams] = await getUserMediaTracksAndStreams(2);
+    let sender1 = pc.addTrack(tracks[0]);
+    let sender2 = pc.addTrack(tracks[1]);
+    await sender2.replaceTrack(sender1.track);
+    await promise_rejects(t, 'InvalidAccessError', pc.getStats(sender1.track));
+  }, 'RTCPeerConnection.getStats(track) throws InvalidAccessError when there ' +
+     'are multiple senders for the track');
+
   // Helpers.
 
   function findStatsByTypeAndId(report, type, identifier) {
     return findStats(report, stats => {
       return stats.type == type && stats[type + 'Identifier'] == identifier;
     });
   }
 
@@ -536,9 +602,19 @@
         let ids = stat[member];
         for (let i = 0; i < ids.length; ++i) {
           validateStatsGraphRecursively(report, ids[i], visitedIds);
         }
       }
     }
   }
 
+  async function async_assert_throws(exceptionName, promise, description) {
+    try {
+      await promise;
+    } catch (e) {
+      assert_equals(e.name, exceptionName);
+      return;
+    }
+    assert_unreached('No exception was thrown.');
+  }
+
 </script>