<!DOCTYPE html>
<html>
<head>
<title>setMediaKeys() multiple times with the same MediaKeys.</title>
<script src="encrypted-media-utils.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<video></video>
<script>
promise_test(function(test)
{
var video = document.querySelector('video');
var content = '../content/test-encrypted.webm';
var mediaKeys;
assert_equals(video.mediaKeys, null);
return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getConfigurationForFile(content)).then(function(access) {
return access.createMediaKeys();
}).then(function(result) {
mediaKeys = result;
assert_not_equals(mediaKeys, null);
// Set mediaKeys on video should work.
return video.setMediaKeys(mediaKeys);
}).then(function() {
assert_true(video.mediaKeys === mediaKeys);
// Set mediaKeys on video again should return a resolved
// promise.
return video.setMediaKeys(mediaKeys);
}).then(function() {
assert_true(video.mediaKeys === mediaKeys);
// Load the media element to create the WebMediaPlayer.
video.src = content;
// Set mediaKeys again on video should still return a
// resolved promise.
return video.setMediaKeys(mediaKeys);
}).then(function() {
assert_true(video.mediaKeys === mediaKeys);
});
}, 'setMediaKeys() multiple times with the same MediaKeys.');
</script>
</body>
</html>