gecko-dev/testing/web-platform/tests/webrtc/RTCRtpReceiver-getStats.https.html
Philipp Hancke e08790baea Bug 1509173 [wpt PR 14170] - webrtc-wpt: use addTrack(track, stream) to increase firefox compat, a=testonly
Automatic update from web-platform-tests
webrtc-wpt: use addTrack(track, stream) to increase firefox compat

Firefox does not support addTrack(track). Add a track whereever it makes sense.
The addTrack tests itself might rightfully use this.

The following grep shows most affected places:
  git grep addTrack *.html | grep -v , | grep -v "\.\.\."

Bug: None
Change-Id: Ib225e6d51184c3ccc446ccf93447e2ac7be080c3
Reviewed-on: https://chromium-review.googlesource.com/c/1346394
Reviewed-by: Henrik Boström <hbos@chromium.org>
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Cr-Commit-Position: refs/heads/master@{#611262}

--

wpt-commits: 641ad0bf0df17b0f422642afa6019a594ef8d0e8
wpt-pr: 14170
2018-12-11 15:50:00 +00:00

83 lines
3.2 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>RTCRtpReceiver.prototype.getStats</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script src="dictionary-helper.js"></script>
<script src="RTCStats-helper.js"></script>
<script>
'use strict';
// Test is based on the following editor draft:
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
// https://w3c.github.io/webrtc-stats/archives/20170614/webrtc-stats.html
// The following helper functions are called from RTCPeerConnection-helper.js:
// doSignalingHandshake
// The following helper function is called from RTCStats-helper.js
// validateStatsReport
// assert_stats_report_has_stats
/*
5.3. RTCRtpReceiver Interface
interface RTCRtpReceiver {
Promise<RTCStatsReport> getStats();
...
};
getStats
1. Let selector be the RTCRtpReceiver object on which the method was invoked.
2. Let p be a new promise, and run the following steps in parallel:
1. Gather the stats indicated by selector according to the stats selection
algorithm.
2. Resolve p with the resulting RTCStatsReport object, containing the
gathered stats.
3. Return p.
8.5. The stats selection algorithm
4. If selector is an RTCRtpReceiver, gather stats for and add the following objects
to result:
- All RTCInboundRTPStreamStats objects corresponding to selector.
- All stats objects referenced directly or indirectly by the RTCInboundRTPStreamStats
added.
*/
promise_test(async t => {
const caller = new RTCPeerConnection();
t.add_cleanup(() => caller.close());
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const stream = await getNoiseStream({audio:true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
callee.addTrack(track, stream);
const { receiver } = caller.addTransceiver('audio');
await doSignalingHandshake(caller, callee);
const statsReport = await receiver.getStats();
validateStatsReport(statsReport);
assert_stats_report_has_stats(statsReport, ['inbound-rtp']);
}, 'receiver.getStats() via addTransceiver should return stats report containing inbound-rtp stats');
promise_test(async t => {
const caller = new RTCPeerConnection();
t.add_cleanup(() => caller.close());
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const stream = await getNoiseStream({audio:true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
caller.addTrack(track, stream);
await doSignalingHandshake(caller, callee);
const receiver = callee.getReceivers()[0];
const statsReport = await receiver.getStats();
validateStatsReport(statsReport);
assert_stats_report_has_stats(statsReport, ['inbound-rtp']);
}, 'receiver.getStats() via addTrack should return stats report containing inbound-rtp stats');
</script>