| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Waiting for a key.</title> | 4 <title>Waiting for a key.</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> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 assert_true(e instanceof window.MediaEncryptedEvent); | 108 assert_true(e instanceof window.MediaEncryptedEvent); |
| 109 assert_equals(e.type, 'encrypted'); | 109 assert_equals(e.type, 'encrypted'); |
| 110 | 110 |
| 111 // The same decryption key is used by both the audio | 111 // The same decryption key is used by both the audio |
| 112 // and the video streams so wait for the second event | 112 // and the video streams so wait for the second event |
| 113 // to ensure we see both events. | 113 // to ensure we see both events. |
| 114 ++debugEncryptedEventCount; | 114 ++debugEncryptedEventCount; |
| 115 if (++encryptedEventCount != 2) | 115 if (++encryptedEventCount != 2) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 video.removeEventListener(listener); | 118 video.removeEventListener('encrypted', listener); |
| 119 resolve(e); | 119 resolve(e); |
| 120 }); | 120 }); |
| 121 }); | 121 }); |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 // Wait for a 'waitingforkey' event. Promise resolved when the | 124 // Wait for a 'waitingforkey' event. Promise resolved when the |
| 125 // event is received. | 125 // event is received. |
| 126 function wait_for_waitingforkey_event(video) | 126 function wait_for_waitingforkey_event(video) |
| 127 { | 127 { |
| 128 var waitingForKeyEventCount = 0; | 128 var waitingForKeyEventCount = 0; |
| 129 return new Promise(function(resolve) { | 129 return new Promise(function(resolve) { |
| 130 video.addEventListener('waitingforkey', function listener(e)
{ | 130 video.addEventListener('waitingforkey', function listener(e)
{ |
| 131 assert_equals(e.target, video); | 131 assert_equals(e.target, video); |
| 132 assert_equals(e.type, 'waitingforkey'); | 132 assert_equals(e.type, 'waitingforkey'); |
| 133 | 133 |
| 134 ++debugWaitingForKeyEventCount; | 134 ++debugWaitingForKeyEventCount; |
| 135 ++waitingForKeyEventCount; | 135 ++waitingForKeyEventCount; |
| 136 // TODO(jrummell): waitingforkey event should only | 136 // TODO(jrummell): waitingforkey event should only |
| 137 // occur once. http://crbug.com/461903 | 137 // occur once. http://crbug.com/461903 |
| 138 // assert_equals(waitingForKeyEventCount, 1, 'Multiple wait
ingforkey events'); | 138 // assert_equals(waitingForKeyEventCount, 1, 'Multiple wait
ingforkey events'); |
| 139 | 139 |
| 140 video.removeEventListener(listener); | 140 video.removeEventListener('waitingforkey', listener); |
| 141 resolve(e); | 141 resolve(e); |
| 142 }); | 142 }); |
| 143 }); | 143 }); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 // Wait for a 'timeupdate' event. Promise resolved if |video| has | 146 // Wait for a 'timeupdate' event. Promise resolved if |video| has |
| 147 // played for more than 0.2 seconds. | 147 // played for more than 0.2 seconds. |
| 148 function wait_for_timeupdate_event(video) | 148 function wait_for_timeupdate_event(video) |
| 149 { | 149 { |
| 150 return new Promise(function(resolve) { | 150 return new Promise(function(resolve) { |
| 151 video.addEventListener('timeupdate', function listener(e) { | 151 video.addEventListener('timeupdate', function listener(e) { |
| 152 assert_equals(e.target, video); | 152 assert_equals(e.target, video); |
| 153 ++debugTimeUpdateEventCount; | 153 ++debugTimeUpdateEventCount; |
| 154 if (video.currentTime < 0.2) | 154 if (video.currentTime < 0.2) |
| 155 return; | 155 return; |
| 156 video.removeEventListener(listener); | 156 video.removeEventListener('timeupdate', listener); |
| 157 resolve(e); | 157 resolve(e); |
| 158 }); | 158 }); |
| 159 }); | 159 }); |
| 160 }; | 160 }; |
| 161 </script> | 161 </script> |
| 162 </body> | 162 </body> |
| 163 </html> | 163 </html> |
| OLD | NEW |