diff --git a/Gruntfile.js b/Gruntfile.js index 0c8104e3d..a39d8b754 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -52,12 +52,12 @@ module.exports = function(grunt) { minify: { source:{ src: ['build/files/combined.video.js', 'build/compiler/goog.base.js', 'src/js/exports.js'], - externs: ['src/js/media/flash.externs.js'], + externs: ['src/js/player.externs.js', 'src/js/media/flash.externs.js'], dest: 'build/files/minified.video.js' }, tests: { src: ['build/files/combined.video.js', 'build/compiler/goog.base.js', 'src/js/exports.js', 'test/unit/*.js', '!test/unit/api.js'], - externs: ['src/js/media/flash.externs.js', 'test/qunit-externs.js'], + externs: ['src/js/player.externs.js', 'src/js/media/flash.externs.js', 'test/qunit-externs.js'], dest: 'build/files/test.minified.video.js' } }, diff --git a/src/js/player.externs.js b/src/js/player.externs.js new file mode 100644 index 000000000..9087cec98 --- /dev/null +++ b/src/js/player.externs.js @@ -0,0 +1,11 @@ +/** + * @fileoverview Externs for videojs.Player. Externs are functions that the + * compiler shouldn't obfuscate. + */ + +/** + * Fullscreen functionality + */ +videojs.Player.prototype.isFullScreen = undefined; +videojs.Player.prototype.requestFullScreen = function(){}; +videojs.Player.prototype.cancelFullScreen = function(){}; diff --git a/test/unit/api.js b/test/unit/api.js index 1b5d402c9..aafd428f5 100644 --- a/test/unit/api.js +++ b/test/unit/api.js @@ -94,7 +94,7 @@ test('should be able to initialize player twice on the same tag using string ref player.dispose(); }); -test('videojs.players should be availble after minification', function() { +test('videojs.players should be available after minification', function() { var videoTag = PlayerTest.makeTag(); var id = videoTag.id; @@ -106,3 +106,33 @@ test('videojs.players should be availble after minification', function() { player.dispose(); }); + +test('fullscreenToggle does not depend on minified player methods', function(){ + var noop, player, fullscreen, requestFullScreen, cancelFullScreen; + noop = function(){}; + requestFullScreen = false; + cancelFullScreen = false; + player = { + id: noop, + on: noop, + ready: noop + }; + + player['requestFullScreen'] = function(){ + requestFullScreen = true; + }; + player['cancelFullScreen'] = function(){ + cancelFullScreen = true; + }; + player['isFullScreen'] = false; + + fullscreen = new videojs.FullscreenToggle(player); + fullscreen.trigger('click'); + + ok(requestFullScreen, 'requestFullScreen called'); + + player.isFullScreen = true; + fullscreen.trigger('click'); + + ok(cancelFullScreen, 'cancelFullScreen called'); +});