mirror of
https://github.com/servo/servo.git
synced 2025-08-17 03:15:34 +01:00
Update web-platform-tests to revision 3b3585e368841b77caea8576fa56cef91c3fbdf0
This commit is contained in:
parent
d00639c55f
commit
3b4f0ec0bb
541 changed files with 14609 additions and 3288 deletions
|
@ -1,25 +1,25 @@
|
|||
function runTest(config,qualifier) {
|
||||
|
||||
// Create a session and call generateRequest() temporary, |initDataType|
|
||||
// and |initData|. generateRequest() should fail temporary, an
|
||||
// InvalidAccessError. Returns a promise that resolves successfully
|
||||
// if the error happened, rejects otherwise.
|
||||
function test_session(keysystem,initDataType, initData)
|
||||
// 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 navigator.requestMediaKeySystemAccess(keysystem, getSimpleConfigurationForInitDataType(initDataType)).then(function(access) {
|
||||
return access.createMediaKeys();
|
||||
}).then(function(mediaKeys) {
|
||||
var mediaKeySession = mediaKeys.createSession();
|
||||
var mediaKeySession = mediaKeys.createSession("temporary");
|
||||
return mediaKeySession.generateRequest(initDataType, initData);
|
||||
}).then(function() {
|
||||
assert_unreached('generateRequest() succeeded');
|
||||
assert_unreached('generateRequest() succeeded unexpectedly');
|
||||
}, function(error) {
|
||||
assert_equals(error.name, 'InvalidAccessError');
|
||||
assert_equals(error.name, 'TypeError');
|
||||
return Promise.resolve('success');
|
||||
});
|
||||
})
|
||||
|
@ -28,19 +28,19 @@ function runTest(config,qualifier) {
|
|||
promise_test(function()
|
||||
{
|
||||
var initData = new Uint8Array(70000);
|
||||
return test_session(config.keysystem,'webm', initData);
|
||||
return test_session(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);
|
||||
return test_session(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);
|
||||
return test_session(config.keysystem, 'keyids', initData);
|
||||
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, initData longer than 64Kb characters');
|
||||
|
||||
promise_test(function()
|
||||
|
@ -56,7 +56,7 @@ function runTest(config,qualifier) {
|
|||
0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B,
|
||||
0x00, 0x00, 0x00, 0x00 // datasize
|
||||
]);
|
||||
return test_session(config.keysystem,'cenc', initData);
|
||||
return test_session(config.keysystem, 'cenc', initData);
|
||||
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, invalid initdata (invalid pssh)');
|
||||
|
||||
promise_test(function()
|
||||
|
@ -71,7 +71,7 @@ function runTest(config,qualifier) {
|
|||
0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B,
|
||||
0x00, 0x00, 0x00, 0x00 // datasize
|
||||
]);
|
||||
return test_session(config.keysystem,'cenc', initData);
|
||||
return test_session(config.keysystem, 'cenc', initData);
|
||||
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, cenc, invalid initdata (not pssh)');
|
||||
|
||||
promise_test(function()
|
||||
|
@ -79,7 +79,7 @@ function runTest(config,qualifier) {
|
|||
// 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);
|
||||
return test_session(config.keysystem, 'keyids', initData);
|
||||
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, invalid initdata (too short key ID)');
|
||||
|
||||
promise_test(function()
|
||||
|
@ -87,6 +87,6 @@ function runTest(config,qualifier) {
|
|||
// 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);
|
||||
return test_session(config.keysystem, 'keyids', initData);
|
||||
}, testnamePrefix( qualifier, config.keysystem ) + ', temporary, keyids, invalid initdata (too long key ID)');
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ function runTest(config,qualifier) {
|
|||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 2 ) && !_timeupdateEvent ) {
|
||||
if ( _video.currentTime > ( config.duration || 1 ) && !_timeupdateEvent ) {
|
||||
_timeupdateEvent = true;
|
||||
_video.pause();
|
||||
_mediaKeySession.remove().then( recordEventFunc('remove-done') ).catch(onFailure);
|
||||
|
|
|
@ -19,6 +19,10 @@ function runTest(config,qualifier) {
|
|||
_mediaSource,
|
||||
_releaseSequence = false;
|
||||
|
||||
function onFailure(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
assert_equals( event.target, _mediaKeySession );
|
||||
// event instance verification failing on CastTV
|
||||
|
@ -35,15 +39,13 @@ function runTest(config,qualifier) {
|
|||
}
|
||||
|
||||
config.messagehandler( event.messageType, event.message ).then( function( response ) {
|
||||
_mediaKeySession.update( response ).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}).then(function() {
|
||||
_mediaKeySession.update( response ).then(function() {
|
||||
if(event.messageType === 'license-request') {
|
||||
_video.setMediaKeys(_mediaKeys);
|
||||
return _video.setMediaKeys(_mediaKeys);
|
||||
} else if(event.messageType === 'license-release') {
|
||||
test.done();
|
||||
}
|
||||
});
|
||||
}).catch(onFailure);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -55,9 +57,7 @@ function runTest(config,qualifier) {
|
|||
waitForEventAndRunStep('message', _mediaKeySession, onMessage, test);
|
||||
_mediaKeySession.generateRequest( config.initData ? config.initDataType : event.initDataType,
|
||||
config.initData || event.initData )
|
||||
.catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
.catch(onFailure);
|
||||
}
|
||||
|
||||
function onClosed(event) {
|
||||
|
@ -66,18 +66,13 @@ function runTest(config,qualifier) {
|
|||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 2 ) && !_releaseSequence ) {
|
||||
|
||||
if ( _video.currentTime > ( config.duration || 1 ) && !_releaseSequence ) {
|
||||
_video.removeEventListener('timeupdate', onTimeupdate );
|
||||
|
||||
_video.pause();
|
||||
|
||||
_releaseSequence = true;
|
||||
|
||||
_mediaKeySession.closed.then( test.step_func( onClosed ) );
|
||||
_mediaKeySession.remove().catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
_mediaKeySession.remove().catch(onFailure);
|
||||
|
||||
_video.removeEventListener('timeupdate', onTimeupdate );
|
||||
}
|
||||
|
@ -95,7 +90,6 @@ function runTest(config,qualifier) {
|
|||
}).then(function(mediaKeys) {
|
||||
_mediaKeys = mediaKeys;
|
||||
_mediaKeySession = _mediaKeys.createSession( 'persistent-usage-record' );
|
||||
|
||||
waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
|
||||
waitForEventAndRunStep('playing', _video, onPlaying, test);
|
||||
}).then(function() {
|
||||
|
@ -106,8 +100,6 @@ function runTest(config,qualifier) {
|
|||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.play();
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}, testname);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@ function runTest(config,qualifier) {
|
|||
_sessionId,
|
||||
_isClosing = false;
|
||||
|
||||
function onFailure(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onEncrypted(event) {
|
||||
assert_equals(event.target, _video);
|
||||
assert_true(event instanceof window.MediaEncryptedEvent);
|
||||
|
@ -28,11 +32,8 @@ function runTest(config,qualifier) {
|
|||
waitForEventAndRunStep('message', _mediaKeySession, onMessage, test);
|
||||
_mediaKeySession.generateRequest( config.initDataType || event.initDataType,
|
||||
config.initData || event.initData ).then( function() {
|
||||
|
||||
_sessionId = _mediaKeySession.sessionId;
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
|
@ -43,24 +44,20 @@ function runTest(config,qualifier) {
|
|||
assert_in_array( event.messageType, [ 'license-request', 'individualization-request' ] );
|
||||
|
||||
config.messagehandler( event.messageType, event.message ).then( function( response ) {
|
||||
|
||||
_mediaKeySession.update( response ).then(function() {
|
||||
_video.setMediaKeys(_mediaKeys);
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
});
|
||||
}
|
||||
|
||||
function onPlaying(event) {
|
||||
|
||||
// Not using waitForEventAndRunStep() to avoid too many
|
||||
// EVENT(onTimeUpdate) logs.
|
||||
_video.addEventListener('timeupdate', onTimeupdate, true);
|
||||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( !_isClosing && _video.currentTime > ( config.duration || 2 ) ) {
|
||||
if ( !_isClosing && _video.currentTime > ( config.duration || 1 ) ) {
|
||||
_isClosing = true;
|
||||
_video.removeEventListener('timeupdate', onTimeupdate );
|
||||
_video.pause();
|
||||
|
@ -75,15 +72,11 @@ function runTest(config,qualifier) {
|
|||
|
||||
var win = window.open( config.windowscript );
|
||||
window.addEventListener('message', test.step_func(function( event ) {
|
||||
|
||||
event.data.forEach(test.step_func(function( assertion ) {
|
||||
|
||||
assert_equals(assertion.actual, assertion.expected, assertion.message);
|
||||
|
||||
}));
|
||||
|
||||
win.close();
|
||||
|
||||
test.done();
|
||||
}));
|
||||
|
||||
|
@ -91,7 +84,6 @@ function runTest(config,qualifier) {
|
|||
delete config.messagehandler;
|
||||
|
||||
win.onload = function() {
|
||||
|
||||
win.postMessage( { config: config, sessionId: _sessionId }, '*' );
|
||||
}
|
||||
}
|
||||
|
@ -100,14 +92,11 @@ function runTest(config,qualifier) {
|
|||
return access.createMediaKeys();
|
||||
}).then(function(mediaKeys) {
|
||||
_mediaKeys = mediaKeys;
|
||||
|
||||
_video.setMediaKeys( mediaKeys );
|
||||
|
||||
return _video.setMediaKeys( mediaKeys );
|
||||
}).then(function(){
|
||||
_mediaKeySession = _mediaKeys.createSession( 'persistent-usage-record' );
|
||||
|
||||
waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
|
||||
waitForEventAndRunStep('playing', _video, onPlaying, test);
|
||||
}).then(function() {
|
||||
return config.servercertificate ? _mediaKeys.setServerCertificate( config.servercertificate ) : true;
|
||||
}).then(function( success ) {
|
||||
return testmediasource(config);
|
||||
|
@ -115,8 +104,6 @@ function runTest(config,qualifier) {
|
|||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.play();
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}, testname);
|
||||
}
|
||||
|
|
|
@ -11,24 +11,23 @@ function runTest(config,qualifier) {
|
|||
sessionTypes: [ 'temporary' ] };
|
||||
|
||||
async_test( function( test ) {
|
||||
|
||||
var _video = config.video,
|
||||
_mediaKeys,
|
||||
_mediaKeySession,
|
||||
_mediaSource,
|
||||
_allKeysUsableEvent = false,
|
||||
_playingEvent = false,
|
||||
_timeupdateEvent = false,
|
||||
_events = [ ];
|
||||
|
||||
function onFailure(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
assert_equals( event.target, _mediaKeySession );
|
||||
assert_true( event instanceof window.MediaKeyMessageEvent );
|
||||
assert_equals( event.type, 'message');
|
||||
|
||||
assert_any( assert_equals,
|
||||
event.messageType,
|
||||
[ 'license-request', 'individualization-request' ] );
|
||||
assert_in_array( event.messageType, [ 'license-request', 'individualization-request' ] );
|
||||
|
||||
if ( event.messageType !== 'individualization-request' ) {
|
||||
_events.push( event.messageType );
|
||||
|
@ -36,13 +35,10 @@ function runTest(config,qualifier) {
|
|||
|
||||
config.messagehandler( event.messageType, event.message ).then( function( response ) {
|
||||
_events.push( 'license-response' );
|
||||
|
||||
waitForEventAndRunStep('keystatuseschange', _mediaKeySession, onKeyStatusesChange, test);
|
||||
_mediaKeySession.update( response ).then( function() {
|
||||
_events.push('updated');
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,24 +46,21 @@ function runTest(config,qualifier) {
|
|||
assert_equals(event.target, _mediaKeySession );
|
||||
assert_true(event instanceof window.Event );
|
||||
assert_equals(event.type, 'keystatuseschange' );
|
||||
|
||||
var hasKeys = false, pendingKeys = false;
|
||||
_mediaKeySession.keyStatuses.forEach( function( value, keyid ) {
|
||||
assert_any( assert_equals, value, [ 'status-pending', 'usable' ] );
|
||||
|
||||
hasKeys = true;
|
||||
pendingKeys = pendingKeys || ( value === 'status-pending' );
|
||||
|
||||
});
|
||||
|
||||
if ( !_allKeysUsableEvent && hasKeys && !pendingKeys ) {
|
||||
_allKeysUsableEvent = true;
|
||||
_events.push( 'allkeysusable' );
|
||||
_video.setMediaKeys(_mediaKeys);
|
||||
}
|
||||
|
||||
if ( !hasKeys ) {
|
||||
_events.push( 'emptykeyslist' );
|
||||
} else if (!pendingKeys ) {
|
||||
_events.push( 'allkeysusable' );
|
||||
_video.setMediaKeys(_mediaKeys).catch(onFailure);
|
||||
} else {
|
||||
assert_unreached('unexpected ' + event.type + ' event');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,17 +73,12 @@ function runTest(config,qualifier) {
|
|||
_mediaKeySession.generateRequest( config.initData ? config.initDataType : event.initDataType,
|
||||
config.initData || event.initData ).then( function() {
|
||||
_events.push( 'generaterequest' );
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}
|
||||
|
||||
function onClosed(event) {
|
||||
|
||||
_events.push( 'closed-promise' );
|
||||
|
||||
setTimeout( test.step_func( function() {
|
||||
|
||||
assert_array_equals( _events,
|
||||
[
|
||||
'generaterequest',
|
||||
|
@ -104,30 +92,23 @@ function runTest(config,qualifier) {
|
|||
'emptykeyslist'
|
||||
],
|
||||
"Expected events sequence" );
|
||||
|
||||
_video.src = "";
|
||||
_video.setMediaKeys( null ).then(function(){
|
||||
test.done();
|
||||
});
|
||||
test.done();
|
||||
} ), 0 );
|
||||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 2 ) && !_timeupdateEvent ) {
|
||||
if ( _video.currentTime > ( config.duration || 1 ) && !_timeupdateEvent ) {
|
||||
_timeupdateEvent = true;
|
||||
_video.pause();
|
||||
|
||||
_mediaKeySession.closed.then( test.step_func( onClosed ) );
|
||||
_mediaKeySession.close().then( function() {
|
||||
_events.push( 'closed' );
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}
|
||||
}
|
||||
|
||||
function onPlaying(event) {
|
||||
_playingEvent = true;
|
||||
_events.push( 'playing' );
|
||||
|
||||
// Not using waitForEventAndRunStep() to avoid too many
|
||||
|
@ -149,8 +130,6 @@ function runTest(config,qualifier) {
|
|||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.play();
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}, testname);
|
||||
}
|
||||
|
|
|
@ -15,44 +15,47 @@ function runTest(config,qualifier) {
|
|||
|
||||
var _video = config.video,
|
||||
_mediaKeys,
|
||||
_mediaKeySessions = [ ],
|
||||
_mediaSource;
|
||||
_mediaKeySessions = [ ];
|
||||
|
||||
function onFailure( error ) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
consoleWrite( "message " + event.messageType );
|
||||
assert_any( assert_equals, event.target, _mediaKeySessions );
|
||||
assert_true( event instanceof window.MediaKeyMessageEvent );
|
||||
assert_equals( event.type, 'message');
|
||||
assert_in_array( event.messageType, [ 'license-request', 'individualization-request' ] );
|
||||
|
||||
assert_any( assert_equals,
|
||||
event.messageType,
|
||||
[ 'license-request', 'individualization-request' ] );
|
||||
|
||||
config.messagehandler( event.messageType, event.message )
|
||||
.then( function( response ) {
|
||||
|
||||
event.target.update( response )
|
||||
.catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
config.messagehandler( event.messageType, event.message ).then( function( response ) {
|
||||
event.target.update( response ).catch(onFailure);
|
||||
});
|
||||
}
|
||||
|
||||
function onWaitingForKey(event) {
|
||||
consoleWrite( "waitingforkey");
|
||||
}
|
||||
|
||||
function onPlaying(event) {
|
||||
consoleWrite( "playing");
|
||||
waitForEventAndRunStep('pause', _video, onStopped, test);
|
||||
waitForEventAndRunStep('waiting', _video, onStopped, test);
|
||||
waitForEventAndRunStep('stalled', _video, onStopped, test);
|
||||
}
|
||||
|
||||
// Not using waitForEventAndRunStep() to avoid too many
|
||||
// EVENT(onTimeUpdate) logs.
|
||||
_video.addEventListener('timeupdate', onTimeupdate, true);
|
||||
|
||||
function onStopped(event) {
|
||||
consoleWrite( event.type );
|
||||
if ( _mediaKeySessions.length < config.initData.length ) {
|
||||
var mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
|
||||
mediaKeySession.generateRequest( config.initDataType, config.initData[ _mediaKeySessions.length ] ).catch(onFailure);
|
||||
_mediaKeySessions.push( mediaKeySession );
|
||||
}
|
||||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 2 ) ) {
|
||||
|
||||
consoleWrite("Session 0:");
|
||||
dumpKeyStatuses( _mediaKeySessions[ 0 ].keyStatuses );
|
||||
consoleWrite("Session 1:");
|
||||
dumpKeyStatuses( _mediaKeySessions[ 1 ].keyStatuses );
|
||||
|
||||
if ( _video.currentTime > ( config.duration || 1 ) ) {
|
||||
_video.removeEventListener('timeupdate', onTimeupdate);
|
||||
_video.pause();
|
||||
test.done();
|
||||
|
@ -63,34 +66,24 @@ function runTest(config,qualifier) {
|
|||
return access.createMediaKeys();
|
||||
}).then(function(mediaKeys) {
|
||||
_mediaKeys = mediaKeys;
|
||||
|
||||
_video.setMediaKeys(_mediaKeys);
|
||||
|
||||
return _video.setMediaKeys(_mediaKeys);
|
||||
}).then(function(){
|
||||
waitForEventAndRunStep('waitingforkey', _video, onWaitingForKey, test);
|
||||
waitForEventAndRunStep('playing', _video, onPlaying, test);
|
||||
|
||||
config.initData.forEach( function( initData ) {
|
||||
|
||||
var mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
|
||||
waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
|
||||
|
||||
_mediaKeySessions.push( mediaKeySession );
|
||||
|
||||
mediaKeySession.generateRequest( config.initDataType, initData )
|
||||
.catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
|
||||
} );
|
||||
// Not using waitForEventAndRunStep() to avoid too many
|
||||
// EVENT(onTimeUpdate) logs.
|
||||
_video.addEventListener('timeupdate', onTimeupdate, true);
|
||||
|
||||
var mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
|
||||
_mediaKeySessions.push( mediaKeySession );
|
||||
return mediaKeySession.generateRequest( config.initDataType, config.initData[ 0 ] );
|
||||
}).then(function() {
|
||||
return testmediasource(config);
|
||||
}).then(function(source) {
|
||||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.src = URL.createObjectURL(source);
|
||||
_video.play();
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}, testname);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
function runTest(config,qualifier) {
|
||||
|
||||
// This test assumes one session is required for each provided initData
|
||||
|
||||
var testname = testnamePrefix( qualifier, config.keysystem )
|
||||
+ ', temporary, '
|
||||
+ /video\/([^;]*)/.exec( config.videoType )[ 1 ]
|
||||
+ ', playback with multiple keys, single session, '
|
||||
+ ', playback with multiple sessions, '
|
||||
+ config.testcase;
|
||||
|
||||
var configuration = { initDataTypes: [ config.initDataType ],
|
||||
|
@ -18,36 +20,8 @@ function runTest(config,qualifier) {
|
|||
_mediaKeySessions = [ ],
|
||||
_mediaSource;
|
||||
|
||||
function onEncrypted(event) {
|
||||
assert_equals(event.target, _video);
|
||||
assert_true(event instanceof window.MediaEncryptedEvent);
|
||||
assert_equals(event.type, 'encrypted');
|
||||
|
||||
// Only create a session for the first encrypted event
|
||||
if ( _mediaKeySessions.length > 0 ) return;
|
||||
|
||||
var mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
|
||||
waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
|
||||
|
||||
var initDataType, initData;
|
||||
if ( config.initDataType && config.initData )
|
||||
{
|
||||
initDataType = config.initDataType;
|
||||
initData = config.initData;
|
||||
}
|
||||
else
|
||||
{
|
||||
initDataType = event.initDataType;
|
||||
initData = event.initData;
|
||||
}
|
||||
|
||||
_mediaKeySessions.push( mediaKeySession );
|
||||
|
||||
mediaKeySession.generateRequest( initDataType, initData )
|
||||
.catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
function onFailure( error ) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
|
@ -55,33 +29,21 @@ function runTest(config,qualifier) {
|
|||
assert_true( event instanceof window.MediaKeyMessageEvent );
|
||||
assert_equals( event.type, 'message');
|
||||
|
||||
assert_any( assert_equals,
|
||||
event.messageType,
|
||||
[ 'license-request', 'individualization-request' ] );
|
||||
assert_in_array( event.messageType, [ 'license-request', 'individualization-request' ] );
|
||||
|
||||
config.messagehandler( event.messageType, event.message )
|
||||
.then( function( response ) {
|
||||
|
||||
event.target.update( response )
|
||||
.catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
config.messagehandler( event.messageType, event.message ).then( function( response ) {
|
||||
event.target.update( response ).catch(onFailure);
|
||||
});
|
||||
}
|
||||
|
||||
function onPlaying(event) {
|
||||
|
||||
// Not using waitForEventAndRunStep() to avoid too many
|
||||
// EVENT(onTimeUpdate) logs.
|
||||
_video.addEventListener('timeupdate', onTimeupdate, true);
|
||||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 2 ) ) {
|
||||
|
||||
consoleWrite("Session 0:");
|
||||
dumpKeyStatuses( _mediaKeySessions[ 0 ].keyStatuses );
|
||||
|
||||
if ( _video.currentTime > ( config.duration || 1 ) ) {
|
||||
_video.removeEventListener('timeupdate', onTimeupdate);
|
||||
_video.pause();
|
||||
test.done();
|
||||
|
@ -92,20 +54,21 @@ function runTest(config,qualifier) {
|
|||
return access.createMediaKeys();
|
||||
}).then(function(mediaKeys) {
|
||||
_mediaKeys = mediaKeys;
|
||||
|
||||
_video.setMediaKeys(_mediaKeys);
|
||||
|
||||
waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
|
||||
return _video.setMediaKeys(_mediaKeys);
|
||||
}).then(function() {
|
||||
waitForEventAndRunStep('playing', _video, onPlaying, test);
|
||||
|
||||
}).then(function() {
|
||||
config.initData.forEach( function( initData ) {
|
||||
var mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
waitForEventAndRunStep('message', mediaKeySession, onMessage, test);
|
||||
_mediaKeySessions.push( mediaKeySession );
|
||||
mediaKeySession.generateRequest( config.initDataType, initData ).catch( onFailure );
|
||||
} );
|
||||
return testmediasource(config);
|
||||
}).then(function(source) {
|
||||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.play();
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}, testname);
|
||||
}
|
|
@ -67,7 +67,7 @@ function runTest(config,qualifier) {
|
|||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 2 ) ) {
|
||||
if ( _video.currentTime > ( config.duration || 1 ) ) {
|
||||
_video.pause();
|
||||
test.done();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ function runTest(config,qualifier) {
|
|||
promise_test(function(test)
|
||||
{
|
||||
var promises = config.video.map( function( video ) { return play_video_as_promise( test, video ); } );
|
||||
|
||||
return Promise.all(promises);
|
||||
|
||||
}, testname );
|
||||
|
@ -23,6 +22,10 @@ function runTest(config,qualifier) {
|
|||
_mediaKeySession,
|
||||
_mediaSource;
|
||||
|
||||
function onFailure(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
assert_equals( event.target, _mediaKeySession );
|
||||
assert_true( event instanceof window.MediaKeyMessageEvent );
|
||||
|
@ -33,10 +36,7 @@ function runTest(config,qualifier) {
|
|||
[ 'license-request', 'individualization-request' ] );
|
||||
|
||||
config.messagehandler( event.messageType, event.message ).then( function( response ) {
|
||||
|
||||
_mediaKeySession.update( response ).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
_mediaKeySession.update( response ).catch(onFailure);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -49,18 +49,14 @@ function runTest(config,qualifier) {
|
|||
|
||||
_mediaKeySession.generateRequest( config.initData ? config.initDataType : event.initDataType,
|
||||
config.initData || event.initData )
|
||||
.catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
|
||||
_video.setMediaKeys(_mediaKeys);
|
||||
.catch(onFailure);
|
||||
}
|
||||
|
||||
function wait_for_timeupdate_message(video)
|
||||
{
|
||||
return new Promise(function(resolve) {
|
||||
video.addEventListener('timeupdate', function listener(event) {
|
||||
if ( event.target.currentTime > ( config.duration || 2 ) )
|
||||
if ( event.target.currentTime > ( config.duration || 1 ) )
|
||||
{
|
||||
video.removeEventListener('timeupdate', listener);
|
||||
resolve(event);
|
||||
|
@ -73,19 +69,16 @@ function runTest(config,qualifier) {
|
|||
return access.createMediaKeys();
|
||||
}).then(function(mediaKeys) {
|
||||
_mediaKeys = mediaKeys;
|
||||
_mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
|
||||
waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
|
||||
|
||||
return _video.setMediaKeys(_mediaKeys);
|
||||
}).then(function() {
|
||||
_mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
|
||||
return testmediasource(config);
|
||||
}).then(function(source) {
|
||||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.play();
|
||||
return wait_for_timeupdate_message(_video);
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ function runTest(config,qualifier) {
|
|||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 2 ) ) {
|
||||
if ( _video.currentTime > ( config.duration || 1 ) ) {
|
||||
assert_equals( _mediaKeySessions.length, config.initData.length );
|
||||
_video.removeEventListener('timeupdate', onTimeupdate);
|
||||
_video.pause();
|
||||
|
@ -60,7 +60,6 @@ function runTest(config,qualifier) {
|
|||
// Not using waitForEventAndRunStep() to avoid too many
|
||||
// EVENT(onTimeUpdate) logs.
|
||||
_video.addEventListener('timeupdate', onTimeupdate, true);
|
||||
}).then(function() {
|
||||
return testmediasource(config);
|
||||
}).then(function(source) {
|
||||
_mediaSource = source;
|
||||
|
|
|
@ -3,7 +3,7 @@ function runTest(config,qualifier) {
|
|||
var testname = testnamePrefix( qualifier, config.keysystem )
|
||||
+ ', temporary, '
|
||||
+ /video\/([^;]*)/.exec( config.videoType )[ 1 ]
|
||||
+ ', playback';
|
||||
+ ', playback, ' + config.testcase;
|
||||
|
||||
var configuration = { initDataTypes: [ config.initDataType ],
|
||||
audioCapabilities: [ { contentType: config.audioType } ],
|
||||
|
@ -17,6 +17,26 @@ function runTest(config,qualifier) {
|
|||
_mediaKeySession,
|
||||
_mediaSource;
|
||||
|
||||
function onFailure(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onEncrypted(event) {
|
||||
assert_equals(event.target, _video);
|
||||
assert_true(event instanceof window.MediaEncryptedEvent);
|
||||
assert_equals(event.type, 'encrypted');
|
||||
|
||||
// Only create the session for the firs encrypted event
|
||||
if ( _mediaKeySession !== undefined ) return;
|
||||
|
||||
var initDataType = config.initData ? config.initDataType : event.initDataType;
|
||||
var initData = config.initData || event.initData;
|
||||
|
||||
_mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
waitForEventAndRunStep('message', _mediaKeySession, onMessage, test);
|
||||
_mediaKeySession.generateRequest( initDataType, initData ).catch(onFailure);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
assert_equals( event.target, _mediaKeySession );
|
||||
assert_true( event instanceof window.MediaKeyMessageEvent );
|
||||
|
@ -27,57 +47,36 @@ function runTest(config,qualifier) {
|
|||
[ 'license-request', 'individualization-request' ] );
|
||||
|
||||
config.messagehandler( event.messageType, event.message ).then( function( response ) {
|
||||
|
||||
_mediaKeySession.update( response ).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
event.target.update( response ).catch(onFailure);
|
||||
});
|
||||
}
|
||||
|
||||
function onEncrypted(event) {
|
||||
assert_equals(event.target, _video);
|
||||
assert_true(event instanceof window.MediaEncryptedEvent);
|
||||
assert_equals(event.type, 'encrypted');
|
||||
|
||||
waitForEventAndRunStep('message', _mediaKeySession, onMessage, test);
|
||||
_mediaKeySession.generateRequest( config.initData ? config.initDataType : event.initDataType,
|
||||
config.initData || event.initData )
|
||||
.catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
|
||||
_video.setMediaKeys(_mediaKeys);
|
||||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 2 ) ) {
|
||||
_video.pause();
|
||||
test.done();
|
||||
}
|
||||
}
|
||||
|
||||
function onPlaying(event) {
|
||||
// Not using waitForEventAndRunStep() to avoid too many
|
||||
// EVENT(onTimeUpdate) logs.
|
||||
_video.addEventListener('timeupdate', onTimeupdate, true);
|
||||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
if ( _video.currentTime > ( config.duration || 1 ) ) {
|
||||
_video.pause();
|
||||
test.done();
|
||||
}
|
||||
}
|
||||
|
||||
navigator.requestMediaKeySystemAccess(config.keysystem, [ configuration ]).then(function(access) {
|
||||
return access.createMediaKeys();
|
||||
}).then(function(mediaKeys) {
|
||||
_mediaKeys = mediaKeys;
|
||||
_mediaKeySession = _mediaKeys.createSession( 'temporary' );
|
||||
|
||||
return _video.setMediaKeys(_mediaKeys);
|
||||
}).then(function(){
|
||||
waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
|
||||
waitForEventAndRunStep('playing', _video, onPlaying, test);
|
||||
}).then(function() {
|
||||
return testmediasource(config);
|
||||
}).then(function(source) {
|
||||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.play();
|
||||
}).catch(function(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
});
|
||||
}).catch(onFailure);
|
||||
}, testname);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue