blob: 966291e6c291c29fd2429add49859dfb56e75452 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>setMediaKeys() again after playback</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 keyId = stringToUint8Array('0123456789012345');
var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
var content = '../content/test-encrypted.webm';
var duration = 0.2;
return createClearKeyMediaKeysAndInitializeWithOneKey(keyId, rawKey).then(function(mediaKeys) {
return video.setMediaKeys(mediaKeys);
}).then(function() {
return playVideoAndWaitForTimeupdate(video, content, duration);
}).then(function() {
// Now create a second MediaKeys.
return createClearKeyMediaKeysAndInitializeWithOneKey(keyId, rawKey);
}).then(function(mediaKeys) {
// video is currently playing, so should not be able to
// change MediaKeys now.
assert_false(video.ended);
return video.setMediaKeys(mediaKeys);
}).then(function() {
assert_unreached('Able to change MediaKeys while playing.');
}, function(error) {
// Error expected.
assert_equals(error.name, 'InvalidStateError');
return Promise.resolve('success');
});
}, 'setMediaKeys() again after playback');
</script>
</body>
</html>