72ece371 by David LaPalomento

Run travis tests in Firefox

Fix tests so they work in Firefox without native MediaSources. Clean up a timeout properly on dispose. Update some paths on the example page.
1 parent ea13a59a
1 language: node_js 1 language: node_js
2 sudo: false
2 node_js: 3 node_js:
3 - '0.10' 4 - "stable"
4 install: 5 install:
5 - npm install -g grunt-cli && npm install 6 - npm install -g grunt-cli && npm install
6 notifications: 7 notifications:
...@@ -11,6 +12,9 @@ notifications: ...@@ -11,6 +12,9 @@ notifications:
11 channels: 12 channels:
12 - "chat.freenode.net#videojs" 13 - "chat.freenode.net#videojs"
13 use_notice: true 14 use_notice: true
15 before_script:
16 - export DISPLAY=:99.0
17 - sh -e /etc/init.d/xvfb start
14 env: 18 env:
15 global: 19 global:
16 - secure: dM7svnHPPu5IiUMeFWW5zg+iuWNpwt6SSDi3MmVvhSclNMRLesQoRB+7Qq5J/LiKhmjpv1/GlNVV0CTsHMRhZNwQ3fo38eEuTXv99aAflEITXwSEh/VntKViHbGFubn06EnVkJoH6MX3zJ6kbiwc2QdSQbywKzS6l6quUEpWpd0= 20 - secure: dM7svnHPPu5IiUMeFWW5zg+iuWNpwt6SSDi3MmVvhSclNMRLesQoRB+7Qq5J/LiKhmjpv1/GlNVV0CTsHMRhZNwQ3fo38eEuTXv99aAflEITXwSEh/VntKViHbGFubn06EnVkJoH6MX3zJ6kbiwc2QdSQbywKzS6l6quUEpWpd0=
......
...@@ -357,7 +357,7 @@ module.exports = function(grunt) { ...@@ -357,7 +357,7 @@ module.exports = function(grunt) {
357 grunt.task.run(['karma:saucelabs']); 357 grunt.task.run(['karma:saucelabs']);
358 grunt.task.run(['connect:test', 'protractor:saucelabs']); 358 grunt.task.run(['connect:test', 'protractor:saucelabs']);
359 } else { 359 } else {
360 grunt.task.run(['karma:phantomjs']); 360 grunt.task.run(['karma:firefox']);
361 } 361 }
362 } else { 362 } else {
363 if (tasks.length === 0) { 363 if (tasks.length === 0) {
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
11 11
12 <!-- transmuxing --> 12 <!-- transmuxing -->
13 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/lib/stream.js"></script> 13 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/lib/stream.js"></script>
14 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/lib/mp4-generator.js"></script>
15 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/lib/transmuxer.js"></script>
16 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/legacy/flv-tag.js"></script> 14 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/legacy/flv-tag.js"></script>
17 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/legacy/exp-golomb.js"></script> 15 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/legacy/exp-golomb.js"></script>
18 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/legacy/h264-extradata.js"></script> 16 <script src="node_modules/videojs-contrib-media-sources/node_modules/mux.js/legacy/h264-extradata.js"></script>
...@@ -23,6 +21,9 @@ ...@@ -23,6 +21,9 @@
23 21
24 <!-- Media Sources plugin --> 22 <!-- Media Sources plugin -->
25 <script src="node_modules/videojs-contrib-media-sources/src/videojs-media-sources.js"></script> 23 <script src="node_modules/videojs-contrib-media-sources/src/videojs-media-sources.js"></script>
24 <script>
25 videojs.MediaSource.webWorkerURI = 'node_modules/videojs-contrib-media-sources/src/transmuxer_worker.js';
26 </script>
26 27
27 <!-- HLS plugin --> 28 <!-- HLS plugin -->
28 <script src="src/videojs-hls.js"></script> 29 <script src="src/videojs-hls.js"></script>
...@@ -39,12 +40,6 @@ ...@@ -39,12 +40,6 @@
39 40
40 <script src="src/bin-utils.js"></script> 41 <script src="src/bin-utils.js"></script>
41 42
42 <!-- example MPEG2-TS segments -->
43 <!-- bipbop -->
44 <!-- <script src="test/tsSegment.js"></script> -->
45 <!-- bunnies -->
46 <!--<script src="test/tsSegment-bc.js"></script>-->
47
48 <style> 43 <style>
49 body { 44 body {
50 font-family: Arial, sans-serif; 45 font-family: Arial, sans-serif;
......
...@@ -10,10 +10,10 @@ var ...@@ -10,10 +10,10 @@ var
10 // a fudge factor to apply to advertised playlist bitrates to account for 10 // a fudge factor to apply to advertised playlist bitrates to account for
11 // temporary flucations in client bandwidth 11 // temporary flucations in client bandwidth
12 bandwidthVariance = 1.1, 12 bandwidthVariance = 1.1,
13 Component = videojs.getComponent('Component'),
13 14
14 // the amount of time to wait between checking the state of the buffer 15 // the amount of time to wait between checking the state of the buffer
15 bufferCheckInterval = 500, 16 bufferCheckInterval = 500,
16 Component = videojs.getComponent('Component'),
17 17
18 keyXhr, 18 keyXhr,
19 keyFailed, 19 keyFailed,
...@@ -133,7 +133,7 @@ videojs.Hls.prototype.src = function(src) { ...@@ -133,7 +133,7 @@ videojs.Hls.prototype.src = function(src) {
133 133
134 // We need to trigger this asynchronously to give others the chance 134 // We need to trigger this asynchronously to give others the chance
135 // to bind to the event when a source is set at player creation 135 // to bind to the event when a source is set at player creation
136 setTimeout(function() { 136 this.setTimeout(function() {
137 this.tech_.trigger('loadstart'); 137 this.tech_.trigger('loadstart');
138 }.bind(this), 1); 138 }.bind(this), 1);
139 139
...@@ -597,6 +597,7 @@ videojs.Hls.prototype.dispose = function() { ...@@ -597,6 +597,7 @@ videojs.Hls.prototype.dispose = function() {
597 } 597 }
598 598
599 this.resetSrc_(); 599 this.resetSrc_();
600 Component.prototype.dispose.call(this);
600 }; 601 };
601 602
602 /** 603 /**
......
...@@ -212,7 +212,8 @@ var ...@@ -212,7 +212,8 @@ var
212 212
213 // return an absolute version of a page-relative URL 213 // return an absolute version of a page-relative URL
214 absoluteUrl = function(relativeUrl) { 214 absoluteUrl = function(relativeUrl) {
215 return window.location.origin + 215 return window.location.protocol + '//' +
216 window.location.host +
216 (window.location.pathname 217 (window.location.pathname
217 .split('/') 218 .split('/')
218 .slice(0, -1) 219 .slice(0, -1)
...@@ -239,6 +240,9 @@ module('HLS', { ...@@ -239,6 +240,9 @@ module('HLS', {
239 el.className = 'vjs-tech vjs-mock-flash'; 240 el.className = 'vjs-tech vjs-mock-flash';
240 el.vjs_load = function() {}; 241 el.vjs_load = function() {};
241 el.vjs_getProperty = function(attr) { 242 el.vjs_getProperty = function(attr) {
243 if (attr === 'buffered') {
244 return [[0,0]];
245 }
242 return el[attr]; 246 return el[attr];
243 }; 247 };
244 el.vjs_setProperty = function(attr, value) { 248 el.vjs_setProperty = function(attr, value) {
...@@ -470,14 +474,14 @@ test('re-initializes the playlist loader when switching sources', function() { ...@@ -470,14 +474,14 @@ test('re-initializes the playlist loader when switching sources', function() {
470 474
471 test('sets the duration if one is available on the playlist', function() { 475 test('sets the duration if one is available on the playlist', function() {
472 var events = 0; 476 var events = 0;
473 player.on('durationchange', function() {
474 events++;
475 });
476 player.src({ 477 player.src({
477 src: 'manifest/media.m3u8', 478 src: 'manifest/media.m3u8',
478 type: 'application/vnd.apple.mpegurl' 479 type: 'application/vnd.apple.mpegurl'
479 }); 480 });
480 openMediaSource(player); 481 openMediaSource(player);
482 player.tech.on('durationchange', function() {
483 events++;
484 });
481 485
482 standardXHRResponse(requests[0]); 486 standardXHRResponse(requests[0]);
483 equal(player.tech.hls.mediaSource.duration, 40, 'set the duration'); 487 equal(player.tech.hls.mediaSource.duration, 40, 'set the duration');
...@@ -569,7 +573,8 @@ test('recognizes domain-relative URLs', function() { ...@@ -569,7 +573,8 @@ test('recognizes domain-relative URLs', function() {
569 standardXHRResponse(requests[0]); 573 standardXHRResponse(requests[0]);
570 standardXHRResponse(requests[1]); 574 standardXHRResponse(requests[1]);
571 strictEqual(requests[1].url, 575 strictEqual(requests[1].url,
572 window.location.origin + '/00001.ts', 576 window.location.protocol + '//' + window.location.host +
577 '/00001.ts',
573 'the first segment is requested'); 578 'the first segment is requested');
574 }); 579 });
575 580
...@@ -1349,9 +1354,11 @@ test('when outstanding XHRs are cancelled, they get aborted properly', function( ...@@ -1349,9 +1354,11 @@ test('when outstanding XHRs are cancelled, they get aborted properly', function(
1349 test('segmentXhr is properly nulled out when dispose is called', function() { 1354 test('segmentXhr is properly nulled out when dispose is called', function() {
1350 var 1355 var
1351 readystatechanges = 0, 1356 readystatechanges = 0,
1352 oldDispose = Flash.prototype.dispose; 1357 oldDispose = Flash.prototype.dispose,
1358 player;
1353 Flash.prototype.dispose = function() {}; 1359 Flash.prototype.dispose = function() {};
1354 1360
1361 player = createPlayer();
1355 player.src({ 1362 player.src({
1356 src: 'manifest/media.m3u8', 1363 src: 'manifest/media.m3u8',
1357 type: 'application/vnd.apple.mpegurl' 1364 type: 'application/vnd.apple.mpegurl'
...@@ -2128,7 +2135,7 @@ test('does not break if the playlist has no segments', function() { ...@@ -2128,7 +2135,7 @@ test('does not break if the playlist has no segments', function() {
2128 }); 2135 });
2129 2136
2130 test('clears the segment buffer on seek', function() { 2137 test('clears the segment buffer on seek', function() {
2131 var currentTime, bufferEnd, oldCurrentTime; 2138 var currentTime, oldCurrentTime;
2132 2139
2133 player.src({ 2140 player.src({
2134 src: 'discontinuity.m3u8', 2141 src: 'discontinuity.m3u8',
...@@ -2142,8 +2149,8 @@ test('clears the segment buffer on seek', function() { ...@@ -2142,8 +2149,8 @@ test('clears the segment buffer on seek', function() {
2142 } 2149 }
2143 return currentTime; 2150 return currentTime;
2144 }; 2151 };
2145 player.buffered = function() { 2152 player.tech.buffered = function() {
2146 return videojs.createTimeRange(0, bufferEnd); 2153 return videojs.createTimeRange();
2147 }; 2154 };
2148 2155
2149 requests.pop().respond(200, null, 2156 requests.pop().respond(200, null,
...@@ -2159,7 +2166,6 @@ test('clears the segment buffer on seek', function() { ...@@ -2159,7 +2166,6 @@ test('clears the segment buffer on seek', function() {
2159 2166
2160 // play to 6s to trigger the next segment request 2167 // play to 6s to trigger the next segment request
2161 currentTime = 6; 2168 currentTime = 6;
2162 bufferEnd = 10;
2163 clock.tick(6000); 2169 clock.tick(6000);
2164 2170
2165 standardXHRResponse(requests.pop()); // 2.ts 2171 standardXHRResponse(requests.pop()); // 2.ts
......