Chromium Code Reviews| Index: LayoutTests/media/encrypted-media/encrypted-media-utils.js |
| diff --git a/LayoutTests/media/encrypted-media/encrypted-media-utils.js b/LayoutTests/media/encrypted-media/encrypted-media-utils.js |
| index 970f07affec42e42ec0ca709c7c607a64c1083c7..60547a471e8840c02f9c9a3e38a76961bf60a591 100644 |
| --- a/LayoutTests/media/encrypted-media/encrypted-media-utils.js |
| +++ b/LayoutTests/media/encrypted-media/encrypted-media-utils.js |
| @@ -12,47 +12,59 @@ function consoleWrite(text) |
| console.appendChild(span); |
| } |
| -// FIXME: Detect EME support rather than just general container support. |
| -// http://crbug.com/441585 |
| +// Returns a promise that is fulfilled with true if |initDataType| is supported, |
| +// or false if not. |
| // For now, assume that implementations that support a container type for clear |
|
ddorwin
2015/03/12 23:18:08
This comment is obsolete.
jrummell
2015/03/13 18:05:30
Done.
|
| // content and are running these tests also support that container with EME. |
| -// The element used for this will is not released to avoid interfering with the |
| -// ActiveDOMObject counts in the lifetime tests. |
| -var canPlayTypeElement = new Audio(); |
| -var isWebMSupported = ('' != canPlayTypeElement.canPlayType('video/webm')); |
| -var isCencSupported = ('' != canPlayTypeElement.canPlayType('video/mp4')); |
| - |
| function isInitDataTypeSupported(initDataType) |
| { |
| - var result = false; |
| - switch (initDataType) { |
| - case 'webm': |
| - result = isWebMSupported; |
| - break; |
| - case 'cenc': |
| - result = isCencSupported; |
| - break; |
| - default: |
| - result = false; |
| - } |
| - |
| - return result; |
| + return navigator.requestMediaKeySystemAccess( |
| + "org.w3.clearkey", [{ initDataTypes : [initDataType] }]) |
| + .then(function() { return(true); }, function() { return(false); }); |
| } |
| - |
| +// Returns a promise that is fulfilled with an initDataType that is supported, |
| +// rejected if neither 'webm' or 'cenc' are supported. |
| function getInitDataType() |
|
ddorwin
2015/03/12 23:18:08
getSupported...
jrummell
2015/03/13 18:05:30
Done.
|
| { |
| - if (isInitDataTypeSupported('webm')) |
| - return 'webm'; |
| - if (isInitDataTypeSupported('cenc')) |
| - return 'cenc'; |
| - throw 'No supported Initialization Data Types'; |
| + return isInitDataTypeSupported('webm').then(function(result) { |
| + if (result) { |
| + return 'webm'; |
|
ddorwin
2015/03/12 23:18:08
Does this end up being a promise resolved with 'we
jrummell
2015/03/13 18:05:30
Done.
|
| + } |
| + return isInitDataTypeSupported('cenc').then(function(result) { |
| + if (result) { |
| + return 'cenc'; |
| + } |
| + return Promise.reject('No supported initDataType.'); |
| + }); |
| + }); |
| } |
| function getInitData(initDataType) |
| { |
| - // FIXME: This should be dependent on initDataType. |
| - return new Uint8Array([ 0, 1, 2, 3, 4, 5, 6, 7 ]); |
| + if (initDataType == 'webm') { |
| + return new Uint8Array([ |
| + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F |
| + ]); |
| + } |
| + |
| + if (initDataType == 'cenc') { |
| + return new Uint8Array([ |
| + 0x00, 0x00, 0x00, 0x00, // size = 0 |
| + 0x70, 0x73, 0x73, 0x68, // 'pssh' |
| + 0x01, // version = 1 |
| + 0x00, 0x00, 0x00, // flags |
| + 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // Common SystemID |
| + 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, |
| + 0x00, 0x00, 0x00, 0x01, // key count |
| + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // key |
| + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
| + 0x00, 0x00, 0x00, 0x00 // datasize |
| + ]); |
| + } |
| + |
| + throw 'initDataType ' + initDataType + ' not supported.'; |
| } |
| function waitForEventAndRunStep(eventName, element, func, stepTest) |