mirror of
https://github.com/servo/servo.git
synced 2025-09-11 07:28:19 +01:00
Update web-platform-tests to revision 592e2ed83ecd717392d37047536250ba74f1bafa
This commit is contained in:
parent
c8b0dc965d
commit
0a3e19aac8
65 changed files with 1906 additions and 106 deletions
|
@ -378,6 +378,52 @@
|
|||
}));
|
||||
}, 'replaceTrack(): original track attachment stats present after replacing');
|
||||
|
||||
promise_test(async function() {
|
||||
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];
|
||||
|
||||
// Obtain inbound and outbound RTP stream stats on a full stats report.
|
||||
let fullReport = await caller.getStats();
|
||||
let outboundTrackStats = findStatsByTypeAndId(
|
||||
fullReport, 'track', sender.track.id);
|
||||
let outboundStats = findStatsByTypeAndMember(
|
||||
fullReport, 'outbound-rtp', 'trackId', outboundTrackStats.id);
|
||||
assert_true(outboundStats != null, 'Has stats for outbound RTP stream');
|
||||
let inboundTrackStats = findStatsByTypeAndId(
|
||||
fullReport, 'track', receiver.track.id);
|
||||
let inboundStats = findStatsByTypeAndMember(
|
||||
fullReport, 'inbound-rtp', 'trackId', inboundTrackStats.id);
|
||||
assert_true(inboundStats != null, 'Has stats for inbound RTP stream');
|
||||
|
||||
// Perform stats selection algorithm with sender selector. The result should
|
||||
// contain the outbound-rtp but not the inbound-rtp.
|
||||
let senderReport = await sender.getStats();
|
||||
assert_true(senderReport.has(outboundStats.id));
|
||||
assert_false(senderReport.has(inboundStats.id));
|
||||
|
||||
// Validate the stats graph, ensuring all stats objects are reachable and
|
||||
// valid from the outbound-rtp stats.
|
||||
validateStatsGraph(senderReport, senderReport.get(outboundStats.id));
|
||||
// Ensure that the stats graph contains some expected dictionaries.
|
||||
assert_equals(findStatsOfType(senderReport, 'track').length, 1,
|
||||
'senderReport should contain track stats');
|
||||
assert_equals(findStatsOfType(senderReport, 'transport').length, 1,
|
||||
'senderReport should contain transport stats');
|
||||
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');
|
||||
|
||||
// Helpers.
|
||||
|
||||
function findStatsByTypeAndId(report, type, identifier) {
|
||||
|
@ -400,4 +446,53 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
function findStatsOfType(report, type) {
|
||||
let stats = [];
|
||||
for (let it = report.values(), n = it.next(); !n.done; n = it.next()) {
|
||||
if (n.value.type == type)
|
||||
stats.push(n.value);
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
// Returns a promise that is resolved when pc.iceConnectionState changes to
|
||||
// 'completed'. This is when transport stats can be expected to have its
|
||||
// selectedCandidatePairId defined.
|
||||
async function onIceConnectionStateCompleted(pc) {
|
||||
let resolver = new Resolver();
|
||||
pc.oniceconnectionstatechange = e => {
|
||||
if (pc.iceConnectionState == 'completed')
|
||||
resolver.resolve();
|
||||
};
|
||||
return resolver.promise;
|
||||
}
|
||||
|
||||
// Explores the stats graph starting from |stat|, validating each stat
|
||||
// (validateRtcStats) and asserting that all stats of the report were visited.
|
||||
function validateStatsGraph(report, stat) {
|
||||
let visitedIds = new Set();
|
||||
validateStatsGraphRecursively(report, stat.id, visitedIds);
|
||||
assert_equals(visitedIds.size, report.size,
|
||||
'Entire stats graph should have been explored.')
|
||||
}
|
||||
|
||||
function validateStatsGraphRecursively(report, currentId, visitedIds) {
|
||||
if (visitedIds.has(currentId))
|
||||
return;
|
||||
visitedIds.add(currentId);
|
||||
assert_true(report.has(currentId), 'Broken reference.');
|
||||
let stat = report.get(currentId);
|
||||
validateRtcStats(report, stat);
|
||||
for (let member in stat) {
|
||||
if (member.endsWith('Id')) {
|
||||
validateStatsGraphRecursively(report, stat[member], visitedIds);
|
||||
} else if (member.endsWith('Ids')) {
|
||||
let ids = stat[member];
|
||||
for (let i = 0; i < ids.length; ++i) {
|
||||
validateStatsGraphRecursively(report, ids[i], visitedIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<title>RTCRtpSender.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>
|
||||
|
@ -12,6 +13,9 @@
|
|||
// webrtc-pc 20171130
|
||||
// webrtc-stats 20171122
|
||||
|
||||
// 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
|
||||
|
@ -35,31 +39,28 @@
|
|||
objects added.
|
||||
*/
|
||||
|
||||
promise_test(() => {
|
||||
const pc = new RTCPeerConnection();
|
||||
const { sender } = pc.addTransceiver('audio');
|
||||
promise_test(async () => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
const { sender } = caller.addTransceiver('audio');
|
||||
|
||||
return sender.getStats()
|
||||
.then(statsReport => {
|
||||
validateStatsReport(statsReport);
|
||||
assert_stats_report_has_stats(statsReport, ['outbound-rtp']);
|
||||
});
|
||||
await doSignalingHandshake(caller, callee);
|
||||
const statsReport = await sender.getStats();
|
||||
validateStatsReport(statsReport);
|
||||
assert_stats_report_has_stats(statsReport, ['outbound-rtp']);
|
||||
}, 'sender.getStats() via addTransceiver should return stats report containing outbound-rtp stats');
|
||||
|
||||
promise_test(() => {
|
||||
const pc = new RTCPeerConnection();
|
||||
promise_test(async () => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
const stream = await navigator.mediaDevices.getUserMedia({audio:true});
|
||||
const [track] = stream.getTracks();
|
||||
const sender = caller.addTrack(track, stream);
|
||||
|
||||
return navigator.mediaDevices.getUserMedia({ audio: true })
|
||||
.then(mediaStream => {
|
||||
const [track] = mediaStream.getTracks();
|
||||
const sender = pc.addTrack(track, mediaStream);
|
||||
|
||||
return sender.getStats()
|
||||
.then(statsReport => {
|
||||
validateStatsReport(statsReport);
|
||||
assert_stats_report_has_stats(statsReport, ['outbound-rtp']);
|
||||
});
|
||||
})
|
||||
await doSignalingHandshake(caller, callee);
|
||||
const statsReport = await sender.getStats();
|
||||
validateStatsReport(statsReport);
|
||||
assert_stats_report_has_stats(statsReport, ['outbound-rtp']);
|
||||
}, 'sender.getStats() via addTrack should return stats report containing outbound-rtp stats');
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue