blob: ebdb9e1538fcdb75f924d15caf18842a5183f092 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>WebKitMediaKeys</title>
<script src=../video-test.js></script>
<script>
function stringToUint8Array(str)
{
var arr=[];
for(var i=0,j=str.length;i<j;++i)
arr[i]=str.charCodeAt(i);
return new Uint8Array(arr);
}
var mediaKeys;
var mediaKeySession;
var initData = stringToUint8Array('mock');
var invalidKey = stringToUint8Array('invalid');
var validKey = stringToUint8Array('key');
function runTest()
{
// Initialize the MockCDM. It supports the key system 'com.apple.mock', the
// mime type 'video/mock'. It requires init data to begin with 'mock', and
// keys to begin with 'key'.
if (internals)
internals.initializeMockCDM();
run('mediaKeys = new WebKitMediaKeys("com.webcore.mock")');
run('mediaKeySession = mediaKeys.createSession("video/mock", initData)');
waitForEvent('webkitkeymessage', keyMessage, false, false, mediaKeySession);
waitForEvent('webkitkeyerror', keyError, false, false, mediaKeySession);
waitForEvent('webkitkeyadded', null, true, false, mediaKeySession);
}
function keyMessage(event)
{
run('mediaKeySession.update(invalidKey)');
}
function keyError(event)
{
run('mediaKeySession.update(validKey)');
}
</script>
</head>
<body onload="runTest()">
<p>This tests the events created by WebKitMediaKeys.</p>
</html>