| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Verify MediaKeySession.keyStatuses handles multiple keys</title> | 4 <title>Verify MediaKeySession.keyStatuses handles multiple keys</title> |
| 5 <script src="encrypted-media-utils.js"></script> | 5 <script src="encrypted-media-utils.js"></script> |
| 6 <script src="../../resources/testharness.js"></script> | 6 <script src="../../resources/testharness.js"></script> |
| 7 <script src="../../resources/testharnessreport.js"></script> | 7 <script src="../../resources/testharnessreport.js"></script> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <script> | 10 <script> |
| 11 async_test(function(test) | 11 async_test(function(test) |
| 12 { | 12 { |
| 13 var mediaKeySession; | 13 var mediaKeySession; |
| 14 var initDataType; | 14 var initDataType; |
| 15 var initData; | 15 var initData; |
| 16 | 16 |
| 17 // Create a list of multiple unique keyIds. | 17 // Create a list of multiple unique keyIds. |
| 18 var keyIds = [ stringToUint8Array('keyid'), | 18 const keyIds = [ |
| 19 stringToUint8Array('a really long keyid'), | 19 { keyId: stringToUint8Array('keyid'), status: 'usable' }, |
| 20 new Uint8Array([0,1,2,3]), | 20 { keyId: stringToUint8Array('a really long keyid'), status:
'usable' }, |
| 21 new Uint8Array([0,1,2,3,4]), | 21 { keyId: new Uint8Array([0,1,2,3]), status: 'usable' }, |
| 22 new Uint8Array([0,1,2,3,4,5]), | 22 { keyId: new Uint8Array([0,1,2,3,4]), status: 'usable' }, |
| 23 new Uint8Array([0,1,2,3,4,6]), | 23 { keyId: new Uint8Array([0,1,2,3,4,5]), status: 'usable' }, |
| 24 stringToUint8Array('7'), | 24 { keyId: new Uint8Array([0,1,2,3,4,6]), status: 'usable' }, |
| 25 stringToUint8Array('8'), | 25 { keyId: stringToUint8Array('7'), status: 'usable' }, |
| 26 stringToUint8Array('9'), | 26 { keyId: stringToUint8Array('8'), status: 'usable' }, |
| 27 stringToUint8Array('10'), | 27 { keyId: stringToUint8Array('9'), status: 'usable' }, |
| 28 stringToUint8Array('11'), | 28 { keyId: stringToUint8Array('10'), status: 'usable' }, |
| 29 stringToUint8Array('12'), | 29 { keyId: stringToUint8Array('11'), status: 'usable' }, |
| 30 stringToUint8Array('13'), | 30 { keyId: stringToUint8Array('12'), status: 'usable' }, |
| 31 stringToUint8Array('14'), | 31 { keyId: stringToUint8Array('13'), status: 'usable' }, |
| 32 stringToUint8Array('15'), | 32 { keyId: stringToUint8Array('14'), status: 'usable' }, |
| 33 stringToUint8Array('16'), | 33 { keyId: stringToUint8Array('15'), status: 'usable' }, |
| 34 stringToUint8Array('17'), | 34 { keyId: stringToUint8Array('16'), status: 'usable' }, |
| 35 stringToUint8Array('18'), | 35 { keyId: stringToUint8Array('17'), status: 'usable' }, |
| 36 stringToUint8Array('19'), | 36 { keyId: stringToUint8Array('18'), status: 'usable' }, |
| 37 stringToUint8Array('20'), | 37 { keyId: stringToUint8Array('19'), status: 'usable' }, |
| 38 stringToUint8Array('21'), | 38 { keyId: stringToUint8Array('20'), status: 'usable' }, |
| 39 stringToUint8Array('22'), | 39 { keyId: stringToUint8Array('21'), status: 'usable' }, |
| 40 stringToUint8Array('23'), | 40 { keyId: stringToUint8Array('22'), status: 'usable' }, |
| 41 stringToUint8Array('24'), | 41 { keyId: stringToUint8Array('23'), status: 'usable' }, |
| 42 stringToUint8Array('25') | 42 { keyId: stringToUint8Array('24'), status: 'usable' }, |
| 43 ]; | 43 { keyId: stringToUint8Array('25'), status: 'usable' } |
| 44 ]; |
| 44 | 45 |
| 45 | 46 |
| 46 function processKeyStatusesChange(event) | 47 function processKeyStatusesChange(event) |
| 47 { | 48 { |
| 48 // All 25 keyIds should be returned in keyStatuses. | 49 // All 25 keyIds should be returned in keyStatuses. |
| 49 verifyKeyStatuses(mediaKeySession.keyStatuses, { expected: k
eyIds, unexpected: [] }); | 50 verifyKeyStatuses(mediaKeySession.keyStatuses, keyIds); |
| 50 test.done(); | 51 test.done(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 function processMessage(event) | 54 function processMessage(event) |
| 54 { | 55 { |
| 55 // No keys added yet. | 56 // No keys added yet. |
| 56 assert_equals(mediaKeySession.keyStatuses.size, 0); | 57 assert_equals(mediaKeySession.keyStatuses.size, 0); |
| 57 | 58 |
| 58 waitForEventAndRunStep('keystatuseschange', mediaKeySession,
processKeyStatusesChange, test); | 59 waitForEventAndRunStep('keystatuseschange', mediaKeySession,
processKeyStatusesChange, test); |
| 59 | 60 |
| 60 // Use the same key for all 25 keyIds. | 61 // Use the same key for all 25 keyIds. |
| 61 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0
x14, 0xd2, 0x7b, | 62 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0
x14, 0xd2, 0x7b, |
| 62 0x68, 0xef, 0x12, 0x2a, 0xfc, 0
xe4, 0xae, 0x3c]); | 63 0x68, 0xef, 0x12, 0x2a, 0xfc, 0
xe4, 0xae, 0x3c]); |
| 63 var jwks = keyIds.map(function(keyId) { return createJWK(key
Id, rawKey); }); | 64 var jwks = keyIds.map(function(item) { return createJWK(item
.keyId, rawKey); }); |
| 64 var jwkSet = stringToUint8Array(createJWKSet.apply(this, jwk
s)); | 65 var jwkSet = stringToUint8Array(createJWKSet.apply(this, jwk
s)); |
| 65 | 66 |
| 66 mediaKeySession.update(jwkSet).catch(function(error) { | 67 mediaKeySession.update(jwkSet).catch(function(error) { |
| 67 forceTestFailureFromPromise(test, error); | 68 forceTestFailureFromPromise(test, error); |
| 68 }); | 69 }); |
| 69 } | 70 } |
| 70 | 71 |
| 71 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp
leConfiguration()).then(function(access) { | 72 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp
leConfiguration()).then(function(access) { |
| 72 initDataType = access.getConfiguration().initDataTypes[0]; | 73 initDataType = access.getConfiguration().initDataTypes[0]; |
| 73 initData = getInitData(initDataType); | 74 initData = getInitData(initDataType); |
| 74 return access.createMediaKeys(); | 75 return access.createMediaKeys(); |
| 75 }).then(function(mediaKeys) { | 76 }).then(function(mediaKeys) { |
| 76 mediaKeySession = mediaKeys.createSession(); | 77 mediaKeySession = mediaKeys.createSession(); |
| 77 | 78 |
| 78 // There should be no keys defined yet. | 79 // There should be no keys defined yet. |
| 79 assert_equals(mediaKeySession.keyStatuses.size, 0); | 80 assert_equals(mediaKeySession.keyStatuses.size, 0); |
| 80 | 81 |
| 81 waitForEventAndRunStep('message', mediaKeySession, processMe
ssage, test); | 82 waitForEventAndRunStep('message', mediaKeySession, processMe
ssage, test); |
| 82 return mediaKeySession.generateRequest(initDataType, initDat
a); | 83 return mediaKeySession.generateRequest(initDataType, initDat
a); |
| 83 }).catch(function(error) { | 84 }).catch(function(error) { |
| 84 forceTestFailureFromPromise(test, error); | 85 forceTestFailureFromPromise(test, error); |
| 85 }); | 86 }); |
| 86 }, 'Verify MediaKeySession.keyStatuses handles multiple keys.'); | 87 }, 'Verify MediaKeySession.keyStatuses handles multiple keys.'); |
| 87 </script> | 88 </script> |
| 88 </body> | 89 </body> |
| 89 </html> | 90 </html> |
| OLD | NEW |