Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eme] Check if encryption scheme is supported #14383

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions encrypted-media/clearkey-check-encryption-scheme.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>Encrypted Media Extensions: Check encryptionScheme with Clear Key</title>
<link rel="help" href="https://w3c.github.io/encrypted-media/">

<!-- Web Platform Test Harness scripts -->
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>

<!-- Helper scripts for Encrypted Media Extensions tests -->
<script src=/encrypted-media/util/utils.js></script>
<script src=/encrypted-media/util/utf8.js></script>

<!-- Content metadata -->
<!--<script src=/encrypted-media/content/content-metadata.js></script>-->

<!-- The script for this specific test -->
<script src=/encrypted-media/scripts/check-encryption-scheme.js></script>

</head>
<body>
<div id='log'></div>

<script>
var config = { keysystem: 'org.w3.clearkey' }

runTest(config);
</script>
</body>
</html>
32 changes: 32 additions & 0 deletions encrypted-media/drm-check-encryption-scheme.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>Encrypted Media Extensions: Check encryptionScheme with DRM</title>
<link rel="help" href="https://w3c.github.io/encrypted-media/">

<!-- Web Platform Test Harness scripts -->
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>

<!-- Helper scripts for Encrypted Media Extensions tests -->
<script src=/encrypted-media/util/utils.js></script>
<script src=/encrypted-media/util/utf8.js></script>

<!-- Content metadata -->
<!--<script src=/encrypted-media/content/content-metadata.js></script>-->

<!-- The script for this specific test -->
<script src=/encrypted-media/scripts/check-encryption-scheme.js></script>

</head>
<body>
<div id='log'></div>

<script>
var config = { keysystem: getSupportedKeySystem() }

runTest(config);
</script>
</body>
</html>
41 changes: 41 additions & 0 deletions encrypted-media/scripts/check-encryption-scheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function runTest(config, qualifier)
{
function checkEncryptionScheme(encryptionScheme)
{
var simpleConfig = getSimpleConfiguration();
assert_greater_than(simpleConfig[0].audioCapabilities.length, 0);
simpleConfig[0].audioCapabilities.forEach(function(capability) {
capability.encryptionScheme = encryptionScheme;
});

return navigator.requestMediaKeySystemAccess(config.keysystem, simpleConfig)
.then(
function(access) {
var actualConfiguration = access.getConfiguration();
for (let i = 0; i < actualConfiguration.audioCapabilities.length; i++) {
const capability = actualConfiguration.audioCapabilities[i];

// If "encryptionScheme" is not supported, fail.
if (!('encryptionScheme' in capability)) {
return Promise.reject('Not implemented');
}

// If "encryptionScheme" is supported, it should be returned.
assert_equals(capability.encryptionScheme, encryptionScheme);
}
return Promise.resolve('Supported');
},
function error() {
// CDM does not support "encryptionScheme". Test should still pass.
return Promise.resolve('Not supported');
});
}

promise_test(
() => checkEncryptionScheme('cenc'),
testnamePrefix(qualifier, config.keysystem) + ' support for "cenc" encryption scheme.');

promise_test(
() => checkEncryptionScheme('cbcs'),
testnamePrefix(qualifier, config.keysystem) + ' support for "cbcs" encryption scheme.');
}