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

Side by Side Diff: LayoutTests/media/encrypted-media/encrypted-media-events.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: Changes 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 v2 events</title> 4 <title>Verify v2 events</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 // Currently Clear Key only generates aynchronous "message" and 12 // Currently Clear Key only generates aynchronous "message" and
13 // "keychange" events. 13 // "keychange" events.
14 async_test(function(test) 14 async_test(function(test)
15 { 15 {
16 var initDataType;
16 var mediaKeySession; 17 var mediaKeySession;
17 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, 18 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
18 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); 19 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
19 20
20 function processMessage(event) 21 function processMessage(event)
21 { 22 {
22 assert_true(event instanceof window.MediaKeyMessageEvent); 23 assert_true(event instanceof window.MediaKeyMessageEvent);
23 assert_equals(event.target, mediaKeySession); 24 assert_equals(event.target, mediaKeySession);
24 assert_equals(event.type, 'message'); 25 assert_equals(event.type, 'message');
25 assert_equals(event.messageType, 'license-request'); 26 assert_equals(event.messageType, 'license-request');
26 27
27 var keyId = extractSingleKeyIdFromMessage(event.message); 28 var keyId = extractSingleKeyIdFromMessage(event.message);
28 var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId , rawKey))); 29 var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId , rawKey)));
29 30
30 waitForEventAndRunStep('keystatuseschange', mediaKeySession, test.step_func(processKeyStatusesChange), test); 31 waitForEventAndRunStep('keystatuseschange', mediaKeySession, test.step_func(processKeyStatusesChange), test);
31 32
32 mediaKeySession.update(jwkSet).catch(test.step_func(function (error) { 33 mediaKeySession.update(jwkSet).catch(test.step_func(function (error) {
33 forceTestFailureFromPromise(test, error); 34 forceTestFailureFromPromise(test, error);
34 })); 35 }));
35 } 36 }
36 37
37 function processKeyStatusesChange(event) 38 function processKeyStatusesChange(event)
38 { 39 {
39 assert_true(event instanceof Event); 40 assert_true(event instanceof Event);
40 assert_equals(event.target, mediaKeySession); 41 assert_equals(event.target, mediaKeySession);
41 assert_equals(event.type, 'keystatuseschange'); 42 assert_equals(event.type, 'keystatuseschange');
42 test.done(); 43 test.done();
43 } 44 }
44 45
45 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) { 46 getSupportedInitDataType().then(function(type) {
47 initDataType = type;
48 return navigator.requestMediaKeySystemAccess('org.w3.clearke y', [{}]);
49 }).then(function(access) {
46 return access.createMediaKeys(); 50 return access.createMediaKeys();
47 }).then(test.step_func(function(mediaKeys) { 51 }).then(test.step_func(function(mediaKeys) {
48 var initDataType = getInitDataType();
49 mediaKeySession = mediaKeys.createSession(); 52 mediaKeySession = mediaKeys.createSession();
50 waitForEventAndRunStep('message', mediaKeySession, test.step _func(processMessage), test); 53 waitForEventAndRunStep('message', mediaKeySession, test.step _func(processMessage), test);
51 return mediaKeySession.generateRequest(initDataType, getInit Data(initDataType)); 54 return mediaKeySession.generateRequest(initDataType, getInit Data(initDataType));
sandersd (OOO until July 31) 2015/03/16 19:57:08 Why not the usual pattern of fetching this after g
jrummell 2015/03/16 20:44:09 Probably the first file I changed. Done.
52 })).catch(test.step_func(function(error) { 55 })).catch(test.step_func(function(error) {
53 forceTestFailureFromPromise(test, error); 56 forceTestFailureFromPromise(test, error);
54 })); 57 }));
55 }, 'Verify v2 events.'); 58 }, 'Verify v2 events.');
56 </script> 59 </script>
57 </body> 60 </body>
58 </html> 61 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698