OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Clear Key Playback</title> | 4 <title>Clear Key Playback</title> |
5 <script src="encrypted-media-utils.js"></script> | 5 <script src="encrypted-media-utils.js"></script> |
6 <script src="../../resources/testharness.js"></script> | 6 <script src="../../resources/testharness.js"></script> |
7 <script src="../../resources/testharnessreport.js"></script> | 7 <script src="../../resources/testharnessreport.js"></script> |
8 </head> | 8 </head> |
9 <body> | 9 <body> |
10 <video id="testVideo"></video> | 10 <video id="testVideo"></video> |
11 <div id="log"></div> | 11 <div id="log"></div> |
12 <p>Test playback of encrypted media using Clear Key key system.</p> | 12 <p>Test playback of encrypted media using Clear Key key system.</p> |
13 <script> | 13 <script> |
14 async_test(function(test) | 14 async_test(function(test) |
15 { | 15 { |
16 var video = document.getElementById('testVideo'); | 16 var video = document.getElementById('testVideo'); |
17 var isSessionCreated = false; | |
18 var isUpdatePromiseResolved = false; | 17 var isUpdatePromiseResolved = false; |
| 18 var encryptedEventCount = 0; |
19 | 19 |
20 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14,
0xd2, 0x7b, | 20 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14,
0xd2, 0x7b, |
21 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4,
0xae, 0x3c]); | 21 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4,
0xae, 0x3c]); |
22 | 22 |
23 function onEncrypted(event) | 23 function onEncrypted(event) |
24 { | 24 { |
25 assert_equals(event.target, video); | 25 assert_equals(event.target, video); |
26 assert_true(event instanceof window.MediaEncryptedEvent); | 26 assert_true(event instanceof window.MediaEncryptedEvent); |
27 assert_equals(event.type, 'encrypted'); | 27 assert_equals(event.type, 'encrypted'); |
28 | 28 |
29 // The same decryption key is shared by all streams so only
create a shared session once. | 29 // The same decryption key is shared by all streams so only |
30 if (isSessionCreated) | 30 // create a shared session once. To avoid timing issues with |
| 31 // the "message" event being received before the second |
| 32 // "encrypted" event, only create the session on the second |
| 33 // event. |
| 34 if (++encryptedEventCount != 2) |
31 return; | 35 return; |
32 isSessionCreated = true; | |
33 | 36 |
34 var mediaKeySession = video.mediaKeys.createSession(); | 37 var mediaKeySession = video.mediaKeys.createSession(); |
35 waitForEventAndRunStep('message', mediaKeySession, onMessage
, test); | 38 waitForEventAndRunStep('message', mediaKeySession, onMessage
, test); |
36 mediaKeySession.generateRequest(event.initDataType, event.in
itData).catch(function(error) { | 39 mediaKeySession.generateRequest(event.initDataType, event.in
itData).catch(function(error) { |
37 forceTestFailureFromPromise(test, error); | 40 forceTestFailureFromPromise(test, error); |
38 }); | 41 }); |
39 } | 42 } |
40 | 43 |
41 function onMessage(event) | 44 function onMessage(event) |
42 { | 45 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 }).then(function(result) { | 79 }).then(function(result) { |
77 video.src = '../content/test-encrypted.webm'; | 80 video.src = '../content/test-encrypted.webm'; |
78 video.play(); | 81 video.play(); |
79 }).catch(function(error) { | 82 }).catch(function(error) { |
80 forceTestFailureFromPromise(test, error); | 83 forceTestFailureFromPromise(test, error); |
81 }); | 84 }); |
82 }, 'Playback using Clear Key key system, calling setMediaKeys() befo
re setting src attribute.'); | 85 }, 'Playback using Clear Key key system, calling setMediaKeys() befo
re setting src attribute.'); |
83 </script> | 86 </script> |
84 </body> | 87 </body> |
85 </html> | 88 </html> |
OLD | NEW |