Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d

This commit is contained in:
Ms2ger 2016-11-14 11:07:09 +01:00
parent 65dd6d4340
commit ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions

View file

@ -1,92 +1,73 @@
function runTest(config,qualifier) {
// Create a "temporary" session for |keysystem| and call generateRequest()
// with the provided initData. generateRequest() should fail with an
// TypeError. Returns a promise that is resolved
// if the error occurred and rejected otherwise.
function test_session(keysystem, initDataType, initData)
{
return isInitDataTypeSupported(initDataType).then(function(result) {
// If |initDataType| is not supported, simply succeed.
if (!result)
return Promise.resolve('Not supported');
return navigator.requestMediaKeySystemAccess(keysystem, getSimpleConfigurationForInitDataType(initDataType)).then(function(access) {
return access.createMediaKeys();
}).then(function(mediaKeys) {
var mediaKeySession = mediaKeys.createSession("temporary");
return mediaKeySession.generateRequest(initDataType, initData);
}).then(function() {
assert_unreached('generateRequest() succeeded unexpectedly');
}, function(error) {
assert_equals(error.name, 'TypeError');
return Promise.resolve('success');
});
})
var tests = [ ], initData, keyId;
function push_test(keysystem, initDataType, initData, testname) {
tests.push({ keysystem: keysystem, initDataType: initDataType, initData: initData, testname: testname });
}
promise_test(function()
{
var initData = new Uint8Array(70000);
return test_session(config.keysystem, 'webm', initData);
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, webm, initData longer than 64Kb characters');
initData = new Uint8Array(70000);
push_test(config.keysystem, 'webm', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, webm, initData longer than 64Kb characters');
promise_test(function()
{
var initData = new Uint8Array(70000);
return test_session(config.keysystem, 'cenc', initData);
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, initData longer than 64Kb characters');
initData = new Uint8Array(70000);
push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, initData longer than 64Kb characters');
promise_test(function()
{
var initData = new Uint8Array(70000);
return test_session(config.keysystem, 'keyids', initData);
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, initData longer than 64Kb characters');
initData = new Uint8Array(70000);
push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, initData longer than 64Kb characters');
promise_test(function()
{
// Invalid 'pssh' box as the size specified is larger than what
// is provided.
var initData = new Uint8Array([
0x00, 0x00, 0xff, 0xff, // size = huge
0x70, 0x73, 0x73, 0x68, // 'pssh'
0x00, // version = 0
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, 0x00 // datasize
]);
return test_session(config.keysystem, 'cenc', initData);
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, invalid initdata (invalid pssh)');
// Invalid 'pssh' box as the size specified is larger than what
// is provided.
initData = new Uint8Array([
0x00, 0x00, 0xff, 0xff, // size = huge
0x70, 0x73, 0x73, 0x68, // 'pssh'
0x00, // version = 0
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, 0x00 // datasize
]);
push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, invalid initdata (invalid pssh)');
promise_test(function()
{
// Invalid data as type = 'psss'.
var initData = new Uint8Array([
0x00, 0x00, 0x00, 0x00, // size = 0
0x70, 0x73, 0x73, 0x73, // 'psss'
0x00, // version = 0
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, 0x00 // datasize
]);
return test_session(config.keysystem, 'cenc', initData);
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, invalid initdata (not pssh)');
// Invalid data as type = 'psss'.
initData = new Uint8Array([
0x00, 0x00, 0x00, 0x00, // size = 0
0x70, 0x73, 0x73, 0x73, // 'psss'
0x00, // version = 0
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, 0x00 // datasize
]);
push_test(config.keysystem, 'cenc', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, invalid initdata (not pssh)');
promise_test(function()
{
// Valid key ID size must be at least 1 character for keyids.
var keyId = new Uint8Array(0);
var initData = stringToUint8Array(createKeyIDs(keyId));
return test_session(config.keysystem, 'keyids', initData);
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, invalid initdata (too short key ID)');
// Valid key ID size must be at least 1 character for keyids.
keyId = new Uint8Array(0);
initData = stringToUint8Array(createKeyIDs(keyId));
push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, invalid initdata (too short key ID)');
promise_test(function()
{
// Valid key ID size must be less than 512 characters for keyids.
var keyId = new Uint8Array(600);
var initData = stringToUint8Array(createKeyIDs(keyId));
return test_session(config.keysystem, 'keyids', initData);
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, invalid initdata (too long key ID)');
// Valid key ID size must be less than 512 characters for keyids.
keyId = new Uint8Array(600);
initData = stringToUint8Array(createKeyIDs(keyId));
push_test(config.keysystem, 'keyids', initData, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, invalid initdata (too long key ID)');
Promise.all( tests.map(function(testspec) {
return isInitDataTypeSupported(testspec.keysystem,testspec.initDataType);
})).then(function(results) {
tests.filter(function(testspec, i) { return results[i]; } ).forEach(function(testspec) {
promise_test(function(test) {
// Create a "temporary" session for |keysystem| and call generateRequest()
// with the provided initData. generateRequest() should fail with an
// TypeError. Returns a promise that is resolved
// if the error occurred and rejected otherwise.
return navigator.requestMediaKeySystemAccess(testspec.keysystem, getSimpleConfigurationForInitDataType(testspec.initDataType)).then(function(access) {
return access.createMediaKeys();
}).then(function(mediaKeys) {
var mediaKeySession = mediaKeys.createSession("temporary");
return mediaKeySession.generateRequest(testspec.initDataType, testspec.initData);
}).then(test.step_func(function() {
assert_unreached('generateRequest() succeeded unexpectedly');
}), test.step_func(function(error) {
assert_equals(error.name, 'TypeError');
}));
},testspec.testname);
});
});
}