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

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

Issue 1004843003: Use requestMediaKeySystemAccess() to check type support in EME layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move vars Created 5 years, 9 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 <div id="log"></div> 10 <div id="log"></div>
11 <script> 11 <script>
12 var mediaKeySession;
13 var firstEvent;
14
15 // Even though key ids are uint8, using printable values so that
16 // they can be verified easily.
17 var key1 = stringToUint8Array('123');
18 var key2 = stringToUint8Array('4567890');
19 var rawKey1 = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0x d2, 0x7b,
20 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0x ae, 0x3c]);
21 var rawKey2 = new Uint8Array([0x3c, 0xae, 0xe4, 0xfc, 0x2a, 0x12, 0x ef, 0x68,
22 0x7b, 0xd2, 0x14, 0x68, 0xf1, 0x62, 0x dd, 0xeb]);
23
24 async_test(function(test) 12 async_test(function(test)
25 { 13 {
14 var initDataType;
15 var initData;
16 var mediaKeySession;
17 var firstEvent;
18
19 // Even though key ids are uint8, using printable values so that
20 // they can be verified easily.
21 var key1 = stringToUint8Array('123');
22 var key2 = stringToUint8Array('4567890');
23 var rawKey1 = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14 , 0xd2, 0x7b,
24 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4 , 0xae, 0x3c]);
25 var rawKey2 = new Uint8Array([0x3c, 0xae, 0xe4, 0xfc, 0x2a, 0x12 , 0xef, 0x68,
26 0x7b, 0xd2, 0x14, 0x68, 0xf1, 0x62 , 0xdd, 0xeb]);
27
26 function processMessage(event) 28 function processMessage(event)
27 { 29 {
28 // No keys added yet. 30 // No keys added yet.
29 verifyKeyStatuses(mediaKeySession.keyStatuses, { expected: [ ], unexpected: [key1, key2] }); 31 verifyKeyStatuses(mediaKeySession.keyStatuses, { expected: [ ], unexpected: [key1, key2] });
30 32
31 // Add key1 to the session. 33 // Add key1 to the session.
32 firstEvent = true; 34 firstEvent = true;
33 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1))); 35 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1)));
34 mediaKeySession.update(jwkSet).catch(function(error) { 36 mediaKeySession.update(jwkSet).catch(function(error) {
35 forceTestFailureFromPromise(test, error); 37 forceTestFailureFromPromise(test, error);
(...skipping 15 matching lines...) Expand all
51 }); 53 });
52 } else { 54 } else {
53 // Verify that the session now contains key1 and key2. 55 // Verify that the session now contains key1 and key2.
54 dumpKeyStatuses(mediaKeySession.keyStatuses); 56 dumpKeyStatuses(mediaKeySession.keyStatuses);
55 verifyKeyStatuses(mediaKeySession.keyStatuses, { expecte d: [key1, key2] }); 57 verifyKeyStatuses(mediaKeySession.keyStatuses, { expecte d: [key1, key2] });
56 58
57 test.done(); 59 test.done();
58 } 60 }
59 } 61 }
60 62
61 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) { 63 getSupportedInitDataType().then(function(type) {
64 initDataType = type;
65 initData = getInitData(initDataType);
66 return navigator.requestMediaKeySystemAccess('org.w3.clearke y', [{}]);
67 }).then(function(access) {
62 return access.createMediaKeys(); 68 return access.createMediaKeys();
63 }).then(function(mediaKeys) { 69 }).then(function(mediaKeys) {
64 var initDataType = getInitDataType();
65 mediaKeySession = mediaKeys.createSession(); 70 mediaKeySession = mediaKeys.createSession();
66 71
67 // There should be no keys defined yet. 72 // There should be no keys defined yet.
68 assert_equals(mediaKeySession.keyStatuses.size, 0); 73 assert_equals(mediaKeySession.keyStatuses.size, 0);
69 74
70 waitForEventAndRunStep('message', mediaKeySession, processMe ssage, test); 75 waitForEventAndRunStep('message', mediaKeySession, processMe ssage, test);
71 waitForEventAndRunStep('keystatuseschange', mediaKeySession, processKeyStatusesChange, test); 76 waitForEventAndRunStep('keystatuseschange', mediaKeySession, processKeyStatusesChange, test);
72 77
73 return mediaKeySession.generateRequest(initDataType, getInit Data(initDataType)); 78 return mediaKeySession.generateRequest(initDataType, initDat a);
74 }).catch(function(error) { 79 }).catch(function(error) {
75 forceTestFailureFromPromise(test, error); 80 forceTestFailureFromPromise(test, error);
76 }); 81 });
77 }, 'Verify MediaKeySession.keyStatuses with multiple updates.'); 82 }, 'Verify MediaKeySession.keyStatuses with multiple updates.');
78 </script> 83 </script>
79 </body> 84 </body>
80 </html> 85 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698