31ee4d9c by David LaPalomento

Add test for mediaupdatetimeouts

Make sure mediaupdatetimeout events don't get repeatedly triggered after frequent quality switches.
1 parent ab0670dd
...@@ -195,7 +195,6 @@ ...@@ -195,7 +195,6 @@
195 strictEqual(errors[0].status, 500, 'http status is captured'); 195 strictEqual(errors[0].status, 500, 'http status is captured');
196 }); 196 });
197 197
198
199 // http://tools.ietf.org/html/draft-pantos-http-live-streaming-12#section-6.3.4 198 // http://tools.ietf.org/html/draft-pantos-http-live-streaming-12#section-6.3.4
200 test('halves the refresh timeout if a playlist is unchanged' + 199 test('halves the refresh timeout if a playlist is unchanged' +
201 'since the last reload', function() { 200 'since the last reload', function() {
...@@ -219,6 +218,37 @@ ...@@ -219,6 +218,37 @@
219 'requested the media playlist'); 218 'requested the media playlist');
220 }); 219 });
221 220
221 test('clears the update timeout when switching quality', function() {
222 var loader = new videojs.Hls.PlaylistLoader('live-master.m3u8'), refreshes = 0;
223 // track the number of playlist refreshes triggered
224 loader.on('mediaupdatetimeout', function() {
225 refreshes++;
226 });
227 // deliver the master
228 requests.pop().respond(200, null,
229 '#EXTM3U\n' +
230 '#EXT-X-STREAM-INF:BANDWIDTH=1\n' +
231 'live-low.m3u8\n' +
232 '#EXT-X-STREAM-INF:BANDWIDTH=2\n' +
233 'live-high.m3u8\n');
234 // deliver the low quality playlist
235 requests.pop().respond(200, null,
236 '#EXTM3U\n' +
237 '#EXT-X-MEDIA-SEQUENCE:0\n' +
238 '#EXTINF:10,\n' +
239 'low-0.ts\n');
240 // change to a higher quality playlist
241 loader.media('live-high.m3u8');
242 requests.pop().respond(200, null,
243 '#EXTM3U\n' +
244 '#EXT-X-MEDIA-SEQUENCE:0\n' +
245 '#EXTINF:10,\n' +
246 'high-0.ts\n');
247 clock.tick(10 * 1000); // trigger a refresh
248
249 equal(1, refreshes, 'only one refresh was triggered');
250 });
251
222 test('media-sequence updates are considered a playlist change', function() { 252 test('media-sequence updates are considered a playlist change', function() {
223 new videojs.Hls.PlaylistLoader('live.m3u8'); 253 new videojs.Hls.PlaylistLoader('live.m3u8');
224 requests.pop().respond(200, null, 254 requests.pop().respond(200, null,
......