blob: ebdb9e1538fcdb75f924d15caf18842a5183f092 [file] [log] [blame]
jer.noble@apple.com09c10fb2013-02-08 23:31:29 +00001<!DOCTYPE html>
2<html>
3 <head>
jer.noble@apple.comaf0a6dd2013-08-09 00:07:23 +00004 <title>WebKitMediaKeys</title>
jer.noble@apple.com09c10fb2013-02-08 23:31:29 +00005 <script src=../video-test.js></script>
6 <script>
7 function stringToUint8Array(str)
8 {
9 var arr=[];
10 for(var i=0,j=str.length;i<j;++i)
11 arr[i]=str.charCodeAt(i);
12 return new Uint8Array(arr);
13 }
14
15 var mediaKeys;
16 var mediaKeySession;
17 var initData = stringToUint8Array('mock');
18 var invalidKey = stringToUint8Array('invalid');
19 var validKey = stringToUint8Array('key');
20
21 function runTest()
22 {
23 // Initialize the MockCDM. It supports the key system 'com.apple.mock', the
24 // mime type 'video/mock'. It requires init data to begin with 'mock', and
25 // keys to begin with 'key'.
26 if (internals)
27 internals.initializeMockCDM();
28
jer.noble@apple.comaf0a6dd2013-08-09 00:07:23 +000029 run('mediaKeys = new WebKitMediaKeys("com.webcore.mock")');
jer.noble@apple.com09c10fb2013-02-08 23:31:29 +000030 run('mediaKeySession = mediaKeys.createSession("video/mock", initData)');
31 waitForEvent('webkitkeymessage', keyMessage, false, false, mediaKeySession);
32 waitForEvent('webkitkeyerror', keyError, false, false, mediaKeySession);
33 waitForEvent('webkitkeyadded', null, true, false, mediaKeySession);
34 }
35
36 function keyMessage(event)
37 {
jer.noble@apple.com3b9fdc82013-08-09 00:40:01 +000038 run('mediaKeySession.update(invalidKey)');
jer.noble@apple.com09c10fb2013-02-08 23:31:29 +000039 }
40
41 function keyError(event)
42 {
jer.noble@apple.com3b9fdc82013-08-09 00:40:01 +000043 run('mediaKeySession.update(validKey)');
jer.noble@apple.com09c10fb2013-02-08 23:31:29 +000044 }
45 </script>
46 </head>
47 <body onload="runTest()">
jer.noble@apple.comaf0a6dd2013-08-09 00:07:23 +000048 <p>This tests the events created by WebKitMediaKeys.</p>
jer.noble@apple.com09c10fb2013-02-08 23:31:29 +000049</html>