Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-not-callable-after-close.html |
| diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-not-callable-after-close.html b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-not-callable-after-close.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1f23cae58ec1a4db186ff463fd22567a9409c8df |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-not-callable-after-close.html |
| @@ -0,0 +1,110 @@ |
| +<!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.
|
| +<html> |
| + <head> |
| + <title>Test MediaKeySession not callable after close().</title> |
| + <script src="encrypted-media-utils.js"></script> |
| + <script src="../../resources/testharness.js"></script> |
| + <script src="../../resources/testharnessreport.js"></script> |
| + </head> |
| + <body> |
| + <script> |
| + // After a MediaKeySession object is closed, other operations |
| + // (except calling close() again) on the session are not allowed |
| + // and should return an InvalidStateError. |
| + |
| + // Create, initialize, and close a session. Returns a promise that |
| + // 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.
|
| + function createClosedSession(access) { |
| + var initDataType = access.getConfiguration().initDataTypes[0]; |
| + var initData = getInitData(initDataType); |
| + var mediaKeySession; |
| + |
| + return access.createMediaKeys().then(function(mediaKeys) { |
| + mediaKeySession = mediaKeys.createSession(); |
| + return mediaKeySession.generateRequest(initDataType, initData); |
| + }).then(function() { |
| + return mediaKeySession.close(); |
| + }).then(function(result) { |
| + return Promise.resolve(mediaKeySession); |
| + }); |
| + } |
| + |
| + promise_test(function() |
| + { |
| + var initDataType; |
| + var initData; |
| + |
| + 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.
|
| + initDataType = access.getConfiguration().initDataTypes[0]; |
| + initData = getInitData(initDataType); |
| + return createClosedSession(access); |
| + }).then(function(mediaKeySession) { |
| + // Now try the operation that should fail. |
| + return mediaKeySession.generateRequest(initDataType, initData); |
| + }).then(function() { |
| + assert_unreached('Unexpected generateRequest() success.'); |
| + }, function(error) { |
| + assert_equals(error.name, 'InvalidStateError'); |
| + return Promise.resolve(null); |
| + }); |
| + }, 'generateRequest() after close().'); |
| + |
| + promise_test(function() |
| + { |
| + return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { |
| + return createClosedSession(access); |
| + }).then(function(mediaKeySession) { |
| + // Now try the operation that should fail. |
| + return mediaKeySession.load('1234'); |
| + }).then(function() { |
| + assert_unreached('Unexpected load() success.'); |
| + }, function(error) { |
| + assert_equals(error.name, 'InvalidStateError'); |
| + return Promise.resolve(null); |
| + }); |
| + }, 'load() after close().'); |
| + |
| + promise_test(function() |
| + { |
| + return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { |
| + return createClosedSession(access); |
| + }).then(function(mediaKeySession) { |
| + // Now try the operation that should fail. |
| + var validLicense = stringToUint8Array(createJWKSet(createJWK(stringToUint8Array('123'), stringToUint8Array('1234567890abcdef')))); |
| + return mediaKeySession.update(validLicense); |
| + }).then(function() { |
| + assert_unreached('Unexpected update() success.'); |
| + }, function(error) { |
| + assert_equals(error.name, 'InvalidStateError'); |
| + return Promise.resolve(null); |
| + }); |
| + }, 'update() after close().'); |
| + |
| + promise_test(function() |
| + { |
| + return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { |
| + return createClosedSession(access); |
| + }).then(function(mediaKeySession) { |
| + // Now try the operation that should fail. |
| + return mediaKeySession.remove(); |
| + }).then(function() { |
| + assert_unreached('Unexpected remove() success.'); |
| + }, function(error) { |
| + assert_equals(error.name, 'InvalidStateError'); |
| + return Promise.resolve(null); |
| + }); |
| + }, 'remove() after close().'); |
| + |
| + promise_test(function() |
| + { |
| + return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfiguration()).then(function(access) { |
| + return createClosedSession(access); |
| + }).then(function(mediaKeySession) { |
| + // Now try calling close() again, which should succeed. |
| + return mediaKeySession.close(); |
| + }); |
| + }, 'close() after close().'); |
| + </script> |
| + </body> |
| +</html> |
| + |