| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Reloading during encrypted media playback</title> | 4 <title>Reloading during encrypted media 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 reloading during encrypted media playback.</p> | 12 <p>Test reloading during encrypted media playback.</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 mediaKeySession = null; | 17 var mediaKeySession = null; |
| 18 var isSessionCreated = false; | |
| 19 var sessionReadyReceived = false; | 18 var sessionReadyReceived = false; |
| 19 var encryptedEventCount = 0; |
| 20 | 20 |
| 21 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14,
0xd2, 0x7b, | 21 var rawKey = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14,
0xd2, 0x7b, |
| 22 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4,
0xae, 0x3c]); | 22 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4,
0xae, 0x3c]); |
| 23 | 23 |
| 24 function onEncrypted(event) | 24 function onEncrypted(event) |
| 25 { | 25 { |
| 26 assert_equals(event.target, video); | 26 assert_equals(event.target, video); |
| 27 assert_true(event instanceof window.MediaEncryptedEvent); | 27 assert_true(event instanceof window.MediaEncryptedEvent); |
| 28 assert_equals(event.type, 'encrypted'); | 28 assert_equals(event.type, 'encrypted'); |
| 29 | 29 |
| 30 // The same decryption key is shared by all streams so only | 30 // The same decryption key is used by both the audio and |
| 31 // create a shared session once. | 31 // the video streams so only create a session once. To |
| 32 if (isSessionCreated) | 32 // avoid issues when comparing the expected.txt file |
| 33 // (which logs the events in the order they occur), create |
| 34 // the session on the second event. This also ensures we |
| 35 // see both events. |
| 36 if (++encryptedEventCount != 2) |
| 33 return; | 37 return; |
| 34 isSessionCreated = true; | |
| 35 | 38 |
| 36 mediaKeySession = video.mediaKeys.createSession(); | 39 mediaKeySession = video.mediaKeys.createSession(); |
| 37 waitForEventAndRunStep('message', mediaKeySession, onMessage
, test); | 40 waitForEventAndRunStep('message', mediaKeySession, onMessage
, test); |
| 38 mediaKeySession.generateRequest(event.initDataType, event.in
itData).catch(function(error) { | 41 mediaKeySession.generateRequest(event.initDataType, event.in
itData).catch(function(error) { |
| 39 forceTestFailureFromPromise(test, error); | 42 forceTestFailureFromPromise(test, error); |
| 40 }); | 43 }); |
| 41 } | 44 } |
| 42 | 45 |
| 43 function onMessage(event) | 46 function onMessage(event) |
| 44 { | 47 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return video.setMediaKeys(mediaKeys); | 87 return video.setMediaKeys(mediaKeys); |
| 85 }).then(function(result) { | 88 }).then(function(result) { |
| 86 video.play(); | 89 video.play(); |
| 87 }).catch(function(error) { | 90 }).catch(function(error) { |
| 88 forceTestFailureFromPromise(test, error); | 91 forceTestFailureFromPromise(test, error); |
| 89 }); | 92 }); |
| 90 }, 'Reloading during encrypted media playback.'); | 93 }, 'Reloading during encrypted media playback.'); |
| 91 </script> | 94 </script> |
| 92 </body> | 95 </body> |
| 93 </html> | 96 </html> |
| OLD | NEW |