mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Update web-platform-tests to revision dc5cbf088edcdb266541d4e5a76149a2c6e716a0
This commit is contained in:
parent
1d40075f03
commit
079092dfea
2381 changed files with 90360 additions and 17722 deletions
|
@ -0,0 +1,59 @@
|
|||
function runTest(config,qualifier) {
|
||||
|
||||
var testname = testnamePrefix( qualifier, config.keysystem ) + ', basic events';
|
||||
|
||||
var configuration = getSimpleConfigurationForContent( config.content );
|
||||
|
||||
if ( config.initDataType && config.initData ) configuration.initDataTypes = [ config.initDataType ]
|
||||
|
||||
async_test(function(test)
|
||||
{
|
||||
var initDataType;
|
||||
var initData;
|
||||
var mediaKeySession;
|
||||
|
||||
function processMessage(event)
|
||||
{
|
||||
assert_true(event instanceof window.MediaKeyMessageEvent);
|
||||
assert_equals(event.target, mediaKeySession);
|
||||
assert_equals(event.type, 'message');
|
||||
assert_any( assert_equals,
|
||||
event.messageType,
|
||||
[ 'license-request', 'individualization-request' ] );
|
||||
|
||||
config.messagehandler( event.messageType, event.message ).then( function( response ) {
|
||||
waitForEventAndRunStep('keystatuseschange', mediaKeySession, test.step_func(processKeyStatusesChange), test);
|
||||
mediaKeySession.update( response ).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function processKeyStatusesChange(event)
|
||||
{
|
||||
assert_true(event instanceof Event);
|
||||
assert_equals(event.target, mediaKeySession);
|
||||
assert_equals(event.type, 'keystatuseschange');
|
||||
test.done();
|
||||
}
|
||||
|
||||
navigator.requestMediaKeySystemAccess( config.keysystem, [ configuration ] ).then(function(access) {
|
||||
initDataType = access.getConfiguration().initDataTypes[0];
|
||||
|
||||
if ( config.initDataType && config.initData ) {
|
||||
initData = config.initData;
|
||||
} else {
|
||||
initData = getInitData(config.content, initDataType);
|
||||
}
|
||||
|
||||
return access.createMediaKeys();
|
||||
}).then(test.step_func(function(mediaKeys) {
|
||||
mediaKeySession = mediaKeys.createSession();
|
||||
waitForEventAndRunStep('message', mediaKeySession, test.step_func(processMessage), test);
|
||||
return mediaKeySession.generateRequest(initDataType, initData);
|
||||
})).catch(test.step_func(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}));
|
||||
}, testname );
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue