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

Side by Side Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js

Issue 2084053002: EME: Update tests so 'audioCapabilities' always provided (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 var consoleDiv = null; 1 var consoleDiv = null;
2 2
3 function consoleWrite(text) 3 function consoleWrite(text)
4 { 4 {
5 if (!consoleDiv && document.body) { 5 if (!consoleDiv && document.body) {
6 consoleDiv = document.createElement('div'); 6 consoleDiv = document.createElement('div');
7 document.body.appendChild(consoleDiv); 7 document.body.appendChild(consoleDiv);
8 } 8 }
9 var span = document.createElement('span'); 9 var span = document.createElement('span');
10 span.appendChild(document.createTextNode(text)); 10 span.appendChild(document.createTextNode(text));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 var keyId = new Uint8Array([ 64 var keyId = new Uint8Array([
65 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 65 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
66 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F 66 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
67 ]); 67 ]);
68 return stringToUint8Array(createKeyIDs(keyId)); 68 return stringToUint8Array(createKeyIDs(keyId));
69 } 69 }
70 70
71 throw 'initDataType ' + initDataType + ' not supported.'; 71 throw 'initDataType ' + initDataType + ' not supported.';
72 } 72 }
73 73
74 // Returns a promise from navigator.requestMediaKeySystemAccess for Clear Key
75 // that is fulfilled if the initDataType is supported, rejected if it is not.
76 function requestClearKeySystemAccessForInitType(initDataType)
77 {
78 var configuration = [ {
79 initDataTypes: [ initDataType ],
80 videoCapabilities: [
81 { contentType: 'video/webm; codecs="vp8"' }
ddorwin 2016/06/21 22:42:47 If we're going to pick one type, let's pick audio.
jrummell 2016/06/23 22:04:21 The encrypted-media-playback tests play a webm fil
82 ]
83 } ];
84 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', configuratio n);
85 }
86
74 function waitForEventAndRunStep(eventName, element, func, stepTest) 87 function waitForEventAndRunStep(eventName, element, func, stepTest)
75 { 88 {
76 var eventCallback = function(event) { 89 var eventCallback = function(event) {
77 if (func) 90 if (func)
78 func(event); 91 func(event);
79 } 92 }
80 if (stepTest) 93 if (stepTest)
81 eventCallback = stepTest.step_func(eventCallback); 94 eventCallback = stepTest.step_func(eventCallback);
82 95
83 element.addEventListener(eventName, eventCallback, true); 96 element.addEventListener(eventName, eventCallback, true);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Create a MediaKeys object for Clear Key with 1 session. KeyId and key 274 // Create a MediaKeys object for Clear Key with 1 session. KeyId and key
262 // required for the video are already known and provided. Returns a promise 275 // required for the video are already known and provided. Returns a promise
263 // that resolves to the MediaKeys object created. 276 // that resolves to the MediaKeys object created.
264 function createMediaKeys(keyId, key) 277 function createMediaKeys(keyId, key)
265 { 278 {
266 var mediaKeys; 279 var mediaKeys;
267 var mediaKeySession; 280 var mediaKeySession;
268 var request = stringToUint8Array(createKeyIDs(keyId)); 281 var request = stringToUint8Array(createKeyIDs(keyId));
269 var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, key))); 282 var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, key)));
270 283
271 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(f unction(access) { 284 return requestClearKeySystemAccessForInitType('keyids').then(function(access ) {
272 return access.createMediaKeys(); 285 return access.createMediaKeys();
273 }).then(function(result) { 286 }).then(function(result) {
274 mediaKeys = result; 287 mediaKeys = result;
275 mediaKeySession = mediaKeys.createSession(); 288 mediaKeySession = mediaKeys.createSession();
276 return mediaKeySession.generateRequest('keyids', request); 289 return mediaKeySession.generateRequest('keyids', request);
277 }).then(function() { 290 }).then(function() {
278 return mediaKeySession.update(jwkSet); 291 return mediaKeySession.update(jwkSet);
279 }).then(function() { 292 }).then(function() {
280 return Promise.resolve(mediaKeys); 293 return Promise.resolve(mediaKeys);
281 }); 294 });
282 } 295 }
283 296
284 // Play the specified |content| on |video|. Returns a promise that is resolved 297 // Play the specified |content| on |video|. Returns a promise that is resolved
285 // after the video plays for |duration| seconds. 298 // after the video plays for |duration| seconds.
286 function playVideoAndWaitForTimeupdate(video, content, duration) 299 function playVideoAndWaitForTimeupdate(video, content, duration)
287 { 300 {
288 video.src = content; 301 video.src = content;
289 video.play(); 302 video.play();
290 return new Promise(function(resolve) { 303 return new Promise(function(resolve) {
291 video.addEventListener('timeupdate', function listener(event) { 304 video.addEventListener('timeupdate', function listener(event) {
292 if (event.target.currentTime < duration) 305 if (event.target.currentTime < duration)
293 return; 306 return;
294 video.removeEventListener('timeupdate', listener); 307 video.removeEventListener('timeupdate', listener);
295 resolve('success'); 308 resolve('success');
296 }); 309 });
297 }); 310 });
298 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698