OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <title>Test MediaKeySession remove() function</title> | |
xhwang
2017/04/25 16:43:48
About the file name and this title, should this be
jrummell
2017/04/25 17:54:10
Done.
| |
5 <script src="encrypted-media-utils.js"></script> | |
6 <script src="../../resources/testharness.js"></script> | |
7 <script src="../../resources/testharnessreport.js"></script> | |
8 </head> | |
9 <body> | |
10 <script> | |
11 promise_test(function(test) | |
12 { | |
13 var keyId = stringToUint8Array('0123456789012345'); | |
14 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | |
15 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); | |
16 | |
17 var mediaKeySession; | |
18 var waitForMessagePromise; | |
19 | |
20 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfigurationForInitDataType('keyids')).then(function(access) { | |
21 return access.createMediaKeys(); | |
22 }).then(function(mediaKeys) { | |
23 mediaKeySession = mediaKeys.createSession(); | |
24 waitForMessagePromise = waitForSingleEvent(mediaKeySession, 'message', function(e, resolve, reject) { | |
25 resolve(); | |
26 }); | |
27 const request = stringToUint8Array(createKeyIDs(keyId)); | |
28 return mediaKeySession.generateRequest('keyids', request); | |
29 }).then(function() { | |
30 return waitForMessagePromise; | |
31 }).then(function() { | |
32 const jwkSet = stringToUint8Array(createJWKSet(createJWK(key Id, rawKey))); | |
33 return mediaKeySession.update(jwkSet); | |
34 }).then(function() { | |
35 // After update() the session should have 1 usable key. | |
36 verifyKeyStatuses(mediaKeySession.keyStatuses, | |
37 { expected: [keyId], unexpected: [] }, 'usable'); | |
38 return mediaKeySession.remove(); | |
39 }).then(function() { | |
40 // After remove() all keys should be 'released'. | |
41 verifyKeyStatuses(mediaKeySession.keyStatuses, | |
42 { expected: [keyId], unexpected: [] }, 'released'); | |
43 // After remove() the session expiry should be NaN. | |
44 // ClearKey doesn't change set expiry times, but check | |
45 // anyway. | |
46 assert_true(isNaN(mediaKeySession.expiration)); | |
47 return mediaKeySession.close(); | |
48 }).then(function() { | |
49 // After close() there should be no keys. | |
50 verifyKeyStatuses(mediaKeySession.keyStatuses, | |
51 { expected: [], unexpected: [keyId] }); | |
52 }); | |
53 | |
54 }, 'Test MediaKeySession remove() function'); | |
55 </script> | |
56 </body> | |
57 </html> | |
OLD | NEW |