8c74b8e2 by Lee Whitaker

Clean up aborts better.

1 parent 7add9298
...@@ -118,7 +118,9 @@ ...@@ -118,7 +118,9 @@
118 */ 118 */
119 loader.dispose = function() { 119 loader.dispose = function() {
120 if (request) { 120 if (request) {
121 request.onreadystatechange = null;
121 request.abort(); 122 request.abort();
123 request = null;
122 } 124 }
123 window.clearTimeout(mediaUpdateTimeout); 125 window.clearTimeout(mediaUpdateTimeout);
124 dispose.call(this); 126 dispose.call(this);
...@@ -161,6 +163,7 @@ ...@@ -161,6 +163,7 @@
161 if (loader.master.playlists[playlist.uri].endList) { 163 if (loader.master.playlists[playlist.uri].endList) {
162 // abort outstanding playlist requests 164 // abort outstanding playlist requests
163 if (request) { 165 if (request) {
166 request.onreadystatechange = null;
164 request.abort(); 167 request.abort();
165 request = null; 168 request = null;
166 } 169 }
...@@ -188,6 +191,7 @@ ...@@ -188,6 +191,7 @@
188 // has no effect after the first 191 // has no effect after the first
189 return; 192 return;
190 } 193 }
194 request.onreadystatechange = null;
191 request.abort(); 195 request.abort();
192 request = null; 196 request = null;
193 } 197 }
......
...@@ -331,6 +331,7 @@ ...@@ -331,6 +331,7 @@
331 clock.tick(10 * 1000); 331 clock.tick(10 * 1000);
332 loader.media('high.m3u8'); 332 loader.media('high.m3u8');
333 strictEqual(requests[0].aborted, true, 'aborted refresh request'); 333 strictEqual(requests[0].aborted, true, 'aborted refresh request');
334 ok(!requests[0].onreadystatechange, 'onreadystatechange handlers should be removed on abort');
334 strictEqual(loader.state, 'SWITCHING_MEDIA', 'updated the state'); 335 strictEqual(loader.state, 'SWITCHING_MEDIA', 'updated the state');
335 }); 336 });
336 337
...@@ -417,6 +418,7 @@ ...@@ -417,6 +418,7 @@
417 418
418 strictEqual(requests.length, 1, 'requested high playlist'); 419 strictEqual(requests.length, 1, 'requested high playlist');
419 ok(requests[0].aborted, 'aborted playlist request'); 420 ok(requests[0].aborted, 'aborted playlist request');
421 ok(!requests[0].onreadystatechange, 'onreadystatechange handlers should be removed on abort');
420 strictEqual(loader.state, 'HAVE_METADATA', 'returned to loaded playlist'); 422 strictEqual(loader.state, 'HAVE_METADATA', 'returned to loaded playlist');
421 strictEqual(loader.media(), loader.master.playlists[0], 'switched to loaded playlist'); 423 strictEqual(loader.media(), loader.master.playlists[0], 'switched to loaded playlist');
422 }); 424 });
...@@ -498,6 +500,7 @@ ...@@ -498,6 +500,7 @@
498 500
499 loader.dispose(); 501 loader.dispose();
500 ok(requests[0].aborted, 'refresh request aborted'); 502 ok(requests[0].aborted, 'refresh request aborted');
503 ok(!requests[0].onreadystatechange, 'onreadystatechange handler should not exist after dispose called');
501 }); 504 });
502 505
503 test('errors if requests take longer than 45s', function() { 506 test('errors if requests take longer than 45s', function() {
......