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 | 29 // The same decryption key is used by both the audio and |
30 // only create a shared session once. | 30 // the video streams so only create a session once. To |
31 if (isSessionCreated) | 31 // avoid issues when comparing the expected.txt file |
| 32 // (which logs the events in the order they occur), create |
| 33 // the session on the second event. This also ensures we |
| 34 // see both events. |
| 35 if (++encryptedEventCount != 2) |
32 return; | 36 return; |
33 isSessionCreated = true; | |
34 | 37 |
35 var mediaKeySession = video.mediaKeys.createSession(); | 38 var mediaKeySession = video.mediaKeys.createSession(); |
36 waitForEventAndRunStep('message', mediaKeySession, onMessage
, test); | 39 waitForEventAndRunStep('message', mediaKeySession, onMessage
, test); |
37 mediaKeySession.generateRequest(event.initDataType, event.in
itData).catch(function(error) { | 40 mediaKeySession.generateRequest(event.initDataType, event.in
itData).catch(function(error) { |
38 forceTestFailureFromPromise(test, error); | 41 forceTestFailureFromPromise(test, error); |
39 }); | 42 }); |
40 } | 43 } |
41 | 44 |
42 function onMessage(event) | 45 function onMessage(event) |
43 { | 46 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return video.setMediaKeys(mediaKeys); | 80 return video.setMediaKeys(mediaKeys); |
78 }).then(function(result) { | 81 }).then(function(result) { |
79 video.play(); | 82 video.play(); |
80 }).catch(function(error) { | 83 }).catch(function(error) { |
81 forceTestFailureFromPromise(test, error); | 84 forceTestFailureFromPromise(test, error); |
82 }); | 85 }); |
83 }, 'Playback using Clear Key key system, calling setMediaKeys() afte
r setting src attribute.'); | 86 }, 'Playback using Clear Key key system, calling setMediaKeys() afte
r setting src attribute.'); |
84 </script> | 87 </script> |
85 </body> | 88 </body> |
86 </html> | 89 </html> |
OLD | NEW |