Skip to content

Commit dc97e7b

Browse files
beback4uchromium-wpt-export-bot
authored andcommitted
Media Capabilities: Add robust WPT for encryptionScheme plumbing
Previously, WPT tests for mediaCapabilities.decodingInfo() encryptionScheme plumbing succeeded even if the plumbing was missing or incomplete. This was because the tests only validated that the returned object has supported/smooth/powerEfficient as booleans using the standard Clear Key system (which supports both cenc and cbcs). To make these tests fail when the plumbing is missing or broken: 1. Define a helper function in WPT that queries decodingInfo() with a specific encryptionScheme, and asserts that the negotiated configuration matches the expected scheme and support status. 2. Run test cases covering different valid encryption schemes ('cenc', 'cbcs', 'cbcs-1-9'), as well as unrecognized ('foobar') and null schemes. If the plumbing is missing, unrecognized schemes will be incorrectly supported, and valid schemes will negotiate as null instead of their expected scheme, causing the tests to fail. 3. Remove the obsolete and non-assertive tests that only checked that the result type was a boolean. Bug: 498284510 Change-Id: I88b3c01f7b3f200312b948f18714707ca2aa7c32 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8076778 Reviewed-by: Xiaohan Wang <xhwang@chromium.org> Commit-Queue: Sangbaek Park <sangbaekpark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1662185}
1 parent e69af49 commit dc97e7b

1 file changed

Lines changed: 43 additions & 25 deletions

File tree

media-capabilities/decodingInfoEncryptedMedia.https.html

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
}));
260260
}, "Test that decodingInfo with type webrtc rejects key system configuration.");
261261

262-
promise_test(async t => {
262+
async function runEncryptionSchemeTest(t, scheme, expectedSupported) {
263263
const config = {
264264
type: 'file',
265265
video: minimalVideoConfiguration,
@@ -268,36 +268,54 @@
268268
keySystem: 'org.w3.clearkey',
269269
video: {
270270
robustness: '',
271-
encryptionScheme: 'cenc' // <- New field being tested
271+
encryptionScheme: scheme
272272
}
273273
}
274274
};
275275

276-
const result = await navigator.mediaCapabilities.decodingInfo(config);
276+
const info = await navigator.mediaCapabilities.decodingInfo(config);
277+
assert_equals(info.supported, expectedSupported, `supported should be ${expectedSupported}`);
277278

278-
// As long as it resolves to an object with `supported` (even if false),
279-
// the IDL parser correctly digested `encryptionScheme`.
280-
assert_equals(typeof result.supported, 'boolean', "supported should be a boolean");
281-
assert_equals(typeof result.smooth, 'boolean', "smooth should be a boolean");
282-
assert_equals(typeof result.powerEfficient, 'boolean', "powerEfficient should be a boolean");
283-
}, "decodingInfo() accepts KeySystemTrackConfiguration with encryptionScheme");
279+
if (expectedSupported) {
280+
assert_not_equals(info.keySystemAccess, null, "keySystemAccess should be present in the result.");
281+
const negotiatedConfig = info.keySystemAccess.getConfiguration();
282+
assert_true(
283+
!!negotiatedConfig.videoCapabilities && negotiatedConfig.videoCapabilities.length > 0,
284+
"videoCapabilities should be present in the negotiated configuration."
285+
);
284286

285-
promise_test(async t => {
286-
const config = {
287-
type: 'file',
288-
video: minimalVideoConfiguration,
289-
audio: minimalAudioConfiguration,
290-
keySystemConfiguration: {
291-
keySystem: 'org.w3.clearkey',
292-
video: {
293-
robustness: '',
294-
encryptionScheme: null // <- Explicitly testing nullable
295-
}
296-
}
297-
};
287+
// If the encryptionScheme is not passed from mediaCapabilities.decodingInfo()
288+
// to the EME query, the negotiated keySystemAccess configuration will not contain
289+
// the requested encryptionScheme (it will be null/unspecified).
290+
assert_equals(
291+
negotiatedConfig.videoCapabilities[0].encryptionScheme,
292+
scheme,
293+
`negotiated encryptionScheme should match requested scheme: ${scheme}`
294+
);
295+
} else {
296+
assert_equals(info.keySystemAccess, null, "keySystemAccess should be null when not supported.");
297+
}
298+
}
299+
300+
promise_test(t => {
301+
return runEncryptionSchemeTest(t, 'cenc', true);
302+
}, "decodingInfo() supports 'cenc' encryptionScheme and echoes it back.");
303+
304+
promise_test(t => {
305+
return runEncryptionSchemeTest(t, 'cbcs', true);
306+
}, "decodingInfo() supports 'cbcs' encryptionScheme and echoes it back.");
307+
308+
promise_test(t => {
309+
return runEncryptionSchemeTest(t, 'cbcs-1-9', true);
310+
}, "decodingInfo() supports 'cbcs-1-9' encryptionScheme and echoes it back.");
311+
312+
promise_test(t => {
313+
return runEncryptionSchemeTest(t, 'foobar', false);
314+
}, "decodingInfo() with unrecognized encryptionScheme returns supported: false.");
315+
316+
promise_test(t => {
317+
return runEncryptionSchemeTest(t, null, true);
318+
}, "decodingInfo() with null encryptionScheme returns supported: true and echoes null.");
298319

299-
const result = await navigator.mediaCapabilities.decodingInfo(config);
300-
assert_equals(typeof result.supported, 'boolean');
301-
}, "decodingInfo() accepts KeySystemTrackConfiguration with null encryptionScheme");
302320

303321
</script>

0 commit comments

Comments
 (0)