Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
|
xhwang
2016/10/17 23:13:55
This seems unrelated to the "TypeError" change of
jrummell
2016/10/18 00:50:39
Done.
| |
| 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 mediaKeySession. | |
|
xhwang
2016/10/17 23:13:55
nit: created and closed mediaKeySession?
jrummell
2016/10/18 00:50:39
Done.
| |
| 17 function createClosedSession(access) { | |
| 18 var initDataType = access.getConfiguration().initDataTypes[0]; | |
| 19 var initData = getInitData(initDataType); | |
| 20 var mediaKeySession; | |
| 21 | |
| 22 return access.createMediaKeys().then(function(mediaKeys) { | |
| 23 mediaKeySession = mediaKeys.createSession(); | |
| 24 return mediaKeySession.generateRequest(initDataType, initDat a); | |
| 25 }).then(function() { | |
| 26 return mediaKeySession.close(); | |
| 27 }).then(function(result) { | |
| 28 return Promise.resolve(mediaKeySession); | |
| 29 }); | |
| 30 } | |
| 31 | |
| 32 promise_test(function() | |
| 33 { | |
| 34 var initDataType; | |
| 35 var initData; | |
| 36 | |
| 37 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { | |
|
xhwang
2016/10/17 23:13:55
Can we put rMKSA part of createClosedSession() so
jrummell
2016/10/18 00:50:39
Done.
| |
| 38 initDataType = access.getConfiguration().initDataTypes[0]; | |
| 39 initData = getInitData(initDataType); | |
| 40 return createClosedSession(access); | |
| 41 }).then(function(mediaKeySession) { | |
| 42 // Now try the operation that should fail. | |
| 43 return mediaKeySession.generateRequest(initDataType, initDat a); | |
| 44 }).then(function() { | |
| 45 assert_unreached('Unexpected generateRequest() success.'); | |
| 46 }, function(error) { | |
| 47 assert_equals(error.name, 'InvalidStateError'); | |
| 48 return Promise.resolve(null); | |
| 49 }); | |
| 50 }, 'generateRequest() after close().'); | |
| 51 | |
| 52 promise_test(function() | |
| 53 { | |
| 54 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { | |
| 55 return createClosedSession(access); | |
| 56 }).then(function(mediaKeySession) { | |
| 57 // Now try the operation that should fail. | |
| 58 return mediaKeySession.load('1234'); | |
| 59 }).then(function() { | |
| 60 assert_unreached('Unexpected load() success.'); | |
| 61 }, function(error) { | |
| 62 assert_equals(error.name, 'InvalidStateError'); | |
| 63 return Promise.resolve(null); | |
| 64 }); | |
| 65 }, 'load() after close().'); | |
| 66 | |
| 67 promise_test(function() | |
| 68 { | |
| 69 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { | |
| 70 return createClosedSession(access); | |
| 71 }).then(function(mediaKeySession) { | |
| 72 // Now try the operation that should fail. | |
| 73 var validLicense = stringToUint8Array(createJWKSet(createJWK (stringToUint8Array('123'), stringToUint8Array('1234567890abcdef')))); | |
| 74 return mediaKeySession.update(validLicense); | |
| 75 }).then(function() { | |
| 76 assert_unreached('Unexpected update() success.'); | |
| 77 }, function(error) { | |
| 78 assert_equals(error.name, 'InvalidStateError'); | |
| 79 return Promise.resolve(null); | |
| 80 }); | |
| 81 }, 'update() after close().'); | |
| 82 | |
| 83 promise_test(function() | |
| 84 { | |
| 85 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { | |
| 86 return createClosedSession(access); | |
| 87 }).then(function(mediaKeySession) { | |
| 88 // Now try the operation that should fail. | |
| 89 return mediaKeySession.remove(); | |
| 90 }).then(function() { | |
| 91 assert_unreached('Unexpected remove() success.'); | |
| 92 }, function(error) { | |
| 93 assert_equals(error.name, 'InvalidStateError'); | |
| 94 return Promise.resolve(null); | |
| 95 }); | |
| 96 }, 'remove() after close().'); | |
| 97 | |
| 98 promise_test(function() | |
| 99 { | |
| 100 return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { | |
| 101 return createClosedSession(access); | |
| 102 }).then(function(mediaKeySession) { | |
| 103 // Now try calling close() again, which should succeed. | |
| 104 return mediaKeySession.close(); | |
| 105 }); | |
| 106 }, 'close() after close().'); | |
| 107 </script> | |
| 108 </body> | |
| 109 </html> | |
| 110 | |
| OLD | NEW |