Added tests for xhr timeouts
Showing
1 changed file
with
20 additions
and
0 deletions
... | @@ -145,6 +145,9 @@ module('HLS', { | ... | @@ -145,6 +145,9 @@ module('HLS', { |
145 | xhr = sinon.useFakeXMLHttpRequest(); | 145 | xhr = sinon.useFakeXMLHttpRequest(); |
146 | requests = []; | 146 | requests = []; |
147 | xhr.onCreate = function(xhr) { | 147 | xhr.onCreate = function(xhr) { |
148 | // we set this here since sinon doesn't | ||
149 | // it is needed to force ontimeout usage | ||
150 | xhr.timeout = 0; | ||
148 | requests.push(xhr); | 151 | requests.push(xhr); |
149 | }; | 152 | }; |
150 | 153 | ||
... | @@ -1108,6 +1111,23 @@ test('resets the switching algorithm if a request times out', function() { | ... | @@ -1108,6 +1111,23 @@ test('resets the switching algorithm if a request times out', function() { |
1108 | 'reset to the lowest bitrate playlist'); | 1111 | 'reset to the lowest bitrate playlist'); |
1109 | }); | 1112 | }); |
1110 | 1113 | ||
1114 | asyncTest('handles xhr timeouts correctly', function (assert) { | ||
1115 | var testTimeout = setTimeout(function() { | ||
1116 | // since we are faking xhr, the test will hang if we don't | ||
1117 | // manually end it (ontimeout will never be called) | ||
1118 | ok(false, 'request was not completed'); | ||
1119 | start(); | ||
1120 | }, 10 * 1000); | ||
1121 | videojs.Hls.xhr({ | ||
1122 | url: 'http://google.com:81', | ||
1123 | timeout: 1 | ||
1124 | }, function(error, url) { | ||
1125 | assert.strictEqual(error, 'timeout', 'called with timeout error'); | ||
1126 | clearTimeout(testTimeout); | ||
1127 | start(); | ||
1128 | }); | ||
1129 | }); | ||
1130 | |||
1111 | test('disposes the playlist loader', function() { | 1131 | test('disposes the playlist loader', function() { |
1112 | var disposes = 0, player, loaderDispose; | 1132 | var disposes = 0, player, loaderDispose; |
1113 | player = createPlayer(); | 1133 | player = createPlayer(); | ... | ... |
-
Please register or sign in to post a comment