From: Rick Waldron Date: Mon, 26 Sep 2011 18:44:06 +0000 (-0400) Subject: [#730] Adds Popcorn.isSupported boolean flag X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e592656f44fdc6cea6267bc0a25963a254c1a95e;p=popcorn-js.git [#730] Adds Popcorn.isSupported boolean flag --- diff --git a/popcorn.js b/popcorn.js index 9450dca..8794882 100644 --- a/popcorn.js +++ b/popcorn.js @@ -2,7 +2,9 @@ // Popcorn.js does not support archaic browsers if ( !document.addEventListener ) { - global.Popcorn = {}; + global.Popcorn = { + isSupported: false + }; var methods = ( "forEach extend effects error guid sizeOf isArray nop position disable enable destroy " + "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " + @@ -63,9 +65,12 @@ return new Popcorn.p.init( entity, options || null ); }; - // Popcorn API version, automatically inserted via build system. + // Popcorn API version, automatically inserted via build system. Popcorn.version = "@VERSION"; + // Boolean flag allowing a client to determine if Popcorn can be supported + Popcorn.isSupported = true; + // Instance caching Popcorn.instances = []; diff --git a/test/popcorn.unit.archaic.js b/test/popcorn.unit.archaic.js index e1df25c..0b78131 100644 --- a/test/popcorn.unit.archaic.js +++ b/test/popcorn.unit.archaic.js @@ -1,15 +1,24 @@ module("Core"); test("Dummy", function () { - expect(1); + expect( 1 ); ok( Popcorn, "Popcorn dummy exists"); }); +test("isSupported", function () { + + expect( 2 ); + + ok( "isSupported" in Popcorn, "Popcorn.isSupported boolean flag exists"); + ok( !Popcorn.isSupported, "Popcorn.isSupported boolean flag is false"); +}); + + module("Static Methods"); (function() { - var method, + var method, methods = ( "removeInstance addInstance getInstanceById removeInstanceById " + "forEach extend effects error guid sizeOf isArray nop position disable enable " + "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " + @@ -21,7 +30,7 @@ module("Static Methods"); test( method, function () { - expect(1); + expect( 1 ); ok( Popcorn[ method ], "Popcorn." + method + " exists"); }); @@ -33,7 +42,7 @@ module("Static Methods"); module("Attempt"); (function() { - var method, + var method, methods = ( "removeInstance addInstance getInstanceById removeInstanceById " + "forEach extend effects error guid sizeOf isArray nop position disable enable " + "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " + @@ -45,7 +54,7 @@ module("Attempt"); test( method, function () { - expect(1); + expect( 1 ); equal( Popcorn[ method ](), undefined, "Popcorn." + method + "() dummy returns undefined without throwing exception"); diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index b975bc7..8162ed0 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -53,7 +53,13 @@ test( "noConflict", function() { Popcorn = $$; }); +test("isSupported", function () { + expect( 2 ); + + ok( "isSupported" in Popcorn, "Popcorn.isSupported boolean flag exists"); + ok( Popcorn.isSupported, "Popcorn.isSupported boolean flag is true"); +}); test("Popcorn.* Static Methods", function() {