updated 404/500 tests. console log cleanup.
Showing
2 changed files
with
41 additions
and
15 deletions
... | @@ -186,10 +186,6 @@ var | ... | @@ -186,10 +186,6 @@ var |
186 | }); | 186 | }); |
187 | 187 | ||
188 | player.on('error', function() { | 188 | player.on('error', function() { |
189 | if(player.error) | ||
190 | { | ||
191 | console.log(player.error.message); | ||
192 | } | ||
193 | 189 | ||
194 | }); | 190 | }); |
195 | 191 | ||
... | @@ -377,7 +373,6 @@ var | ... | @@ -377,7 +373,6 @@ var |
377 | 373 | ||
378 | if (this.readyState === 4) { | 374 | if (this.readyState === 4) { |
379 | if (this.status >= 400) { | 375 | if (this.status >= 400) { |
380 | console.log('index', player.hls.mediaIndex, player.hls.media.segments.length); | ||
381 | if(player.hls.mediaIndex<player.hls.media.segments.length-1) | 376 | if(player.hls.mediaIndex<player.hls.media.segments.length-1) |
382 | { | 377 | { |
383 | player.hls.mediaIndex++; | 378 | player.hls.mediaIndex++; | ... | ... |
... | @@ -547,7 +547,7 @@ test('gets the correct PTS on seek', function() { | ... | @@ -547,7 +547,7 @@ test('gets the correct PTS on seek', function() { |
547 | ok(ptsByTime<=seekTime, 'PTS should be less than or equal to seek time'); | 547 | ok(ptsByTime<=seekTime, 'PTS should be less than or equal to seek time'); |
548 | }); | 548 | }); |
549 | 549 | ||
550 | test('missing playlist should trigger error', function() { | 550 | test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { |
551 | var errorTriggered = false; | 551 | var errorTriggered = false; |
552 | 552 | ||
553 | window.XMLHttpRequest = function() { | 553 | window.XMLHttpRequest = function() { |
... | @@ -564,9 +564,7 @@ test('missing playlist should trigger error', function() { | ... | @@ -564,9 +564,7 @@ test('missing playlist should trigger error', function() { |
564 | player.hls('manifest/media.m3u8'); | 564 | player.hls('manifest/media.m3u8'); |
565 | 565 | ||
566 | player.on('error', function() { | 566 | player.on('error', function() { |
567 | if (player.error.code === 2) { | ||
568 | errorTriggered = true; | 567 | errorTriggered = true; |
569 | } | ||
570 | }); | 568 | }); |
571 | 569 | ||
572 | videojs.mediaSources[player.currentSrc()].trigger({ | 570 | videojs.mediaSources[player.currentSrc()].trigger({ |
... | @@ -574,19 +572,21 @@ test('missing playlist should trigger error', function() { | ... | @@ -574,19 +572,21 @@ test('missing playlist should trigger error', function() { |
574 | }); | 572 | }); |
575 | 573 | ||
576 | equal(true, errorTriggered, 'Missing Playlist error event should trigger'); | 574 | equal(true, errorTriggered, 'Missing Playlist error event should trigger'); |
575 | equal(2, player.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_NETWORK'); | ||
576 | equal('hls-missing-playlist', player.error.type, 'Player error type should inform user correctly'); | ||
577 | }); | 577 | }); |
578 | 578 | ||
579 | test('missing segment should trigger error', function() { | 579 | test('segment 404 should trigger MEDIA_ERR_NETWORK', function () { |
580 | var errorTriggered = false; | 580 | var errorTriggered = false; |
581 | 581 | ||
582 | player.hls('manifest/media.m3u8'); | 582 | player.hls('manifest/media.m3u8'); |
583 | 583 | ||
584 | player.on('loadedmanifest', function() { | 584 | player.on('loadedmanifest', function () { |
585 | window.XMLHttpRequest = function() { | 585 | window.XMLHttpRequest = function () { |
586 | this.open = function(method, url) { | 586 | this.open = function (method, url) { |
587 | xhrUrls.push(url); | 587 | xhrUrls.push(url); |
588 | }; | 588 | }; |
589 | this.send = function() { | 589 | this.send = function () { |
590 | this.readyState = 4; | 590 | this.readyState = 4; |
591 | this.status = 404; | 591 | this.status = 404; |
592 | this.onreadystatechange(); | 592 | this.onreadystatechange(); |
... | @@ -595,9 +595,7 @@ test('missing segment should trigger error', function() { | ... | @@ -595,9 +595,7 @@ test('missing segment should trigger error', function() { |
595 | }); | 595 | }); |
596 | 596 | ||
597 | player.on('error', function () { | 597 | player.on('error', function () { |
598 | if (player.error.code === 2) { | ||
599 | errorTriggered = true; | 598 | errorTriggered = true; |
600 | } | ||
601 | }); | 599 | }); |
602 | 600 | ||
603 | videojs.mediaSources[player.currentSrc()].trigger({ | 601 | videojs.mediaSources[player.currentSrc()].trigger({ |
... | @@ -605,6 +603,39 @@ test('missing segment should trigger error', function() { | ... | @@ -605,6 +603,39 @@ test('missing segment should trigger error', function() { |
605 | }); | 603 | }); |
606 | 604 | ||
607 | equal(true, errorTriggered, 'Missing Segment error event should trigger'); | 605 | equal(true, errorTriggered, 'Missing Segment error event should trigger'); |
606 | equal(2, player.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_NETWORK'); | ||
607 | equal('hls-missing-segment', player.error.type, 'Player error type should inform user correctly'); | ||
608 | }); | ||
609 | |||
610 | test('segment 500 should trigger MEDIA_ERR_ABORTED', function () { | ||
611 | var errorTriggered = false; | ||
612 | |||
613 | player.hls('manifest/media.m3u8'); | ||
614 | |||
615 | player.on('loadedmanifest', function () { | ||
616 | window.XMLHttpRequest = function () { | ||
617 | this.open = function (method, url) { | ||
618 | xhrUrls.push(url); | ||
619 | }; | ||
620 | this.send = function () { | ||
621 | this.readyState = 4; | ||
622 | this.status = 500; | ||
623 | this.onreadystatechange(); | ||
624 | }; | ||
625 | }; | ||
626 | }); | ||
627 | |||
628 | player.on('error', function () { | ||
629 | errorTriggered = true; | ||
630 | }); | ||
631 | |||
632 | videojs.mediaSources[player.currentSrc()].trigger({ | ||
633 | type: 'sourceopen' | ||
634 | }); | ||
635 | |||
636 | equal(true, errorTriggered, 'Missing Segment error event should trigger'); | ||
637 | equal(4, player.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_ABORTED'); | ||
638 | equal('hls-missing-segment', player.error.type, 'Player error type should inform user correctly'); | ||
608 | }); | 639 | }); |
609 | 640 | ||
610 | module('segment controller', { | 641 | module('segment controller', { | ... | ... |
-
Please register or sign in to post a comment