Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
-
CI results over the last 21 days
- This test runs only with pattern: wmfme
- Manifest: dom/media/test/mochitest_media_engine.toml
<!DOCTYPE HTML>
<html>
<head>
<title>Media Engine only test : Media Foundation CDMs are not offered without hardware video decoding</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
// PlayReady needs hardware video decoding, so its key systems must not be
// offered when hardware video decoding is unavailable, unless the graphics
// blocklist is bypassed.
const kKeySystems = [
"com.microsoft.playready.recommendation",
"com.microsoft.playready.recommendation.3000",
"com.microsoft.playready.recommendation.3000.clearlead",
];
add_task(async function setupTestingPrefs() {
await SpecialPowers.pushPrefEnv({
set: [
["media.wmf.media-engine.enabled", 2],
["media.eme.playready.enabled", true],
// Use the mock clearkey CDM to create cdm for all other key systems.
["media.eme.wmf.use-mock-cdm-for-external-cdms", true],
["media.eme.mfcdm.origin-filter.enabled", 0],
// Turns hardware video decoding off at runtime.
["media.hardware-video-decoding.failed", true],
],
});
});
add_task(async function testNotOfferedWithoutHardwareDecoding() {
await SpecialPowers.pushPrefEnv({
set: [["media.wmf.media-engine.bypass-gfx-blocklist", false]],
});
for (const keySystem of kKeySystems) {
is(await requestAccess(keySystem), "rejected: NotSupportedError",
`${keySystem} is not offered without hardware video decoding`);
}
is(await requestAccess("org.w3.clearkey"), "resolved",
"a key system outside the media engine is still offered");
await SpecialPowers.popPrefEnv();
});
add_task(async function testOfferedWhenBlocklistBypassed() {
await SpecialPowers.pushPrefEnv({
set: [["media.wmf.media-engine.bypass-gfx-blocklist", true]],
});
for (const keySystem of kKeySystems) {
is(await requestAccess(keySystem), "resolved",
`${keySystem} is offered when the graphics blocklist is bypassed`);
}
await SpecialPowers.popPrefEnv();
});
// Following are helper functions.
// Resolves to "resolved" or "rejected: <name>".
function requestAccess(aKeySystem) {
return navigator
.requestMediaKeySystemAccess(aKeySystem, [{
initDataTypes: ["keyids"],
videoCapabilities: [{ contentType: 'video/mp4;codecs="avc1.640028"' }],
sessionTypes: ["temporary"],
}])
.then(() => "resolved", e => `rejected: ${e.name}`);
}
</script>
</pre>
</body>
</html>