b2f8fdc9 by Gary Katsevman

Add sinon to jshintrc. Fix jshint errors.

Also, remove resetting setTimeout as it's already being done in
setup/teardown.
1 parent 2a6b1234
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
26 "notDeepEqual", 26 "notDeepEqual",
27 "strictEqual", 27 "strictEqual",
28 "notStrictEqual", 28 "notStrictEqual",
29 "throws" 29 "throws",
30 "sinon"
30 ] 31 ]
31 } 32 }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
23 var 23 var
24 player, 24 player,
25 oldFlashSupported, 25 oldFlashSupported,
26 oldXhr,
27 oldSegmentParser, 26 oldSegmentParser,
28 oldSetTimeout, 27 oldSetTimeout,
29 oldSourceBuffer, 28 oldSourceBuffer,
...@@ -33,7 +32,9 @@ var ...@@ -33,7 +32,9 @@ var
33 xhr, 32 xhr,
34 33
35 standardXHRResponse = function(request) { 34 standardXHRResponse = function(request) {
36 if (!request.url) return; 35 if (!request.url) {
36 return;
37 }
37 38
38 var contentType = "application/json", 39 var contentType = "application/json",
39 // contents off the global object 40 // contents off the global object
...@@ -42,7 +43,7 @@ var ...@@ -42,7 +43,7 @@ var
42 if (manifestName) { 43 if (manifestName) {
43 manifestName = manifestName[1]; 44 manifestName = manifestName[1];
44 } else { 45 } else {
45 request.url; 46 manifestName = request.url;
46 } 47 }
47 48
48 if (/\.m3u8?/.test(request.url)) { 49 if (/\.m3u8?/.test(request.url)) {
...@@ -54,7 +55,7 @@ var ...@@ -54,7 +55,7 @@ var
54 request.response = new Uint8Array([1]).buffer; 55 request.response = new Uint8Array([1]).buffer;
55 request.respond(200, 56 request.respond(200,
56 {'Content-Type': contentType}, 57 {'Content-Type': contentType},
57 window.manifests[manifestName || request.url]); 58 window.manifests[manifestName]);
58 }, 59 },
59 60
60 mockSegmentParser = function(tags) { 61 mockSegmentParser = function(tags) {
...@@ -704,9 +705,6 @@ test('activates if the first playable source is HLS', function() { ...@@ -704,9 +705,6 @@ test('activates if the first playable source is HLS', function() {
704 }); 705 });
705 706
706 test('cancels outstanding XHRs when seeking', function() { 707 test('cancels outstanding XHRs when seeking', function() {
707 var
708 aborted = false,
709 opened = 0;
710 player.hls('manifest/media.m3u8'); 708 player.hls('manifest/media.m3u8');
711 videojs.mediaSources[player.currentSrc()].trigger({ 709 videojs.mediaSources[player.currentSrc()].trigger({
712 type: 'sourceopen' 710 type: 'sourceopen'
...@@ -724,7 +722,6 @@ test('cancels outstanding XHRs when seeking', function() { ...@@ -724,7 +722,6 @@ test('cancels outstanding XHRs when seeking', function() {
724 722
725 // trigger a segment download request 723 // trigger a segment download request
726 player.trigger('timeupdate'); 724 player.trigger('timeupdate');
727 opened = 0;
728 // attempt to seek while the download is in progress 725 // attempt to seek while the download is in progress
729 player.trigger('seeking'); 726 player.trigger('seeking');
730 727
...@@ -757,12 +754,10 @@ test('flushes the parser after each segment', function() { ...@@ -757,12 +754,10 @@ test('flushes the parser after each segment', function() {
757 }); 754 });
758 755
759 test('drops tags before the target timestamp when seeking', function() { 756 test('drops tags before the target timestamp when seeking', function() {
760 var 757 var i = 10,
761 i = 10,
762 callbacks = [], 758 callbacks = [],
763 tags = [], 759 tags = [],
764 bytes = [], 760 bytes = [];
765 oldSetTimeout = window.setTimeout;
766 761
767 // mock out the parser and source buffer 762 // mock out the parser and source buffer
768 videojs.hls.SegmentParser = mockSegmentParser(tags); 763 videojs.hls.SegmentParser = mockSegmentParser(tags);
...@@ -808,15 +803,12 @@ test('drops tags before the target timestamp when seeking', function() { ...@@ -808,15 +803,12 @@ test('drops tags before the target timestamp when seeking', function() {
808 } 803 }
809 804
810 deepEqual(bytes, [7,8,9], 'three tags are appended'); 805 deepEqual(bytes, [7,8,9], 'three tags are appended');
811 window.setTimeout = oldSetTimeout;
812 }); 806 });
813 807
814 test('clears pending buffer updates when seeking', function() { 808 test('clears pending buffer updates when seeking', function() {
815 var 809 var bytes = [],
816 bytes = [],
817 callbacks = [], 810 callbacks = [],
818 tags = [{ pts: 0, bytes: 0 }], 811 tags = [{ pts: 0, bytes: 0 }];
819 oldSetTimeout = window.setTimeout;
820 812
821 // mock out the parser and source buffer 813 // mock out the parser and source buffer
822 videojs.hls.SegmentParser = mockSegmentParser(tags); 814 videojs.hls.SegmentParser = mockSegmentParser(tags);
...@@ -852,7 +844,6 @@ test('clears pending buffer updates when seeking', function() { ...@@ -852,7 +844,6 @@ test('clears pending buffer updates when seeking', function() {
852 } 844 }
853 845
854 deepEqual(bytes, ['flv', 7], 'tags queued to be appended should be cancelled'); 846 deepEqual(bytes, ['flv', 7], 'tags queued to be appended should be cancelled');
855 window.setTimeout = oldSetTimeout;
856 }); 847 });
857 848
858 test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { 849 test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() {
...@@ -919,8 +910,7 @@ test('has no effect if native HLS is available', function() { ...@@ -919,8 +910,7 @@ test('has no effect if native HLS is available', function() {
919 }); 910 });
920 911
921 test('reloads live playlists', function() { 912 test('reloads live playlists', function() {
922 var callbacks = [], 913 var callbacks = [];
923 oldSetTimeout = window.setTimeout;
924 // capture timeouts 914 // capture timeouts
925 window.setTimeout = function(callback, timeout) { 915 window.setTimeout = function(callback, timeout) {
926 callbacks.push({ callback: callback, timeout: timeout }); 916 callbacks.push({ callback: callback, timeout: timeout });
...@@ -935,7 +925,6 @@ test('reloads live playlists', function() { ...@@ -935,7 +925,6 @@ test('reloads live playlists', function() {
935 strictEqual(player.hls.media.targetDuration * 1000, 925 strictEqual(player.hls.media.targetDuration * 1000,
936 callbacks[0].timeout, 926 callbacks[0].timeout,
937 'waited one target duration'); 927 'waited one target duration');
938 window.setTimeout = oldSetTimeout;
939 }); 928 });
940 929
941 test('duration is Infinity for live playlists', function() { 930 test('duration is Infinity for live playlists', function() {
...@@ -965,8 +954,7 @@ test('does not reload playlists with an endlist tag', function() { ...@@ -965,8 +954,7 @@ test('does not reload playlists with an endlist tag', function() {
965 954
966 test('reloads a live playlist after half a target duration if it has not ' + 955 test('reloads a live playlist after half a target duration if it has not ' +
967 'changed since the last request', function() { 956 'changed since the last request', function() {
968 var callbacks = [], 957 var callbacks = [];
969 oldSetTimeout = window.setTimeout;
970 // capture timeouts 958 // capture timeouts
971 window.setTimeout = function(callback, timeout) { 959 window.setTimeout = function(callback, timeout) {
972 callbacks.push({ callback: callback, timeout: timeout }); 960 callbacks.push({ callback: callback, timeout: timeout });
...@@ -986,14 +974,11 @@ test('reloads a live playlist after half a target duration if it has not ' + ...@@ -986,14 +974,11 @@ test('reloads a live playlist after half a target duration if it has not ' +
986 strictEqual(callbacks[0].timeout, 974 strictEqual(callbacks[0].timeout,
987 player.hls.media.targetDuration / 2 * 1000, 975 player.hls.media.targetDuration / 2 * 1000,
988 'waited half a target duration'); 976 'waited half a target duration');
989 window.setTimeout = oldSetTimeout;
990 }); 977 });
991 978
992 test('merges playlist reloads', function() { 979 test('merges playlist reloads', function() {
993 var 980 var oldPlaylist,
994 oldPlaylist, 981 callback;
995 callback,
996 oldSetTimeout = window.setTimeout;
997 982
998 // capture timeouts 983 // capture timeouts
999 window.setTimeout = function(cb) { 984 window.setTimeout = function(cb) {
...@@ -1011,12 +996,10 @@ test('merges playlist reloads', function() { ...@@ -1011,12 +996,10 @@ test('merges playlist reloads', function() {
1011 callback(); 996 callback();
1012 standardXHRResponse(requests[2]); 997 standardXHRResponse(requests[2]);
1013 ok(oldPlaylist !== player.hls.media, 'player.hls.media was updated'); 998 ok(oldPlaylist !== player.hls.media, 'player.hls.media was updated');
1014 window.setTimeout = oldSetTimeout;
1015 }); 999 });
1016 1000
1017 test('updates the media index when a playlist reloads', function() { 1001 test('updates the media index when a playlist reloads', function() {
1018 var callback, 1002 var callback;
1019 oldSetTimeout = window.setTimeout;
1020 window.setTimeout = function(cb) { 1003 window.setTimeout = function(cb) {
1021 callback = cb; 1004 callback = cb;
1022 }; 1005 };
...@@ -1053,7 +1036,6 @@ test('updates the media index when a playlist reloads', function() { ...@@ -1053,7 +1036,6 @@ test('updates the media index when a playlist reloads', function() {
1053 standardXHRResponse(requests[2]); 1036 standardXHRResponse(requests[2]);
1054 1037
1055 strictEqual(player.hls.mediaIndex, 2, 'mediaIndex is updated after the reload'); 1038 strictEqual(player.hls.mediaIndex, 2, 'mediaIndex is updated after the reload');
1056 window.setTimeout = oldSetTimeout;
1057 }); 1039 });
1058 1040
1059 test('mediaIndex is zero before the first segment loads', function() { 1041 test('mediaIndex is zero before the first segment loads', function() {
...@@ -1127,7 +1109,6 @@ test('only reloads the active media playlist', function() { ...@@ -1127,7 +1109,6 @@ test('only reloads the active media playlist', function() {
1127 var callbacks = [], 1109 var callbacks = [],
1128 i = 0, 1110 i = 0,
1129 filteredRequests = [], 1111 filteredRequests = [],
1130 oldSetTimeout = window.setTimeout,
1131 customResponse; 1112 customResponse;
1132 1113
1133 customResponse = function(request) { 1114 customResponse = function(request) {
...@@ -1177,7 +1158,6 @@ test('only reloads the active media playlist', function() { ...@@ -1177,7 +1158,6 @@ test('only reloads the active media playlist', function() {
1177 'http://example.com/switched.m3u8', 1158 'http://example.com/switched.m3u8',
1178 'refreshed the active playlist'); 1159 'refreshed the active playlist');
1179 1160
1180 window.setTimeout = oldSetTimeout;
1181 }); 1161 });
1182 1162
1183 })(window, window.videojs); 1163 })(window, window.videojs);
......