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

Side by Side Diff: LayoutTests/media/encrypted-media/encrypted-media-keystatuses-multiple-sessions.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 sessions</title> 4 <title>Verify MediaKeySession.keyStatuses with multiple sessions</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 mediaKeySession1;
13 var mediaKeySession2;
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 mediaKeySession1;
15 var mediaKeySession2;
16 var initDataType;
17 var initData;
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 processMessage1(event) 28 function processMessage1(event)
27 { 29 {
28 // This should only be called for session1. 30 // This should only be called for session1.
29 assert_equals(event.target, mediaKeySession1); 31 assert_equals(event.target, mediaKeySession1);
30 32
31 // No keys added yet. 33 // No keys added yet.
32 verifyKeyStatuses(mediaKeySession1.keyStatuses, { expected: [], unexpected: [key1, key2] }); 34 verifyKeyStatuses(mediaKeySession1.keyStatuses, { expected: [], unexpected: [key1, key2] });
33 35
34 // Add key1 to session1. 36 // Add key1 to session1.
35 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1))); 37 var jwkSet = stringToUint8Array(createJWKSet(createJWK(key1, rawKey1)));
36 mediaKeySession1.update(jwkSet).catch(function(error) { 38 mediaKeySession1.update(jwkSet).catch(function(error) {
37 forceTestFailureFromPromise(test, error); 39 forceTestFailureFromPromise(test, error);
38 }); 40 });
39 } 41 }
40 42
41 function processKeyStatusesChange1(event) 43 function processKeyStatusesChange1(event)
42 { 44 {
43 // This should only be called for session1. 45 // This should only be called for session1.
44 assert_equals(event.target, mediaKeySession1); 46 assert_equals(event.target, mediaKeySession1);
45 47
46 // Check that keyStatuses contains the expected key1 only. 48 // Check that keyStatuses contains the expected key1 only.
47 dumpKeyStatuses(mediaKeySession1.keyStatuses); 49 dumpKeyStatuses(mediaKeySession1.keyStatuses);
48 verifyKeyStatuses(mediaKeySession1.keyStatuses, { expected: [key1], unexpected: [key2] }); 50 verifyKeyStatuses(mediaKeySession1.keyStatuses, { expected: [key1], unexpected: [key2] });
49 51
50 // Now trigger a message event on session2. 52 // Now trigger a message event on session2.
51 var initDataType = getInitDataType(); 53 mediaKeySession2.generateRequest(initDataType, initData).cat ch(function(error) {
52 mediaKeySession2.generateRequest(initDataType, getInitData(i nitDataType)).catch(function(error) {
53 forceTestFailureFromPromise(test, error); 54 forceTestFailureFromPromise(test, error);
54 }); 55 });
55 } 56 }
56 57
57 function processMessage2(event) 58 function processMessage2(event)
58 { 59 {
59 // This should only be called for session2. 60 // This should only be called for session2.
60 assert_equals(event.target, mediaKeySession2); 61 assert_equals(event.target, mediaKeySession2);
61 62
62 // session2 has no keys added yet. 63 // session2 has no keys added yet.
(...skipping 17 matching lines...) Expand all
80 // Check that keyStatuses contains the expected key2 only. 81 // Check that keyStatuses contains the expected key2 only.
81 dumpKeyStatuses(mediaKeySession2.keyStatuses); 82 dumpKeyStatuses(mediaKeySession2.keyStatuses);
82 verifyKeyStatuses(mediaKeySession2.keyStatuses, { expected: [key2], unexpected: [key1] }); 83 verifyKeyStatuses(mediaKeySession2.keyStatuses, { expected: [key2], unexpected: [key1] });
83 84
84 // session1 should still have 1 key. 85 // session1 should still have 1 key.
85 verifyKeyStatuses(mediaKeySession1.keyStatuses, { expected: [key1], unexpected: [key2] }); 86 verifyKeyStatuses(mediaKeySession1.keyStatuses, { expected: [key1], unexpected: [key2] });
86 87
87 test.done(); 88 test.done();
88 } 89 }
89 90
90 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) { 91 getSupportedInitDataType().then(function(type) {
92 initDataType = type;
93 initData = getInitData(initDataType);
94 return navigator.requestMediaKeySystemAccess('org.w3.clearke y', [{}]);
95 }).then(function(access) {
91 return access.createMediaKeys(); 96 return access.createMediaKeys();
92 }).then(function(mediaKeys) { 97 }).then(function(mediaKeys) {
93 var initDataType = getInitDataType();
94 mediaKeySession1 = mediaKeys.createSession(); 98 mediaKeySession1 = mediaKeys.createSession();
95 mediaKeySession2 = mediaKeys.createSession(); 99 mediaKeySession2 = mediaKeys.createSession();
96 100
97 // There should be no keys defined on either session. 101 // There should be no keys defined on either session.
98 verifyKeyStatuses(mediaKeySession1.keyStatuses, { expected: [], unexpected: [key1, key2] }); 102 verifyKeyStatuses(mediaKeySession1.keyStatuses, { expected: [], unexpected: [key1, key2] });
99 verifyKeyStatuses(mediaKeySession2.keyStatuses, { expected: [], unexpected: [key1, key2] }); 103 verifyKeyStatuses(mediaKeySession2.keyStatuses, { expected: [], unexpected: [key1, key2] });
100 104
101 // Bind all the event handlers now. 105 // Bind all the event handlers now.
102 waitForEventAndRunStep('message', mediaKeySession1, processM essage1, test); 106 waitForEventAndRunStep('message', mediaKeySession1, processM essage1, test);
103 waitForEventAndRunStep('message', mediaKeySession2, processM essage2, test); 107 waitForEventAndRunStep('message', mediaKeySession2, processM essage2, test);
104 waitForEventAndRunStep('keystatuseschange', mediaKeySession1 , processKeyStatusesChange1, test); 108 waitForEventAndRunStep('keystatuseschange', mediaKeySession1 , processKeyStatusesChange1, test);
105 waitForEventAndRunStep('keystatuseschange', mediaKeySession2 , processKeyStatusesChange2, test); 109 waitForEventAndRunStep('keystatuseschange', mediaKeySession2 , processKeyStatusesChange2, test);
106 110
107 // Generate a request on session1. 111 // Generate a request on session1.
108 return mediaKeySession1.generateRequest(initDataType, getIni tData(initDataType)); 112 return mediaKeySession1.generateRequest(initDataType, initDa ta);
109 }).catch(function(error) { 113 }).catch(function(error) {
110 forceTestFailureFromPromise(test, error); 114 forceTestFailureFromPromise(test, error);
111 }); 115 });
112 }, 'Verify MediaKeySession.keyStatuses with multiple sessions.'); 116 }, 'Verify MediaKeySession.keyStatuses with multiple sessions.');
113 </script> 117 </script>
114 </body> 118 </body>
115 </html> 119 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698