Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE HTML>
<html>
<head>
<title>Test getStatusForPolicy on ClearKey CDM</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
<script type="text/javascript" src="eme.js"></script>
</head>
<body>
<pre id="test">
<video id="v" controls></video>
<script class="testbody" type="text/javascript">
add_task(async function setupTestingPrefs() {
await SpecialPowers.pushPrefEnv({
set: [
["media.eme.hdcp-policy-check.enabled", true],
],
});
});
// We expect that ClearKey has HDCP 2.0 compliant.
const expectedResults = [
{
minHdcpVersion : "1.0",
expectedResult : "usable"
},
{
minHdcpVersion : "1.1",
expectedResult : "usable"
},
{
minHdcpVersion : "1.2",
expectedResult : "usable"
},
{
minHdcpVersion : "1.3",
expectedResult : "usable"
},
{
minHdcpVersion : "1.4",
expectedResult : "usable"
},
{
minHdcpVersion : "2.0",
expectedResult : "usable"
},
{
minHdcpVersion : "2.1",
expectedResult : "usable"
},
{
minHdcpVersion : "2.2",
expectedResult : "output-restricted"
},
{
minHdcpVersion : "2.3",
expectedResult : "output-restricted"
},
];
add_task(async function testGetStatusForPolicy() {
for (let result of expectedResults) {
let mediaKey = await createMediaKeysAndSet();
let video = document.getElementById("v");
is(video.mediaKeys, mediaKey,
"Should have set MediaKeys on media element");
let keyStatus = await
video.mediaKeys.getStatusForPolicy({minHdcpVersion : result.minHdcpVersion})
.catch(() => ok(false, "getStatusForPolicy failed!"));
info(`getStatusForPolicy for HDCP ${result.minHdcpVersion} : ${keyStatus}`);
is(keyStatus, result.expectedResult,
`Expected ${result.expectedResult}, got ${keyStatus}`);
}
});
// Helper function
function createMediaKeysAndSet() {
return navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, gCencMediaKeySystemConfig)
.then(function (access) {
return access.createMediaKeys();
})
.then(function (mediaKeys) {
document.getElementById("v").setMediaKeys(mediaKeys);
return mediaKeys;
});
}
</script>
</pre>
</body>
</html>