From a0dad7941b04a17f818f89f72192ba7dabac6a64 Mon Sep 17 00:00:00 2001 From: Mark Watson Date: Tue, 20 Sep 2016 17:29:24 +0100 Subject: [PATCH 1/4] Fix #3756: Test that persistent licenses cannot be ingested into temporary sessions --- .../drm-temporary-license-type.html | 71 +++++++++++++++++++ .../scripts/temporary-license-type.js | 63 ++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 encrypted-media/drm-temporary-license-type.html create mode 100644 encrypted-media/scripts/temporary-license-type.js diff --git a/encrypted-media/drm-temporary-license-type.html b/encrypted-media/drm-temporary-license-type.html new file mode 100644 index 00000000000000..bff82ef4acbc40 --- /dev/null +++ b/encrypted-media/drm-temporary-license-type.html @@ -0,0 +1,71 @@ + + + + + Encrypted Media Extensions: Events with DRM + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + diff --git a/encrypted-media/scripts/temporary-license-type.js b/encrypted-media/scripts/temporary-license-type.js new file mode 100644 index 00000000000000..20aa5bbd8d702a --- /dev/null +++ b/encrypted-media/scripts/temporary-license-type.js @@ -0,0 +1,63 @@ +function runTest(config,qualifier) { + + var testname = testnamePrefix( qualifier, config.keysystem ) + ', cannot load persistent license into temporary session'; + + 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 onFailure( error ) { + forceTestFailureFromPromise(test, error); + } + + 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 ) { + mediaKeySession.update( response ).then( test.step_func( function() { + if ( event.messageType !== 'license-request' ) + return; + + assert_unreached( "Update with incorrect license type should fail" ) + } ) ).catch( test.step_func( function( error ) { + if ( event.messageType !== 'license-request' ) { + forceTestFailureFromPromise(test, error); + return; + } + + assert_equals(error.name, 'TypeError' ); + 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( 'temporary' ); + waitForEventAndRunStep('message', mediaKeySession, test.step_func(processMessage), test); + return mediaKeySession.generateRequest(initDataType, initData); + })).catch(onFailure); + }, testname ); + +} From 7b127d2b5cf76fd4619cc8382c711a29d0a2ab81 Mon Sep 17 00:00:00 2001 From: Mark Watson Date: Wed, 21 Sep 2016 10:09:17 +0100 Subject: [PATCH 2/4] lint --- encrypted-media/scripts/temporary-license-type.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encrypted-media/scripts/temporary-license-type.js b/encrypted-media/scripts/temporary-license-type.js index 20aa5bbd8d702a..f9c4dab951cc7c 100644 --- a/encrypted-media/scripts/temporary-license-type.js +++ b/encrypted-media/scripts/temporary-license-type.js @@ -29,7 +29,7 @@ function runTest(config,qualifier) { mediaKeySession.update( response ).then( test.step_func( function() { if ( event.messageType !== 'license-request' ) return; - + assert_unreached( "Update with incorrect license type should fail" ) } ) ).catch( test.step_func( function( error ) { if ( event.messageType !== 'license-request' ) { From 6aab9b2e551a0b090146e9d691be09601e6536ca Mon Sep 17 00:00:00 2001 From: "Michael[tm] Smith" Date: Thu, 22 Sep 2016 22:52:44 +0900 Subject: [PATCH 3/4] Fix lint failure for trailing WS --- encrypted-media/scripts/temporary-license-type.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encrypted-media/scripts/temporary-license-type.js b/encrypted-media/scripts/temporary-license-type.js index f9c4dab951cc7c..416d95d570922d 100644 --- a/encrypted-media/scripts/temporary-license-type.js +++ b/encrypted-media/scripts/temporary-license-type.js @@ -29,7 +29,7 @@ function runTest(config,qualifier) { mediaKeySession.update( response ).then( test.step_func( function() { if ( event.messageType !== 'license-request' ) return; - + assert_unreached( "Update with incorrect license type should fail" ) } ) ).catch( test.step_func( function( error ) { if ( event.messageType !== 'license-request' ) { From f8e98444d942ae58e06cc4dcf2ccf4370da90aec Mon Sep 17 00:00:00 2001 From: Mark Watson Date: Mon, 26 Sep 2016 11:44:57 -0700 Subject: [PATCH 4/4] Address review comments --- encrypted-media/drm-temporary-license-type.html | 4 ++-- encrypted-media/scripts/temporary-license-type.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/encrypted-media/drm-temporary-license-type.html b/encrypted-media/drm-temporary-license-type.html index bff82ef4acbc40..ef527f45ff5e57 100644 --- a/encrypted-media/drm-temporary-license-type.html +++ b/encrypted-media/drm-temporary-license-type.html @@ -2,7 +2,7 @@ - Encrypted Media Extensions: Events with DRM + Encrypted Media Extensions: Test that persistent license cannot be ingested into temporary session @@ -35,7 +35,7 @@ .then( function( supported ) { // This test requires initData for supported content. - // We prefer explciit initData configured for the content, but + // We prefer explicit initData configured for the content, but // otherwise we will generate initData for a supported initDataType // FIXME: Move me to a utility function var content, diff --git a/encrypted-media/scripts/temporary-license-type.js b/encrypted-media/scripts/temporary-license-type.js index f9c4dab951cc7c..cd1fb3eed0b6a4 100644 --- a/encrypted-media/scripts/temporary-license-type.js +++ b/encrypted-media/scripts/temporary-license-type.js @@ -27,8 +27,9 @@ function runTest(config,qualifier) { config.messagehandler( event.messageType, event.message ).then( function( response ) { mediaKeySession.update( response ).then( test.step_func( function() { - if ( event.messageType !== 'license-request' ) + if ( event.messageType !== 'license-request' ) { return; + } assert_unreached( "Update with incorrect license type should fail" ) } ) ).catch( test.step_func( function( error ) {