mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 17:24:29 +00:00
Bug 1878039 - part2 : add test for mfcdm. r=jolin
Differential Revision: https://phabricator.services.mozilla.com/D200985
This commit is contained in:
parent
4ab0545847
commit
28ab226d21
@ -6,3 +6,5 @@ skip-if = ["!wmfme"]
|
||||
["test_eme_mfcdm_generate_request.html"]
|
||||
|
||||
["test_eme_wideinve_l1_installation.html"]
|
||||
|
||||
["test_eme_mfcdm_getstatusforpolicy.html"]
|
||||
|
115
dom/media/test/test_eme_mfcdm_getstatusforpolicy.html
Normal file
115
dom/media/test/test_eme_mfcdm_getstatusforpolicy.html
Normal file
@ -0,0 +1,115 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test getStatusForPolicy on MFCDM</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],
|
||||
["media.wmf.media-engine.enabled", 2],
|
||||
["media.eme.playready.enabled", true],
|
||||
["media.eme.widevine.experiment.enabled", true],
|
||||
// This is used to trigger Widevine CDM installation check
|
||||
["media.gmp-widevinecdm-l1.enabled", true],
|
||||
["media.eme.wmf.clearkey.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],
|
||||
// Our mock CDM doesn't implement 'IsTypeSupportedEx()', only 'IsTypeSupported()'
|
||||
["media.eme.playready.istypesupportedex", false],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
// We expect that all key system have HDCP 2.1 compliant, which is pre-defined
|
||||
// in `WMFClearKeyCDMFactory::IsTypeSupported`.
|
||||
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"
|
||||
},
|
||||
];
|
||||
|
||||
const kKeySystems = [
|
||||
"com.microsoft.playready.recommendation",
|
||||
"com.microsoft.playready.recommendation.3000",
|
||||
"com.microsoft.playready.recommendation.3000.clearlead",
|
||||
"com.widevine.alpha.experiment",
|
||||
"com.widevine.alpha.experiment2",
|
||||
"org.w3.clearkey",
|
||||
];
|
||||
|
||||
add_task(async function testGetStatusForPolicy() {
|
||||
for (let keySystem of kKeySystems) {
|
||||
for (let result of expectedResults) {
|
||||
let mediaKey = await createMediaKeysAndSet(keySystem);
|
||||
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(keySystem) {
|
||||
return navigator.requestMediaKeySystemAccess(keySystem, gCencMediaKeySystemConfig)
|
||||
.then(function (access) {
|
||||
return access.createMediaKeys();
|
||||
})
|
||||
.then(function (mediaKeys) {
|
||||
document.getElementById("v").setMediaKeys(mediaKeys);
|
||||
return mediaKeys;
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "WMFClearKeyCDMFactory.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <Mferror.h>
|
||||
|
||||
#include "WMFClearKeyCDMAccess.h"
|
||||
@ -15,11 +17,36 @@ using Microsoft::WRL::MakeAndInitialize;
|
||||
|
||||
ActivatableClass(WMFClearKeyCDMFactory);
|
||||
|
||||
bool isRequiringHDCP22OrAbove(LPCWSTR aType) {
|
||||
if (aType == nullptr || *aType == L'\0') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The HDCP value follows the feature value in
|
||||
// https://docs.microsoft.com/en-us/uwp/api/windows.media.protection.protectioncapabilities.istypesupported?view=winrt-19041
|
||||
// - 1 (on without HDCP 2.2 Type 1 restriction)
|
||||
// - 2 (on with HDCP 2.2 Type 1 restriction)
|
||||
std::wstring wstr(aType);
|
||||
std::string hdcpStr(wstr.begin(), wstr.end());
|
||||
return wstr.find(L"hdcp=2") != std::string::npos;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(BOOL)
|
||||
WMFClearKeyCDMFactory::IsTypeSupported(_In_ LPCWSTR aKeySystem,
|
||||
_In_opt_ LPCWSTR aContentType) {
|
||||
// For testing, always return support. Maybe we can block support for certain
|
||||
// type if needed?
|
||||
// For testing, return support for most of cases. Only returns false for some
|
||||
// special cases.
|
||||
|
||||
bool needHDCP22OrAbove = isRequiringHDCP22OrAbove(aContentType);
|
||||
ENTRY_LOG_ARGS("Need-HDCP2.2+=%d", needHDCP22OrAbove);
|
||||
|
||||
// As the API design of the Media Foundation, we can only know whether the
|
||||
// requester is asking for HDCP 2.2+ or not, we can't know the exact HDCP
|
||||
// version which is used in getStatusPolicy web api. Therefore, we pretend
|
||||
// ourselves only having HDCP 2.1 compliant.
|
||||
if (needHDCP22OrAbove) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user