зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1878713 - part2 : implement GetStatusForPolicy for ClearKey CDM. r=media-playback-reviewers,jolin
This patch implement GetStatusForPolicy for ClearKey CDM so that we can extend our test coverage. Differential Revision: https://phabricator.services.mozilla.com/D200757
This commit is contained in:
Родитель
d8f7773781
Коммит
26d844a92e
|
@ -816,18 +816,6 @@ already_AddRefed<Promise> MediaKeys::GetStatusForPolicy(
|
|||
return promise.forget();
|
||||
}
|
||||
|
||||
// Currently, only widevine CDM supports for this API.
|
||||
if (!IsWidevineKeySystem(mKeySystem)) {
|
||||
EME_LOG(
|
||||
"MediaKeys[%p]::GetStatusForPolicy() HDCP policy check on unsupported "
|
||||
"keysystem ",
|
||||
this);
|
||||
NS_WARNING("Tried to query without a CDM");
|
||||
promise->MaybeRejectWithNotSupportedError(
|
||||
"HDCP policy check on unsupported keysystem");
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
if (!mProxy) {
|
||||
NS_WARNING("Tried to use a MediaKeys without a CDM");
|
||||
promise->MaybeRejectWithInvalidStateError(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test Encrypted Media Extensions</title>
|
||||
<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>
|
||||
|
@ -12,8 +12,70 @@
|
|||
<video id="v" controls></video>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
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(e => 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) {
|
||||
|
@ -25,30 +87,6 @@ function createMediaKeysAndSet() {
|
|||
});
|
||||
}
|
||||
|
||||
function test() {
|
||||
createMediaKeysAndSet()
|
||||
.then((m) => {
|
||||
let video = document.getElementById("v");
|
||||
is(video.mediaKeys, m, "Should have set MediaKeys on media element");
|
||||
// getStatusForPolicy() is not suppored by ClearKey key system.
|
||||
// The promise will always be rejected with NotSupportedError.
|
||||
return video.mediaKeys.getStatusForPolicy({minHdcpVersion: "hdcp-2.0"});
|
||||
})
|
||||
.then((mediaKeyStatus) => {
|
||||
ok(false, "Promise of getStatusForPolicy should not be resolved with clearkey key system");
|
||||
})
|
||||
// Promise rejected with NotSupportedError as expected.
|
||||
.catch(reason => is("NotSupportedError", reason.name,
|
||||
"Promise should be rejected with NotSupportedError."))
|
||||
.then(() => SimpleTest.finish());
|
||||
}
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set":
|
||||
[
|
||||
["media.eme.hdcp-policy-check.enabled", true],
|
||||
]
|
||||
}, test);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -25,10 +25,13 @@ void ClearKeyCDM::Initialize(bool aAllowDistinctiveIdentifier,
|
|||
|
||||
void ClearKeyCDM::GetStatusForPolicy(uint32_t aPromiseId,
|
||||
const Policy& aPolicy) {
|
||||
// MediaKeys::GetStatusForPolicy checks the keysystem and
|
||||
// reject the promise with NS_ERROR_DOM_NOT_SUPPORTED_ERR without calling CDM.
|
||||
// This function should never be called and is not supported.
|
||||
assert(false);
|
||||
// Pretend the device is HDCP 2.1 compliant.
|
||||
const cdm::HdcpVersion kDeviceHdcpVersion = cdm::kHdcpVersion2_1;
|
||||
if (aPolicy.min_hdcp_version <= kDeviceHdcpVersion) {
|
||||
mHost->OnResolveKeyStatusPromise(aPromiseId, KeyStatus::kUsable);
|
||||
} else {
|
||||
mHost->OnResolveKeyStatusPromise(aPromiseId, KeyStatus::kOutputRestricted);
|
||||
}
|
||||
}
|
||||
void ClearKeyCDM::SetServerCertificate(uint32_t aPromiseId,
|
||||
const uint8_t* aServerCertificateData,
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featurePolicy.header.enabled:true, dom.security.featurePolicy.webidl.enabled:true]
|
||||
prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featurePolicy.header.enabled:true, dom.security.featurePolicy.webidl.enabled:true, media.eme.hdcp-policy-check.enabled:true]
|
||||
lsan-disabled: true
|
||||
leak-threshold: [default:51200]
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
expected: FAIL
|
||||
|
||||
[org.w3.clearkey support for HDCP 1.0.]
|
||||
expected: FAIL
|
||||
expected:
|
||||
if (os == "android"): [FAIL, PASS]
|
||||
|
|
Загрузка…
Ссылка в новой задаче