4c4ebe84 by Tom Johnson

updated 404/500 tests. console log cleanup.

1 parent 0fa1bd7c
...@@ -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) { 567 errorTriggered = true;
568 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,38 @@ test('missing segment should trigger error', function() { ...@@ -595,9 +595,38 @@ 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) { 598 errorTriggered = true;
599 errorTriggered = true; 599 });
600 } 600
601 videojs.mediaSources[player.currentSrc()].trigger({
602 type: 'sourceopen'
603 });
604
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;
601 }); 630 });
602 631
603 videojs.mediaSources[player.currentSrc()].trigger({ 632 videojs.mediaSources[player.currentSrc()].trigger({
...@@ -605,6 +634,8 @@ test('missing segment should trigger error', function() { ...@@ -605,6 +634,8 @@ test('missing segment should trigger error', function() {
605 }); 634 });
606 635
607 equal(true, errorTriggered, 'Missing Segment error event should trigger'); 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', {
......