Files
sousa-gecko/testing/web-platform/tests/webrtc-stats/hardware-capability-stats.https.html
T
Henrik Boström f2e48b4eb1 Bug 1985729 [wpt PR 54560] - Update hardware-capability-stats WPT not to assume premature RTP stats., a=testonly
Automatic update from web-platform-tests
Update hardware-capability-stats WPT not to assume premature RTP stats.

The helper method hasEncodedAndDecodedFrames() which waits until frames
are encoded and decoded should not assume that RTP stats objects exists,
it is both out of place for this WPT to test and it it's assertion that
inbound-rtp stats objects exists prior to receiving packets contradicts
the spec.

Bug: chromium:406585888
Change-Id: I529846c3002b6c336c5cf60af98e3892545ad558
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6890836
Commit-Queue: Harald Alvestrand <hta@chromium.org>
Reviewed-by: Harald Alvestrand <hta@chromium.org>
Commit-Queue: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1507592}

--

wpt-commits: ba896743fd4ee29efc8e5003619f0e059d8bfdda
wpt-pr: 54560
2025-09-01 08:30:32 +00:00

109 lines
3.9 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>Stats exposing hardware capability</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="../webrtc/RTCPeerConnection-helper.js"></script>
<script>
/*
* Test stats that expose hardware capabilities are only exposed according to
* the conditions described in https://w3c.github.io/webrtc-stats/#limiting-exposure-of-hardware-capabilities.
*/
'use strict';
function getStatEntry(report, type, kind, assertStatsExists = true) {
const values = [...report.values()];
const for_kind = values.filter(
stat => stat.type == type && stat.kind == kind);
if (assertStatsExists) {
assert_equals(1, for_kind.length,
"Expected report to have only 1 entry with type '" + type +
"' and kind '" + kind + "'. Found values " + for_kind);
}
return for_kind.length > 0 ? for_kind[0] : null;
}
async function hasEncodedAndDecodedFrames(pc, t) {
while (true) {
const report = await pc.getStats();
const inboundRtp = getStatEntry(report, 'inbound-rtp', 'video', false);
const outboundRtp = getStatEntry(report, 'outbound-rtp', 'video', false);
if (inboundRtp?.framesDecoded > 0 && outboundRtp?.framesEncoded > 0) {
return;
}
// Avoid any stats caching, which can otherwise make this an infinite loop.
await (new Promise(r => t.step_timeout(r, 100)));
}
}
async function setupPcAndGetStatEntry(
t, stream, type, kind, stat) {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
for (const track of stream.getTracks()) {
pc1.addTrack(track, stream);
pc2.addTrack(track, stream);
t.add_cleanup(() => track.stop());
}
exchangeIceCandidates(pc1, pc2);
await exchangeOfferAnswer(pc1, pc2);
await hasEncodedAndDecodedFrames(pc1, t);
const report = await pc1.getStats();
return getStatEntry(report, type, kind);
}
for (const args of [
// RTCOutboundRtpStreamStats.powerEfficientEncoder
['outbound-rtp', 'video', 'powerEfficientEncoder'],
// RTCOutboundRtpStreamStats.encoderImplementation
['outbound-rtp', 'video', 'encoderImplementation'],
// RTCInboundRtpStreamStats.powerEfficientDecoder
['inbound-rtp', 'video', 'powerEfficientDecoder'],
// RTCOutboundRtpStreamStats.decoderImplementation
['inbound-rtp', 'video', 'decoderImplementation'],
]) {
const type = args[0];
const kind = args[1];
const stat = args[2];
promise_test(async (t) => {
const stream = await getNoiseStream({video: true, audio: true});
const statsEntry = await setupPcAndGetStatEntry(t, stream, type, kind, stat);
assert_not_own_property(statsEntry, stat);
}, stat + " not exposed when not capturing.");
// Exposing hardware capabilities when a there is a fullscreen element was
// removed with https://github.com/w3c/webrtc-stats/pull/713.
promise_test(async (t) => {
const stream = await getNoiseStream({video: true, audio: true});
const element = document.getElementById('elementToFullscreen');
await test_driver.bless("fullscreen", () => element.requestFullscreen());
t.add_cleanup(() => document.exitFullscreen());
const statsEntry = await setupPcAndGetStatEntry(
t, stream, type, kind, stat);
assert_not_own_property(statsEntry, stat);
}, stat + " not exposed when fullscreen and not capturing.");
promise_test(async (t) => {
const stream = await navigator.mediaDevices.getUserMedia(
{video: true, audio: true});
const statsEntry = await setupPcAndGetStatEntry(
t, stream, type, kind, stat);
assert_own_property(statsEntry, stat);
}, stat + " exposed when capturing.");
}
</script>
<body>
<div id="elementToFullscreen"></div>
</body>