Fix tests
Make the withCredentials test synchronous so that karma doesn't hang on it. Pull out test player creation so that it can be re-used. Re-indented player.src invocations.
Showing
1 changed file
with
198 additions
and
78 deletions
1 | (function(window, videojs, undefined) { | 1 | (function(window, videojs, undefined) { |
2 | 'use strict'; | ||
2 | /* | 3 | /* |
3 | ======== A Handy Little QUnit Reference ======== | 4 | ======== A Handy Little QUnit Reference ======== |
4 | http://api.qunitjs.com/ | 5 | http://api.qunitjs.com/ |
... | @@ -30,6 +31,29 @@ var | ... | @@ -30,6 +31,29 @@ var |
30 | requests, | 31 | requests, |
31 | xhr, | 32 | xhr, |
32 | 33 | ||
34 | createPlayer = function(options) { | ||
35 | var tech, video, player; | ||
36 | video = document.createElement('video'); | ||
37 | document.querySelector('#qunit-fixture').appendChild(video); | ||
38 | player = videojs(video, { | ||
39 | flash: { | ||
40 | swf: '' | ||
41 | }, | ||
42 | techOrder: ['hls'], | ||
43 | hls: options || {} | ||
44 | }); | ||
45 | |||
46 | player.buffered = function() { | ||
47 | return videojs.createTimeRange(0, 0); | ||
48 | }; | ||
49 | |||
50 | tech = player.el().querySelector('.vjs-tech'); | ||
51 | tech.vjs_getProperty = function() {}; | ||
52 | tech.vjs_src = function() {}; | ||
53 | videojs.Flash.onReady(tech.id); | ||
54 | |||
55 | return player; | ||
56 | }, | ||
33 | standardXHRResponse = function(request) { | 57 | standardXHRResponse = function(request) { |
34 | if (!request.url) { | 58 | if (!request.url) { |
35 | return; | 59 | return; |
... | @@ -96,20 +120,6 @@ module('HLS', { | ... | @@ -96,20 +120,6 @@ module('HLS', { |
96 | this.abort = function() {}; | 120 | this.abort = function() {}; |
97 | }; | 121 | }; |
98 | 122 | ||
99 | // create the test player | ||
100 | var video = document.createElement('video'); | ||
101 | document.querySelector('#qunit-fixture').appendChild(video); | ||
102 | player = videojs(video, { | ||
103 | flash: { | ||
104 | swf: ''//'../node_modules/video.js/dist/video-js/video-js.swf' | ||
105 | }, | ||
106 | techOrder: ['hls'] | ||
107 | }); | ||
108 | |||
109 | player.buffered = function() { | ||
110 | return videojs.createTimeRange(0, 0); | ||
111 | }; | ||
112 | |||
113 | // store functionality that some tests need to mock | 123 | // store functionality that some tests need to mock |
114 | oldSegmentParser = videojs.Hls.SegmentParser; | 124 | oldSegmentParser = videojs.Hls.SegmentParser; |
115 | oldSetTimeout = window.setTimeout; | 125 | oldSetTimeout = window.setTimeout; |
... | @@ -121,10 +131,8 @@ module('HLS', { | ... | @@ -121,10 +131,8 @@ module('HLS', { |
121 | requests.push(xhr); | 131 | requests.push(xhr); |
122 | }; | 132 | }; |
123 | 133 | ||
124 | var tech = player.el().querySelector('.vjs-tech'); | 134 | // create the test player |
125 | tech.vjs_getProperty = function() {}; | 135 | player = createPlayer(); |
126 | tech.vjs_src = function() {}; | ||
127 | videojs.Flash.onReady(tech.id); | ||
128 | }, | 136 | }, |
129 | 137 | ||
130 | teardown: function() { | 138 | teardown: function() { |
... | @@ -144,7 +152,10 @@ test('starts playing if autoplay is specified', function() { | ... | @@ -144,7 +152,10 @@ test('starts playing if autoplay is specified', function() { |
144 | plays++; | 152 | plays++; |
145 | }; | 153 | }; |
146 | player.options().autoplay = true; | 154 | player.options().autoplay = true; |
147 | player.src({src: 'manifest/playlist.m3u8', type: 'application/vnd.apple.mpegurl'}); | 155 | player.src({ |
156 | src: 'manifest/playlist.m3u8', | ||
157 | type: 'application/vnd.apple.mpegurl' | ||
158 | }); | ||
148 | player.hls.mediaSource.trigger({ | 159 | player.hls.mediaSource.trigger({ |
149 | type: 'sourceopen' | 160 | type: 'sourceopen' |
150 | }); | 161 | }); |
... | @@ -160,7 +171,10 @@ test('creates a PlaylistLoader on init', function() { | ... | @@ -160,7 +171,10 @@ test('creates a PlaylistLoader on init', function() { |
160 | }); | 171 | }); |
161 | 172 | ||
162 | ok(!player.hls.playlists, 'waits for set src to create the loader'); | 173 | ok(!player.hls.playlists, 'waits for set src to create the loader'); |
163 | player.src({src:'manifest/playlist.m3u8', type: 'application/vnd.apple.mpegurl'}); | 174 | player.src({ |
175 | src:'manifest/playlist.m3u8', | ||
176 | type: 'application/vnd.apple.mpegurl' | ||
177 | }); | ||
164 | player.hls.mediaSource.trigger({ | 178 | player.hls.mediaSource.trigger({ |
165 | type: 'sourceopen' | 179 | type: 'sourceopen' |
166 | }); | 180 | }); |
... | @@ -182,7 +196,10 @@ test('sets the duration if one is available on the playlist', function() { | ... | @@ -182,7 +196,10 @@ test('sets the duration if one is available on the playlist', function() { |
182 | } | 196 | } |
183 | calls++; | 197 | calls++; |
184 | }; | 198 | }; |
185 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 199 | player.src({ |
200 | src: 'manifest/media.m3u8', | ||
201 | type: 'application/vnd.apple.mpegurl' | ||
202 | }); | ||
186 | player.hls.mediaSource.trigger({ | 203 | player.hls.mediaSource.trigger({ |
187 | type: 'sourceopen' | 204 | type: 'sourceopen' |
188 | }); | 205 | }); |
... | @@ -201,7 +218,10 @@ test('calculates the duration if needed', function() { | ... | @@ -201,7 +218,10 @@ test('calculates the duration if needed', function() { |
201 | } | 218 | } |
202 | durations.push(duration); | 219 | durations.push(duration); |
203 | }; | 220 | }; |
204 | player.src({src: 'http://example.com/manifest/missingExtinf.m3u8', type: 'application/vnd.apple.mpegurl'}); | 221 | player.src({ |
222 | src: 'http://example.com/manifest/missingExtinf.m3u8', | ||
223 | type: 'application/vnd.apple.mpegurl' | ||
224 | }); | ||
205 | player.hls.mediaSource.trigger({ | 225 | player.hls.mediaSource.trigger({ |
206 | type: 'sourceopen' | 226 | type: 'sourceopen' |
207 | }); | 227 | }); |
... | @@ -214,7 +234,10 @@ test('calculates the duration if needed', function() { | ... | @@ -214,7 +234,10 @@ test('calculates the duration if needed', function() { |
214 | }); | 234 | }); |
215 | 235 | ||
216 | test('starts downloading a segment on loadedmetadata', function() { | 236 | test('starts downloading a segment on loadedmetadata', function() { |
217 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 237 | player.src({ |
238 | src: 'manifest/media.m3u8', | ||
239 | type: 'application/vnd.apple.mpegurl' | ||
240 | }); | ||
218 | player.buffered = function() { | 241 | player.buffered = function() { |
219 | return videojs.createTimeRange(0, 0); | 242 | return videojs.createTimeRange(0, 0); |
220 | }; | 243 | }; |
... | @@ -232,7 +255,10 @@ test('starts downloading a segment on loadedmetadata', function() { | ... | @@ -232,7 +255,10 @@ test('starts downloading a segment on loadedmetadata', function() { |
232 | }); | 255 | }); |
233 | 256 | ||
234 | test('recognizes absolute URIs and requests them unmodified', function() { | 257 | test('recognizes absolute URIs and requests them unmodified', function() { |
235 | player.src({src: 'manifest/absoluteUris.m3u8', type: 'application/vnd.apple.mpegurl'}); | 258 | player.src({ |
259 | src: 'manifest/absoluteUris.m3u8', | ||
260 | type: 'application/vnd.apple.mpegurl' | ||
261 | }); | ||
236 | player.hls.mediaSource.trigger({ | 262 | player.hls.mediaSource.trigger({ |
237 | type: 'sourceopen' | 263 | type: 'sourceopen' |
238 | }); | 264 | }); |
... | @@ -245,7 +271,10 @@ test('recognizes absolute URIs and requests them unmodified', function() { | ... | @@ -245,7 +271,10 @@ test('recognizes absolute URIs and requests them unmodified', function() { |
245 | }); | 271 | }); |
246 | 272 | ||
247 | test('recognizes domain-relative URLs', function() { | 273 | test('recognizes domain-relative URLs', function() { |
248 | player.src({src: 'manifest/domainUris.m3u8', type: 'application/vnd.apple.mpegurl'}); | 274 | player.src({ |
275 | src: 'manifest/domainUris.m3u8', | ||
276 | type: 'application/vnd.apple.mpegurl' | ||
277 | }); | ||
249 | player.hls.mediaSource.trigger({ | 278 | player.hls.mediaSource.trigger({ |
250 | type: 'sourceopen' | 279 | type: 'sourceopen' |
251 | }); | 280 | }); |
... | @@ -260,14 +289,20 @@ test('recognizes domain-relative URLs', function() { | ... | @@ -260,14 +289,20 @@ test('recognizes domain-relative URLs', function() { |
260 | test('re-initializes the tech for each source', function() { | 289 | test('re-initializes the tech for each source', function() { |
261 | var firstPlaylists, secondPlaylists, firstMSE, secondMSE; | 290 | var firstPlaylists, secondPlaylists, firstMSE, secondMSE; |
262 | 291 | ||
263 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 292 | player.src({ |
293 | src: 'manifest/master.m3u8', | ||
294 | type: 'application/vnd.apple.mpegurl' | ||
295 | }); | ||
264 | player.hls.mediaSource.trigger({ | 296 | player.hls.mediaSource.trigger({ |
265 | type: 'sourceopen' | 297 | type: 'sourceopen' |
266 | }); | 298 | }); |
267 | firstPlaylists = player.hls.playlists; | 299 | firstPlaylists = player.hls.playlists; |
268 | firstMSE = player.hls.mediaSource; | 300 | firstMSE = player.hls.mediaSource; |
269 | 301 | ||
270 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 302 | player.src({ |
303 | src: 'manifest/master.m3u8', | ||
304 | type: 'application/vnd.apple.mpegurl' | ||
305 | }); | ||
271 | player.hls.mediaSource.trigger({ | 306 | player.hls.mediaSource.trigger({ |
272 | type: 'sourceopen' | 307 | type: 'sourceopen' |
273 | }); | 308 | }); |
... | @@ -283,7 +318,10 @@ test('triggers an error when a master playlist request errors', function() { | ... | @@ -283,7 +318,10 @@ test('triggers an error when a master playlist request errors', function() { |
283 | player.on('error', function() { | 318 | player.on('error', function() { |
284 | error = player.hls.error; | 319 | error = player.hls.error; |
285 | }); | 320 | }); |
286 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 321 | player.src({ |
322 | src: 'manifest/master.m3u8', | ||
323 | type: 'application/vnd.apple.mpegurl' | ||
324 | }); | ||
287 | player.hls.mediaSource.trigger({ | 325 | player.hls.mediaSource.trigger({ |
288 | type: 'sourceopen' | 326 | type: 'sourceopen' |
289 | }); | 327 | }); |
... | @@ -294,7 +332,10 @@ test('triggers an error when a master playlist request errors', function() { | ... | @@ -294,7 +332,10 @@ test('triggers an error when a master playlist request errors', function() { |
294 | }); | 332 | }); |
295 | 333 | ||
296 | test('downloads media playlists after loading the master', function() { | 334 | test('downloads media playlists after loading the master', function() { |
297 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 335 | player.src({ |
336 | src: 'manifest/master.m3u8', | ||
337 | type: 'application/vnd.apple.mpegurl' | ||
338 | }); | ||
298 | player.hls.mediaSource.trigger({ | 339 | player.hls.mediaSource.trigger({ |
299 | type: 'sourceopen' | 340 | type: 'sourceopen' |
300 | }); | 341 | }); |
... | @@ -324,7 +365,10 @@ test('timeupdates do not check to fill the buffer until a media playlist is read | ... | @@ -324,7 +365,10 @@ test('timeupdates do not check to fill the buffer until a media playlist is read |
324 | }; | 365 | }; |
325 | this.send = function() {}; | 366 | this.send = function() {}; |
326 | }; | 367 | }; |
327 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 368 | player.src({ |
369 | src: 'manifest/media.m3u8', | ||
370 | type: 'application/vnd.apple.mpegurl' | ||
371 | }); | ||
328 | player.hls.mediaSource.trigger({ | 372 | player.hls.mediaSource.trigger({ |
329 | type: 'sourceopen' | 373 | type: 'sourceopen' |
330 | }); | 374 | }); |
... | @@ -335,7 +379,10 @@ test('timeupdates do not check to fill the buffer until a media playlist is read | ... | @@ -335,7 +379,10 @@ test('timeupdates do not check to fill the buffer until a media playlist is read |
335 | }); | 379 | }); |
336 | 380 | ||
337 | test('calculates the bandwidth after downloading a segment', function() { | 381 | test('calculates the bandwidth after downloading a segment', function() { |
338 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 382 | player.src({ |
383 | src: 'manifest/media.m3u8', | ||
384 | type: 'application/vnd.apple.mpegurl' | ||
385 | }); | ||
339 | player.hls.mediaSource.trigger({ | 386 | player.hls.mediaSource.trigger({ |
340 | type: 'sourceopen' | 387 | type: 'sourceopen' |
341 | }); | 388 | }); |
... | @@ -352,7 +399,10 @@ test('calculates the bandwidth after downloading a segment', function() { | ... | @@ -352,7 +399,10 @@ test('calculates the bandwidth after downloading a segment', function() { |
352 | 399 | ||
353 | test('selects a playlist after segment downloads', function() { | 400 | test('selects a playlist after segment downloads', function() { |
354 | var calls = 0; | 401 | var calls = 0; |
355 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 402 | player.src({ |
403 | src: 'manifest/master.m3u8', | ||
404 | type: 'application/vnd.apple.mpegurl' | ||
405 | }); | ||
356 | player.hls.selectPlaylist = function() { | 406 | player.hls.selectPlaylist = function() { |
357 | calls++; | 407 | calls++; |
358 | return player.hls.playlists.master.playlists[0]; | 408 | return player.hls.playlists.master.playlists[0]; |
... | @@ -382,7 +432,10 @@ test('selects a playlist after segment downloads', function() { | ... | @@ -382,7 +432,10 @@ test('selects a playlist after segment downloads', function() { |
382 | test('moves to the next segment if there is a network error', function() { | 432 | test('moves to the next segment if there is a network error', function() { |
383 | var mediaIndex; | 433 | var mediaIndex; |
384 | 434 | ||
385 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 435 | player.src({ |
436 | src: 'manifest/master.m3u8', | ||
437 | type: 'application/vnd.apple.mpegurl' | ||
438 | }); | ||
386 | player.hls.mediaSource.trigger({ | 439 | player.hls.mediaSource.trigger({ |
387 | type: 'sourceopen' | 440 | type: 'sourceopen' |
388 | }); | 441 | }); |
... | @@ -401,7 +454,10 @@ test('updates the duration after switching playlists', function() { | ... | @@ -401,7 +454,10 @@ test('updates the duration after switching playlists', function() { |
401 | var | 454 | var |
402 | calls = 0, | 455 | calls = 0, |
403 | selectedPlaylist = false; | 456 | selectedPlaylist = false; |
404 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 457 | player.src({ |
458 | src: 'manifest/master.m3u8', | ||
459 | type: 'application/vnd.apple.mpegurl' | ||
460 | }); | ||
405 | player.hls.selectPlaylist = function() { | 461 | player.hls.selectPlaylist = function() { |
406 | selectedPlaylist = true; | 462 | selectedPlaylist = true; |
407 | return player.hls.playlists.master.playlists[1]; | 463 | return player.hls.playlists.master.playlists[1]; |
... | @@ -433,7 +489,10 @@ test('downloads additional playlists if required', function() { | ... | @@ -433,7 +489,10 @@ test('downloads additional playlists if required', function() { |
433 | playlist = { | 489 | playlist = { |
434 | uri: 'media3.m3u8' | 490 | uri: 'media3.m3u8' |
435 | }; | 491 | }; |
436 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 492 | player.src({ |
493 | src: 'manifest/master.m3u8', | ||
494 | type: 'application/vnd.apple.mpegurl' | ||
495 | }); | ||
437 | player.hls.mediaSource.trigger({ | 496 | player.hls.mediaSource.trigger({ |
438 | type: 'sourceopen' | 497 | type: 'sourceopen' |
439 | }); | 498 | }); |
... | @@ -471,7 +530,10 @@ test('downloads additional playlists if required', function() { | ... | @@ -471,7 +530,10 @@ test('downloads additional playlists if required', function() { |
471 | 530 | ||
472 | test('selects a playlist below the current bandwidth', function() { | 531 | test('selects a playlist below the current bandwidth', function() { |
473 | var playlist; | 532 | var playlist; |
474 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 533 | player.src({ |
534 | src: 'manifest/master.m3u8', | ||
535 | type: 'application/vnd.apple.mpegurl' | ||
536 | }); | ||
475 | player.hls.mediaSource.trigger({ | 537 | player.hls.mediaSource.trigger({ |
476 | type: 'sourceopen' | 538 | type: 'sourceopen' |
477 | }); | 539 | }); |
... | @@ -493,7 +555,10 @@ test('selects a playlist below the current bandwidth', function() { | ... | @@ -493,7 +555,10 @@ test('selects a playlist below the current bandwidth', function() { |
493 | 555 | ||
494 | test('raises the minimum bitrate for a stream proportionially', function() { | 556 | test('raises the minimum bitrate for a stream proportionially', function() { |
495 | var playlist; | 557 | var playlist; |
496 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 558 | player.src({ |
559 | src: 'manifest/master.m3u8', | ||
560 | type: 'application/vnd.apple.mpegurl' | ||
561 | }); | ||
497 | player.hls.mediaSource.trigger({ | 562 | player.hls.mediaSource.trigger({ |
498 | type: 'sourceopen' | 563 | type: 'sourceopen' |
499 | }); | 564 | }); |
... | @@ -515,7 +580,10 @@ test('raises the minimum bitrate for a stream proportionially', function() { | ... | @@ -515,7 +580,10 @@ test('raises the minimum bitrate for a stream proportionially', function() { |
515 | 580 | ||
516 | test('uses the lowest bitrate if no other is suitable', function() { | 581 | test('uses the lowest bitrate if no other is suitable', function() { |
517 | var playlist; | 582 | var playlist; |
518 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 583 | player.src({ |
584 | src: 'manifest/master.m3u8', | ||
585 | type: 'application/vnd.apple.mpegurl' | ||
586 | }); | ||
519 | player.hls.mediaSource.trigger({ | 587 | player.hls.mediaSource.trigger({ |
520 | type: 'sourceopen' | 588 | type: 'sourceopen' |
521 | }); | 589 | }); |
... | @@ -535,7 +603,10 @@ test('uses the lowest bitrate if no other is suitable', function() { | ... | @@ -535,7 +603,10 @@ test('uses the lowest bitrate if no other is suitable', function() { |
535 | test('selects the correct rendition by player dimensions', function() { | 603 | test('selects the correct rendition by player dimensions', function() { |
536 | var playlist; | 604 | var playlist; |
537 | 605 | ||
538 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 606 | player.src({ |
607 | src: 'manifest/master.m3u8', | ||
608 | type: 'application/vnd.apple.mpegurl' | ||
609 | }); | ||
539 | 610 | ||
540 | player.hls.mediaSource.trigger({ | 611 | player.hls.mediaSource.trigger({ |
541 | type: 'sourceopen' | 612 | type: 'sourceopen' |
... | @@ -565,7 +636,10 @@ test('selects the correct rendition by player dimensions', function() { | ... | @@ -565,7 +636,10 @@ test('selects the correct rendition by player dimensions', function() { |
565 | 636 | ||
566 | 637 | ||
567 | test('does not download the next segment if the buffer is full', function() { | 638 | test('does not download the next segment if the buffer is full', function() { |
568 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 639 | player.src({ |
640 | src: 'manifest/media.m3u8', | ||
641 | type: 'application/vnd.apple.mpegurl' | ||
642 | }); | ||
569 | player.currentTime = function() { | 643 | player.currentTime = function() { |
570 | return 15; | 644 | return 15; |
571 | }; | 645 | }; |
... | @@ -584,7 +658,10 @@ test('does not download the next segment if the buffer is full', function() { | ... | @@ -584,7 +658,10 @@ test('does not download the next segment if the buffer is full', function() { |
584 | }); | 658 | }); |
585 | 659 | ||
586 | test('downloads the next segment if the buffer is getting low', function() { | 660 | test('downloads the next segment if the buffer is getting low', function() { |
587 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 661 | player.src({ |
662 | src: 'manifest/media.m3u8', | ||
663 | type: 'application/vnd.apple.mpegurl' | ||
664 | }); | ||
588 | player.hls.mediaSource.trigger({ | 665 | player.hls.mediaSource.trigger({ |
589 | type: 'sourceopen' | 666 | type: 'sourceopen' |
590 | }); | 667 | }); |
... | @@ -612,7 +689,10 @@ test('downloads the next segment if the buffer is getting low', function() { | ... | @@ -612,7 +689,10 @@ test('downloads the next segment if the buffer is getting low', function() { |
612 | }); | 689 | }); |
613 | 690 | ||
614 | test('stops downloading segments at the end of the playlist', function() { | 691 | test('stops downloading segments at the end of the playlist', function() { |
615 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 692 | player.src({ |
693 | src: 'manifest/media.m3u8', | ||
694 | type: 'application/vnd.apple.mpegurl' | ||
695 | }); | ||
616 | player.hls.mediaSource.trigger({ | 696 | player.hls.mediaSource.trigger({ |
617 | type: 'sourceopen' | 697 | type: 'sourceopen' |
618 | }); | 698 | }); |
... | @@ -626,7 +706,10 @@ test('stops downloading segments at the end of the playlist', function() { | ... | @@ -626,7 +706,10 @@ test('stops downloading segments at the end of the playlist', function() { |
626 | 706 | ||
627 | test('only makes one segment request at a time', function() { | 707 | test('only makes one segment request at a time', function() { |
628 | var openedXhrs = 0; | 708 | var openedXhrs = 0; |
629 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 709 | player.src({ |
710 | src: 'manifest/media.m3u8', | ||
711 | type: 'application/vnd.apple.mpegurl' | ||
712 | }); | ||
630 | player.hls.mediaSource.trigger({ | 713 | player.hls.mediaSource.trigger({ |
631 | type: 'sourceopen' | 714 | type: 'sourceopen' |
632 | }); | 715 | }); |
... | @@ -650,7 +733,10 @@ test('only makes one segment request at a time', function() { | ... | @@ -650,7 +733,10 @@ test('only makes one segment request at a time', function() { |
650 | }); | 733 | }); |
651 | 734 | ||
652 | test('cancels outstanding XHRs when seeking', function() { | 735 | test('cancels outstanding XHRs when seeking', function() { |
653 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 736 | player.src({ |
737 | src: 'manifest/media.m3u8', | ||
738 | type: 'application/vnd.apple.mpegurl' | ||
739 | }); | ||
654 | player.hls.mediaSource.trigger({ | 740 | player.hls.mediaSource.trigger({ |
655 | type: 'sourceopen' | 741 | type: 'sourceopen' |
656 | }); | 742 | }); |
... | @@ -688,7 +774,10 @@ test('flushes the parser after each segment', function() { | ... | @@ -688,7 +774,10 @@ test('flushes the parser after each segment', function() { |
688 | this.tagsAvailable = function() {}; | 774 | this.tagsAvailable = function() {}; |
689 | }; | 775 | }; |
690 | 776 | ||
691 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 777 | player.src({ |
778 | src: 'manifest/media.m3u8', | ||
779 | type: 'application/vnd.apple.mpegurl' | ||
780 | }); | ||
692 | player.hls.mediaSource.trigger({ | 781 | player.hls.mediaSource.trigger({ |
693 | type: 'sourceopen' | 782 | type: 'sourceopen' |
694 | }); | 783 | }); |
... | @@ -720,7 +809,10 @@ test('drops tags before the target timestamp when seeking', function() { | ... | @@ -720,7 +809,10 @@ test('drops tags before the target timestamp when seeking', function() { |
720 | // push a tag into the buffer | 809 | // push a tag into the buffer |
721 | tags.push({ pts: 0, bytes: 0 }); | 810 | tags.push({ pts: 0, bytes: 0 }); |
722 | 811 | ||
723 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 812 | player.src({ |
813 | src: 'manifest/media.m3u8', | ||
814 | type: 'application/vnd.apple.mpegurl' | ||
815 | }); | ||
724 | player.hls.mediaSource.trigger({ | 816 | player.hls.mediaSource.trigger({ |
725 | type: 'sourceopen' | 817 | type: 'sourceopen' |
726 | }); | 818 | }); |
... | @@ -774,7 +866,10 @@ test('clears pending buffer updates when seeking', function() { | ... | @@ -774,7 +866,10 @@ test('clears pending buffer updates when seeking', function() { |
774 | }; | 866 | }; |
775 | 867 | ||
776 | // queue up a tag to be pushed into the buffer (but don't push it yet!) | 868 | // queue up a tag to be pushed into the buffer (but don't push it yet!) |
777 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 869 | player.src({ |
870 | src: 'manifest/media.m3u8', | ||
871 | type: 'application/vnd.apple.mpegurl' | ||
872 | }); | ||
778 | player.hls.mediaSource.trigger({ | 873 | player.hls.mediaSource.trigger({ |
779 | type: 'sourceopen' | 874 | type: 'sourceopen' |
780 | }); | 875 | }); |
... | @@ -802,7 +897,10 @@ test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { | ... | @@ -802,7 +897,10 @@ test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { |
802 | player.on('error', function() { | 897 | player.on('error', function() { |
803 | errorTriggered = true; | 898 | errorTriggered = true; |
804 | }); | 899 | }); |
805 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 900 | player.src({ |
901 | src: 'manifest/media.m3u8', | ||
902 | type: 'application/vnd.apple.mpegurl' | ||
903 | }); | ||
806 | player.hls.mediaSource.trigger({ | 904 | player.hls.mediaSource.trigger({ |
807 | type: 'sourceopen' | 905 | type: 'sourceopen' |
808 | }); | 906 | }); |
... | @@ -818,7 +916,10 @@ test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { | ... | @@ -818,7 +916,10 @@ test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { |
818 | }); | 916 | }); |
819 | 917 | ||
820 | test('segment 404 should trigger MEDIA_ERR_NETWORK', function () { | 918 | test('segment 404 should trigger MEDIA_ERR_NETWORK', function () { |
821 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 919 | player.src({ |
920 | src: 'manifest/media.m3u8', | ||
921 | type: 'application/vnd.apple.mpegurl' | ||
922 | }); | ||
822 | 923 | ||
823 | player.hls.mediaSource.trigger({ | 924 | player.hls.mediaSource.trigger({ |
824 | type: 'sourceopen' | 925 | type: 'sourceopen' |
... | @@ -831,7 +932,10 @@ test('segment 404 should trigger MEDIA_ERR_NETWORK', function () { | ... | @@ -831,7 +932,10 @@ test('segment 404 should trigger MEDIA_ERR_NETWORK', function () { |
831 | }); | 932 | }); |
832 | 933 | ||
833 | test('segment 500 should trigger MEDIA_ERR_ABORTED', function () { | 934 | test('segment 500 should trigger MEDIA_ERR_ABORTED', function () { |
834 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 935 | player.src({ |
936 | src: 'manifest/media.m3u8', | ||
937 | type: 'application/vnd.apple.mpegurl' | ||
938 | }); | ||
835 | 939 | ||
836 | player.hls.mediaSource.trigger({ | 940 | player.hls.mediaSource.trigger({ |
837 | type: 'sourceopen' | 941 | type: 'sourceopen' |
... | @@ -845,14 +949,20 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () { | ... | @@ -845,14 +949,20 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () { |
845 | 949 | ||
846 | test('has no effect if native HLS is available', function() { | 950 | test('has no effect if native HLS is available', function() { |
847 | videojs.Hls.supportsNativeHls = true; | 951 | videojs.Hls.supportsNativeHls = true; |
848 | player.src({src: 'http://example.com/manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 952 | player.src({ |
953 | src: 'http://example.com/manifest/master.m3u8', | ||
954 | type: 'application/vnd.apple.mpegurl' | ||
955 | }); | ||
849 | 956 | ||
850 | ok(!(player.currentSrc() in videojs.mediaSources), | 957 | ok(!(player.currentSrc() in videojs.mediaSources), |
851 | 'no media source was opened'); | 958 | 'no media source was opened'); |
852 | }); | 959 | }); |
853 | 960 | ||
854 | test('duration is Infinity for live playlists', function() { | 961 | test('duration is Infinity for live playlists', function() { |
855 | player.src({src: 'http://example.com/manifest/missingEndlist.m3u8', type: 'application/vnd.apple.mpegurl'}); | 962 | player.src({ |
963 | src: 'http://example.com/manifest/missingEndlist.m3u8', | ||
964 | type: 'application/vnd.apple.mpegurl' | ||
965 | }); | ||
856 | player.hls.mediaSource.trigger({ | 966 | player.hls.mediaSource.trigger({ |
857 | type: 'sourceopen' | 967 | type: 'sourceopen' |
858 | }); | 968 | }); |
... | @@ -868,7 +978,10 @@ test('does not reload playlists with an endlist tag', function() { | ... | @@ -868,7 +978,10 @@ test('does not reload playlists with an endlist tag', function() { |
868 | window.setTimeout = function(callback, timeout) { | 978 | window.setTimeout = function(callback, timeout) { |
869 | callbacks.push({ callback: callback, timeout: timeout }); | 979 | callbacks.push({ callback: callback, timeout: timeout }); |
870 | }; | 980 | }; |
871 | player.src({src: 'manifest/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | 981 | player.src({ |
982 | src: 'manifest/media.m3u8', | ||
983 | type: 'application/vnd.apple.mpegurl' | ||
984 | }); | ||
872 | player.hls.mediaSource.trigger({ | 985 | player.hls.mediaSource.trigger({ |
873 | type: 'sourceopen' | 986 | type: 'sourceopen' |
874 | }); | 987 | }); |
... | @@ -877,7 +990,10 @@ test('does not reload playlists with an endlist tag', function() { | ... | @@ -877,7 +990,10 @@ test('does not reload playlists with an endlist tag', function() { |
877 | }); | 990 | }); |
878 | 991 | ||
879 | test('updates the media index when a playlist reloads', function() { | 992 | test('updates the media index when a playlist reloads', function() { |
880 | player.src({src: 'http://example.com/live-updating.m3u8', type: 'application/vnd.apple.mpegurl'}); | 993 | player.src({ |
994 | src: 'http://example.com/live-updating.m3u8', | ||
995 | type: 'application/vnd.apple.mpegurl' | ||
996 | }); | ||
881 | player.hls.mediaSource.trigger({ | 997 | player.hls.mediaSource.trigger({ |
882 | type: 'sourceopen' | 998 | type: 'sourceopen' |
883 | }); | 999 | }); |
... | @@ -920,7 +1036,10 @@ test('mediaIndex is zero before the first segment loads', function() { | ... | @@ -920,7 +1036,10 @@ test('mediaIndex is zero before the first segment loads', function() { |
920 | this.open = function() {}; | 1036 | this.open = function() {}; |
921 | this.send = function() {}; | 1037 | this.send = function() {}; |
922 | }; | 1038 | }; |
923 | player.src({src: 'http://example.com/first-seg-load.m3u8', type: 'application/vnd.apple.mpegurl'}); | 1039 | player.src({ |
1040 | src: 'http://example.com/first-seg-load.m3u8', | ||
1041 | type: 'application/vnd.apple.mpegurl' | ||
1042 | }); | ||
924 | player.hls.mediaSource.trigger({ | 1043 | player.hls.mediaSource.trigger({ |
925 | type: 'sourceopen' | 1044 | type: 'sourceopen' |
926 | }); | 1045 | }); |
... | @@ -929,7 +1048,10 @@ test('mediaIndex is zero before the first segment loads', function() { | ... | @@ -929,7 +1048,10 @@ test('mediaIndex is zero before the first segment loads', function() { |
929 | }); | 1048 | }); |
930 | 1049 | ||
931 | test('reloads out-of-date live playlists when switching variants', function() { | 1050 | test('reloads out-of-date live playlists when switching variants', function() { |
932 | player.src({src: 'http://example.com/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 1051 | player.src({ |
1052 | src: 'http://example.com/master.m3u8', | ||
1053 | type: 'application/vnd.apple.mpegurl' | ||
1054 | }); | ||
933 | player.hls.mediaSource.trigger({ | 1055 | player.hls.mediaSource.trigger({ |
934 | type: 'sourceopen' | 1056 | type: 'sourceopen' |
935 | }); | 1057 | }); |
... | @@ -970,40 +1092,38 @@ test('does not reload master playlists', function() { | ... | @@ -970,40 +1092,38 @@ test('does not reload master playlists', function() { |
970 | callbacks.push(callback); | 1092 | callbacks.push(callback); |
971 | }; | 1093 | }; |
972 | 1094 | ||
973 | player.src({src: 'http://example.com/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 1095 | player.src({ |
1096 | src: 'http://example.com/master.m3u8', | ||
1097 | type: 'application/vnd.apple.mpegurl' | ||
1098 | }); | ||
974 | player.hls.mediaSource.trigger({ | 1099 | player.hls.mediaSource.trigger({ |
975 | type: 'sourceopen' | 1100 | type: 'sourceopen' |
976 | }); | 1101 | }); |
977 | 1102 | ||
978 | strictEqual(callbacks.length, 0, 'no reload scheduled'); | 1103 | strictEqual(callbacks.length, |
1104 | 0, 'no reload scheduled'); | ||
979 | }); | 1105 | }); |
980 | 1106 | ||
981 | test('if withCredentials option is used, withCredentials is set on the XHR object', function() { | 1107 | test('if withCredentials option is used, withCredentials is set on the XHR object', function() { |
982 | stop(); | ||
983 | player.dispose(); | 1108 | player.dispose(); |
984 | var video = document.createElement('video'); | 1109 | player = createPlayer({ |
985 | 1110 | withCredentials: true | |
986 | document.querySelector('#qunit-fixture').appendChild(video); | 1111 | }); |
987 | player = videojs(video, { | 1112 | player.src({ |
988 | flash: { | 1113 | src: 'http://example.com/media.m3u8', |
989 | swf: '../node_modules/video.js/dist/video-js/video-js.swf' | 1114 | type: 'application/vnd.apple.mpegurl' |
990 | }, | ||
991 | hls: { | ||
992 | withCredentials: true | ||
993 | }, | ||
994 | techOrder: ['hls'] | ||
995 | }, function() { | ||
996 | player.src({src: 'http://example.com/media.m3u8', type: 'application/vnd.apple.mpegurl'}); | ||
997 | player.hls.mediaSource.trigger({ | ||
998 | type: 'sourceopen' | ||
999 | }); | ||
1000 | ok(requests[0].withCredentials, "with credentials should be set to true if that option is passed in"); | ||
1001 | start(); | ||
1002 | }); | 1115 | }); |
1116 | player.hls.mediaSource.trigger({ | ||
1117 | type: 'sourceopen' | ||
1118 | }); | ||
1119 | ok(requests[0].withCredentials, "with credentials should be set to true if that option is passed in"); | ||
1003 | }); | 1120 | }); |
1004 | 1121 | ||
1005 | test('does not break if the playlist has no segments', function() { | 1122 | test('does not break if the playlist has no segments', function() { |
1006 | player.src({src: 'manifest/master.m3u8', type: 'application/vnd.apple.mpegurl'}); | 1123 | player.src({ |
1124 | src: 'manifest/master.m3u8', | ||
1125 | type: 'application/vnd.apple.mpegurl' | ||
1126 | }); | ||
1007 | try { | 1127 | try { |
1008 | player.hls.mediaSource.trigger({ | 1128 | player.hls.mediaSource.trigger({ |
1009 | type: 'sourceopen' | 1129 | type: 'sourceopen' | ... | ... |
-
Please register or sign in to post a comment