| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Test MediaKeySession not callable after close().</title> |
| 5 <script src="encrypted-media-utils.js"></script> |
| 6 <script src="../../resources/testharness.js"></script> |
| 7 <script src="../../resources/testharnessreport.js"></script> |
| 8 </head> |
| 9 <body> |
| 10 <script> |
| 11 // After a MediaKeySession object is closed, other operations |
| 12 // (except calling close() again) on the session are not allowed |
| 13 // and should return an InvalidStateError. |
| 14 |
| 15 // Create, initialize, and close a session. Returns a promise that |
| 16 // resolves with the created and closed mediaKeySession and the |
| 17 // initDataType used. |
| 18 function createClosedSession() { |
| 19 var initDataType; |
| 20 var initData; |
| 21 var mediaKeySession; |
| 22 |
| 23 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
getSimpleConfiguration()).then(function(access) { |
| 24 initDataType = access.getConfiguration().initDataTypes[0]; |
| 25 initData = getInitData(initDataType); |
| 26 return access.createMediaKeys(); |
| 27 }).then(function(mediaKeys) { |
| 28 mediaKeySession = mediaKeys.createSession(); |
| 29 return mediaKeySession.generateRequest(initDataType, initDat
a); |
| 30 }).then(function() { |
| 31 return mediaKeySession.close(); |
| 32 }).then(function(result) { |
| 33 return Promise.resolve({ session: mediaKeySession, initDataT
ype: initDataType} ); |
| 34 }); |
| 35 } |
| 36 |
| 37 promise_test(function() |
| 38 { |
| 39 return createClosedSession().then(function(result) { |
| 40 var mediaKeySession = result.session; |
| 41 var initDataType = result.initDataType; |
| 42 var initData = getInitData(initDataType); |
| 43 |
| 44 // Now try the operation that should fail. |
| 45 return mediaKeySession.generateRequest(initDataType, initDat
a); |
| 46 }).then(function() { |
| 47 assert_unreached('Unexpected generateRequest() success.'); |
| 48 }, function(error) { |
| 49 assert_equals(error.name, 'InvalidStateError'); |
| 50 return Promise.resolve(null); |
| 51 }); |
| 52 }, 'generateRequest() after close().'); |
| 53 |
| 54 promise_test(function() |
| 55 { |
| 56 return createClosedSession().then(function(result) { |
| 57 var mediaKeySession = result.session; |
| 58 |
| 59 // Now try the operation that should fail. |
| 60 return mediaKeySession.load('1234'); |
| 61 }).then(function() { |
| 62 assert_unreached('Unexpected load() success.'); |
| 63 }, function(error) { |
| 64 assert_equals(error.name, 'InvalidStateError'); |
| 65 return Promise.resolve(null); |
| 66 }); |
| 67 }, 'load() after close().'); |
| 68 |
| 69 promise_test(function() |
| 70 { |
| 71 return createClosedSession().then(function(result) { |
| 72 var mediaKeySession = result.session; |
| 73 |
| 74 // Now try the operation that should fail. |
| 75 var validLicense = stringToUint8Array(createJWKSet(createJWK
(stringToUint8Array('123'), stringToUint8Array('1234567890abcdef')))); |
| 76 return mediaKeySession.update(validLicense); |
| 77 }).then(function() { |
| 78 assert_unreached('Unexpected update() success.'); |
| 79 }, function(error) { |
| 80 assert_equals(error.name, 'InvalidStateError'); |
| 81 return Promise.resolve(null); |
| 82 }); |
| 83 }, 'update() after close().'); |
| 84 |
| 85 promise_test(function() |
| 86 { |
| 87 return createClosedSession().then(function(result) { |
| 88 var mediaKeySession = result.session; |
| 89 |
| 90 // Now try the operation that should fail. |
| 91 return mediaKeySession.remove(); |
| 92 }).then(function() { |
| 93 assert_unreached('Unexpected remove() success.'); |
| 94 }, function(error) { |
| 95 assert_equals(error.name, 'InvalidStateError'); |
| 96 return Promise.resolve(null); |
| 97 }); |
| 98 }, 'remove() after close().'); |
| 99 |
| 100 promise_test(function() |
| 101 { |
| 102 return createClosedSession().then(function(result) { |
| 103 var mediaKeySession = result.session; |
| 104 |
| 105 // Now try calling close() again, which should succeed. |
| 106 return mediaKeySession.close(); |
| 107 }); |
| 108 }, 'close() after close().'); |
| 109 </script> |
| 110 </body> |
| 111 </html> |
| 112 |
| OLD | NEW |