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

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

Issue 2108033002: EME: Clear Key CDM now generates keystatuseschange event on close() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update unittest Created 4 years, 5 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
« no previous file with comments | « media/cdm/aes_decryptor_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Verify MediaKeySession.keyStatuses</title> 4 <title>Verify MediaKeySession.keyStatuses</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 <div id="log"></div> 10 <div id="log"></div>
11 <script> 11 <script>
12 async_test(function(test) 12 async_test(function(test)
13 { 13 {
14 var mediaKeySession; 14 var mediaKeySession;
15 var initDataType; 15 var initDataType;
16 var initData; 16 var initData;
17 var closed = false;
17 18
18 // Even though key ids are uint8, using printable values so that 19 // Even though key ids are uint8, using printable values so that
19 // they can be verified easily. 20 // they can be verified easily.
20 var key1String = '123'; 21 var key1String = '123';
21 var key2String = '4567890'; 22 var key2String = '4567890';
22 var key1 = stringToUint8Array(key1String); 23 var key1 = stringToUint8Array(key1String);
23 var key2 = stringToUint8Array(key2String); 24 var key2 = stringToUint8Array(key2String);
24 var rawKey1 = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14 , 0xd2, 0x7b, 25 var rawKey1 = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14 , 0xd2, 0x7b,
25 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4 , 0xae, 0x3c]); 26 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4 , 0xae, 0x3c]);
26 var rawKey2 = new Uint8Array([0x3c, 0xae, 0xe4, 0xfc, 0x2a, 0x12 , 0xef, 0x68, 27 var rawKey2 = new Uint8Array([0x3c, 0xae, 0xe4, 0xfc, 0x2a, 0x12 , 0xef, 0x68,
27 0x7b, 0xd2, 0x14, 0x68, 0xf1, 0x62 , 0xdd, 0xeb]); 28 0x7b, 0xd2, 0x14, 0x68, 0xf1, 0x62 , 0xdd, 0xeb]);
28 29
29 function processMessage(event) 30 function processMessage(event)
30 { 31 {
31 // No keys added yet. 32 // No keys added yet.
32 assert_equals(mediaKeySession.keyStatuses.size, 0); 33 assert_equals(mediaKeySession.keyStatuses.size, 0);
33 34
34 waitForEventAndRunStep('keystatuseschange', mediaKeySession, processKeyStatusesChange, test); 35 waitForEventAndRunStep('keystatuseschange', mediaKeySession, processKeyStatusesChange, test);
35 36
36 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1), createJWK(key2, rawKey2))); 37 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1), createJWK(key2, rawKey2)));
37 mediaKeySession.update(jwkSet).catch(function(error) { 38 mediaKeySession.update(jwkSet).catch(function(error) {
38 forceTestFailureFromPromise(test, error); 39 forceTestFailureFromPromise(test, error);
39 }); 40 });
40 } 41 }
41 42
42 function processKeyStatusesChange(event) 43 function checkKeyStatusFor2Keys()
43 { 44 {
44 // Two keys added, so both should show up in |keyStatuses|. 45 // Two keys added, so both should show up in |keyStatuses|.
45 assert_equals(mediaKeySession.keyStatuses.size, 2); 46 assert_equals(mediaKeySession.keyStatuses.size, 2);
46 dumpKeyStatuses(mediaKeySession.keyStatuses); 47 dumpKeyStatuses(mediaKeySession.keyStatuses);
47 48
48 // Check |keyStatuses| for 2 entries. 49 // Check |keyStatuses| for 2 entries.
49 var result = []; 50 var result = [];
50 for (let [keyId, status] of mediaKeySession.keyStatuses) { 51 for (let [keyId, status] of mediaKeySession.keyStatuses) {
51 result.push({ key: arrayBufferAsString(keyId), value: st atus }); 52 result.push({ key: arrayBufferAsString(keyId), value: st atus });
52 } 53 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 118
118 var invalid5 = new Uint8Array(key1.length + 1); 119 var invalid5 = new Uint8Array(key1.length + 1);
119 invalid5.set(key1, 1); // First element will be 0. 120 invalid5.set(key1, 1); // First element will be 0.
120 assert_false(mediaKeySession.keyStatuses.has(invalid5)); 121 assert_false(mediaKeySession.keyStatuses.has(invalid5));
121 assert_equals(mediaKeySession.keyStatuses.get(invalid5), und efined); 122 assert_equals(mediaKeySession.keyStatuses.get(invalid5), und efined);
122 123
123 var invalid6 = new Uint8Array(key1.length + 1); 124 var invalid6 = new Uint8Array(key1.length + 1);
124 invalid6.set(key1, 0); // Last element will be 0. 125 invalid6.set(key1, 0); // Last element will be 0.
125 assert_false(mediaKeySession.keyStatuses.has(invalid6)); 126 assert_false(mediaKeySession.keyStatuses.has(invalid6));
126 assert_equals(mediaKeySession.keyStatuses.get(invalid6), und efined); 127 assert_equals(mediaKeySession.keyStatuses.get(invalid6), und efined);
128 }
127 129
128 test.done(); 130 function processKeyStatusesChange(event)
131 {
132 if ( !closed )
133 {
134 // The first keystatuseschange (caused by update())
135 // should include both keys.
136 checkKeyStatusFor2Keys();
137
138 mediaKeySession.close().catch(function(error) {
139 forceTestFailureFromPromise(test, error);
140 });
141 closed = true;
142 }
143 else
144 {
145 // The second keystatuseschange (caused by close())
146 // should not have any keys.
147 assert_equals(mediaKeySession.keyStatuses.size, 0);
148 test.done();
149 }
129 } 150 }
130 151
131 getSupportedInitDataType().then(function(type) { 152 getSupportedInitDataType().then(function(type) {
132 initDataType = type; 153 initDataType = type;
133 initData = getInitData(initDataType); 154 initData = getInitData(initDataType);
134 return navigator.requestMediaKeySystemAccess('org.w3.clearke y', [{}]); 155 return navigator.requestMediaKeySystemAccess('org.w3.clearke y', [{}]);
135 }).then(function(access) { 156 }).then(function(access) {
136 return access.createMediaKeys(); 157 return access.createMediaKeys();
137 }).then(function(mediaKeys) { 158 }).then(function(mediaKeys) {
138 mediaKeySession = mediaKeys.createSession(); 159 mediaKeySession = mediaKeys.createSession();
139 160
140 // There should be no keys defined yet. 161 // There should be no keys defined yet.
141 assert_equals(mediaKeySession.keyStatuses.size, 0); 162 assert_equals(mediaKeySession.keyStatuses.size, 0);
142 163
143 waitForEventAndRunStep('message', mediaKeySession, processMe ssage, test); 164 waitForEventAndRunStep('message', mediaKeySession, processMe ssage, test);
144 return mediaKeySession.generateRequest(initDataType, initDat a); 165 return mediaKeySession.generateRequest(initDataType, initDat a);
145 }).catch(function(error) { 166 }).catch(function(error) {
146 forceTestFailureFromPromise(test, error); 167 forceTestFailureFromPromise(test, error);
147 }); 168 });
148 }, 'Verify MediaKeySession.keyStatuses.'); 169 }, 'Verify MediaKeySession.keyStatuses.');
149 </script> 170 </script>
150 </body> 171 </body>
151 </html> 172 </html>
OLDNEW
« no previous file with comments | « media/cdm/aes_decryptor_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698