check-encryption-scheme.js (1817B)
1 function runTest(config, qualifier) 2 { 3 function checkEncryptionScheme(encryptionScheme) 4 { 5 var simpleConfig = getSimpleConfiguration(); 6 assert_greater_than(simpleConfig[0].audioCapabilities.length, 0); 7 simpleConfig[0].audioCapabilities.forEach(function(capability) { 8 capability.encryptionScheme = encryptionScheme; 9 }); 10 11 return navigator.requestMediaKeySystemAccess(config.keysystem, simpleConfig) 12 .then( 13 function(access) { 14 var actualConfiguration = access.getConfiguration(); 15 for (let i = 0; i < actualConfiguration.audioCapabilities.length; i++) { 16 const capability = actualConfiguration.audioCapabilities[i]; 17 18 // If "encryptionScheme" is not supported, fail. 19 if (!('encryptionScheme' in capability)) { 20 return Promise.reject('Not implemented'); 21 } 22 23 // If "encryptionScheme" is supported, it should be returned. 24 assert_equals(capability.encryptionScheme, encryptionScheme); 25 } 26 return Promise.resolve('Supported'); 27 }, 28 function error() { 29 // CDM does not support "encryptionScheme". Test should still pass. 30 return Promise.resolve('Not supported'); 31 }); 32 } 33 34 promise_test( 35 () => checkEncryptionScheme('cenc'), 36 testnamePrefix(qualifier, config.keysystem) + ' support for "cenc" encryption scheme.'); 37 38 promise_test( 39 () => checkEncryptionScheme('cbcs'), 40 testnamePrefix(qualifier, config.keysystem) + ' support for "cbcs" encryption scheme.'); 41 42 promise_test( 43 () => checkEncryptionScheme('cbcs-1-9'), 44 testnamePrefix(qualifier, config.keysystem) + 45 ' support for "cbcs-1-9" encryption scheme.'); 46 }