blob: 8aaf6ea4e64f586607c425fa9cdb0f841519188e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>Test multiple calls to MediaKeySession.close() sequentially</title>
<script src="encrypted-media-utils.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
// This test verifies that calls to close() on a closed session
// succeed, and always return a promise.
promise_test(function(test)
{
var initDataType;
var initData;
var mediaKeySession;
return navigator.requestMediaKeySystemAccess(
'org.w3.clearkey',
getSimpleConfiguration()).then(function(access) {
initDataType = access.getConfiguration().initDataTypes[0];
initData = getInitData(initDataType);
return access.createMediaKeys();
}).then(function(mediaKeys) {
mediaKeySession = mediaKeys.createSession();
return mediaKeySession.generateRequest(initDataType, initData);
}).then(function() {
// Call close() multiple times sequentially.
var p = mediaKeySession.close();
assert_true(p instanceof Promise);
return p;
}).then(function() {
var p = mediaKeySession.close();
assert_true(p instanceof Promise);
return p;
}).then(function() {
var p = mediaKeySession.close();
assert_true(p instanceof Promise);
return p;
});
}, 'Test multiple calls to MediaKeySession.close() sequentially.');
</script>
</body>
</html>