OLD | NEW |
(Empty) | |
| 1 function runTest(config,qualifier) { |
| 2 var tests = [ ], initData, keyId; |
| 3 function push_test(keysystem, initDataType, initData, testname) { |
| 4 tests.push({ keysystem: keysystem, initDataType: initDataType, initData:
initData, testname: testname }); |
| 5 } |
| 6 |
| 7 initData = new Uint8Array(70000); |
| 8 push_test(config.keysystem, 'webm', initData, testnamePrefix( qualifier, con
fig.keysystem ) + ', temporary, webm, initData longer than 64Kb characters'); |
| 9 |
| 10 initData = new Uint8Array(70000); |
| 11 push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, con
fig.keysystem ) + ', temporary, cenc, initData longer than 64Kb characters'); |
| 12 |
| 13 initData = new Uint8Array(70000); |
| 14 push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, c
onfig.keysystem ) + ', temporary, keyids, initData longer than 64Kb characters')
; |
| 15 |
| 16 // Invalid 'pssh' box as the size specified is larger than what |
| 17 // is provided. |
| 18 initData = new Uint8Array([ |
| 19 0x00, 0x00, 0xff, 0xff, // size = huge |
| 20 0x70, 0x73, 0x73, 0x68, // 'pssh' |
| 21 0x00, // version = 0 |
| 22 0x00, 0x00, 0x00, // flags |
| 23 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // Common SystemID |
| 24 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, |
| 25 0x00, 0x00, 0x00, 0x00 // datasize |
| 26 ]); |
| 27 push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, con
fig.keysystem ) + ', temporary, cenc, invalid initdata (invalid pssh)'); |
| 28 |
| 29 // Invalid data as type = 'psss'. |
| 30 initData = new Uint8Array([ |
| 31 0x00, 0x00, 0x00, 0x00, // size = 0 |
| 32 0x70, 0x73, 0x73, 0x73, // 'psss' |
| 33 0x00, // version = 0 |
| 34 0x00, 0x00, 0x00, // flags |
| 35 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // Common SystemID |
| 36 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B, |
| 37 0x00, 0x00, 0x00, 0x00 // datasize |
| 38 ]); |
| 39 push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, con
fig.keysystem ) + ', temporary, cenc, invalid initdata (not pssh)'); |
| 40 |
| 41 // Valid key ID size must be at least 1 character for keyids. |
| 42 keyId = new Uint8Array(0); |
| 43 initData = stringToUint8Array(createKeyIDs(keyId)); |
| 44 push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, c
onfig.keysystem ) + ', temporary, keyids, invalid initdata (too short key ID)'); |
| 45 |
| 46 // Valid key ID size must be less than 512 characters for keyids. |
| 47 keyId = new Uint8Array(600); |
| 48 initData = stringToUint8Array(createKeyIDs(keyId)); |
| 49 push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, c
onfig.keysystem ) + ', temporary, keyids, invalid initdata (too long key ID)'); |
| 50 |
| 51 Promise.all( tests.map(function(testspec) { |
| 52 return isInitDataTypeSupported(testspec.keysystem,testspec.initDataType)
; |
| 53 })).then(function(results) { |
| 54 tests.filter(function(testspec, i) { return results[i]; } ).forEach(func
tion(testspec) { |
| 55 promise_test(function(test) { |
| 56 // Create a "temporary" session for |keysystem| and call generat
eRequest() |
| 57 // with the provided initData. generateRequest() should fail wit
h an |
| 58 // TypeError. Returns a promise that is resolved |
| 59 // if the error occurred and rejected otherwise. |
| 60 return navigator.requestMediaKeySystemAccess(testspec.keysystem,
getSimpleConfigurationForInitDataType(testspec.initDataType)).then(function(acc
ess) { |
| 61 return access.createMediaKeys(); |
| 62 }).then(function(mediaKeys) { |
| 63 var mediaKeySession = mediaKeys.createSession("temporary"); |
| 64 return mediaKeySession.generateRequest(testspec.initDataType
, testspec.initData); |
| 65 }).then(test.step_func(function() { |
| 66 assert_unreached('generateRequest() succeeded unexpectedly')
; |
| 67 }), test.step_func(function(error) { |
| 68 assert_equals(error.name, 'TypeError'); |
| 69 })); |
| 70 },testspec.testname); |
| 71 }); |
| 72 }); |
| 73 } |
OLD | NEW |