Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-keystatuses-multiple-updates.html

Issue 2847803005: Cleanup verifyKeyStatuses() to take KeyId/status pairs (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Verify MediaKeySession.keyStatuses with multiple updates</title> 4 <title>Verify MediaKeySession.keyStatuses with multiple updates</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 initDataType; 13 var initDataType;
14 var initData; 14 var initData;
15 var mediaKeySession; 15 var mediaKeySession;
16 var firstEvent; 16 var firstEvent;
17 17
18 // Even though key ids are uint8, using printable values so that 18 // Even though key ids are uint8, using printable values so that
19 // they can be verified easily. 19 // they can be verified easily.
20 var key1 = stringToUint8Array('123'); 20 var key1 = stringToUint8Array('123');
21 var key2 = stringToUint8Array('4567890'); 21 var key2 = stringToUint8Array('4567890');
22 var rawKey1 = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14 , 0xd2, 0x7b, 22 var rawKey1 = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14 , 0xd2, 0x7b,
23 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4 , 0xae, 0x3c]); 23 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4 , 0xae, 0x3c]);
24 var rawKey2 = new Uint8Array([0x3c, 0xae, 0xe4, 0xfc, 0x2a, 0x12 , 0xef, 0x68, 24 var rawKey2 = new Uint8Array([0x3c, 0xae, 0xe4, 0xfc, 0x2a, 0x12 , 0xef, 0x68,
25 0x7b, 0xd2, 0x14, 0x68, 0xf1, 0x62 , 0xdd, 0xeb]); 25 0x7b, 0xd2, 0x14, 0x68, 0xf1, 0x62 , 0xdd, 0xeb]);
26 26
27 function processMessage(event) 27 function processMessage(event)
28 { 28 {
29 // No keys added yet. 29 // No keys added yet.
30 verifyKeyStatuses(mediaKeySession.keyStatuses, { expected: [ ], unexpected: [key1, key2] }); 30 verifyKeyStatuses(mediaKeySession.keyStatuses, []);
31 31
32 // Add key1 to the session. 32 // Add key1 to the session.
33 firstEvent = true; 33 firstEvent = true;
34 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1))); 34 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1)));
35 mediaKeySession.update(jwkSet).catch(function(error) { 35 mediaKeySession.update(jwkSet).catch(function(error) {
36 forceTestFailureFromPromise(test, error); 36 forceTestFailureFromPromise(test, error);
37 }); 37 });
38 } 38 }
39 39
40 function processKeyStatusesChange(event) 40 function processKeyStatusesChange(event)
41 { 41 {
42 if (firstEvent) { 42 if (firstEvent) {
43 // Verify that the session only contains key1. 43 // Verify that the session only contains key1.
44 dumpKeyStatuses(mediaKeySession.keyStatuses); 44 dumpKeyStatuses(mediaKeySession.keyStatuses);
45 verifyKeyStatuses(mediaKeySession.keyStatuses, { expecte d: [key1], unexpected: [key2] }); 45 verifyKeyStatuses(mediaKeySession.keyStatuses,
46 [ { keyId: key1, status: 'usable' } ]);
46 47
47 // Now add key2 to the session. 48 // Now add key2 to the session.
48 firstEvent = false; 49 firstEvent = false;
49 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k ey2, rawKey2))); 50 var jwkSet = stringToUint8Array(createJWKSet(createJWK(k ey2, rawKey2)));
50 mediaKeySession.update(jwkSet).catch(function(error) { 51 mediaKeySession.update(jwkSet).catch(function(error) {
51 forceTestFailureFromPromise(test, error); 52 forceTestFailureFromPromise(test, error);
52 }); 53 });
53 } else { 54 } else {
54 // Verify that the session now contains key1 and key2. 55 // Verify that the session now contains key1 and key2.
55 dumpKeyStatuses(mediaKeySession.keyStatuses); 56 dumpKeyStatuses(mediaKeySession.keyStatuses);
56 verifyKeyStatuses(mediaKeySession.keyStatuses, { expecte d: [key1, key2] }); 57 verifyKeyStatuses(mediaKeySession.keyStatuses,
58 [ { keyId: key1, status: 'usable' }, { keyId: key2, status: 'usable' } ]);
57 59
58 test.done(); 60 test.done();
59 } 61 }
60 } 62 }
61 63
62 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp leConfiguration()).then(function(access) { 64 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp leConfiguration()).then(function(access) {
63 initDataType = access.getConfiguration().initDataTypes[0]; 65 initDataType = access.getConfiguration().initDataTypes[0];
64 initData = getInitData(initDataType); 66 initData = getInitData(initDataType);
65 return access.createMediaKeys(); 67 return access.createMediaKeys();
66 }).then(function(mediaKeys) { 68 }).then(function(mediaKeys) {
67 mediaKeySession = mediaKeys.createSession(); 69 mediaKeySession = mediaKeys.createSession();
68 70
69 // There should be no keys defined yet. 71 // There should be no keys defined yet.
70 assert_equals(mediaKeySession.keyStatuses.size, 0); 72 assert_equals(mediaKeySession.keyStatuses.size, 0);
71 73
72 waitForEventAndRunStep('message', mediaKeySession, processMe ssage, test); 74 waitForEventAndRunStep('message', mediaKeySession, processMe ssage, test);
73 waitForEventAndRunStep('keystatuseschange', mediaKeySession, processKeyStatusesChange, test); 75 waitForEventAndRunStep('keystatuseschange', mediaKeySession, processKeyStatusesChange, test);
74 76
75 return mediaKeySession.generateRequest(initDataType, initDat a); 77 return mediaKeySession.generateRequest(initDataType, initDat a);
76 }).catch(function(error) { 78 }).catch(function(error) {
77 forceTestFailureFromPromise(test, error); 79 forceTestFailureFromPromise(test, error);
78 }); 80 });
79 }, 'Verify MediaKeySession.keyStatuses with multiple updates.'); 81 }, 'Verify MediaKeySession.keyStatuses with multiple updates.');
80 </script> 82 </script>
81 </body> 83 </body>
82 </html> 84 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698