| 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 used by both the audio and |
| 30 if (isSessionCreated) | 30 // the video streams so only create a session once. To |
| 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) |
| 31 return; | 36 return; |
| 32 isSessionCreated = true; | |
| 33 | 37 |
| 34 var mediaKeySession = video.mediaKeys.createSession(); | 38 var mediaKeySession = video.mediaKeys.createSession(); |
| 35 waitForEventAndRunStep('message', mediaKeySession, onMessage
, test); | 39 waitForEventAndRunStep('message', mediaKeySession, onMessage
, test); |
| 36 mediaKeySession.generateRequest(event.initDataType, event.in
itData).catch(function(error) { | 40 mediaKeySession.generateRequest(event.initDataType, event.in
itData).catch(function(error) { |
| 37 forceTestFailureFromPromise(test, error); | 41 forceTestFailureFromPromise(test, error); |
| 38 }); | 42 }); |
| 39 } | 43 } |
| 40 | 44 |
| 41 function onMessage(event) | 45 function onMessage(event) |
| 42 { | 46 { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 }).then(function(result) { | 80 }).then(function(result) { |
| 77 video.src = '../content/test-encrypted.webm'; | 81 video.src = '../content/test-encrypted.webm'; |
| 78 video.play(); | 82 video.play(); |
| 79 }).catch(function(error) { | 83 }).catch(function(error) { |
| 80 forceTestFailureFromPromise(test, error); | 84 forceTestFailureFromPromise(test, error); |
| 81 }); | 85 }); |
| 82 }, 'Playback using Clear Key key system, calling setMediaKeys() befo
re setting src attribute.'); | 86 }, 'Playback using Clear Key key system, calling setMediaKeys() befo
re setting src attribute.'); |
| 83 </script> | 87 </script> |
| 84 </body> | 88 </body> |
| 85 </html> | 89 </html> |
| OLD | NEW |