]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#730] Adds Popcorn.isSupported boolean flag
authorRick Waldron <waldron.rick@gmail.com>
Mon, 26 Sep 2011 18:44:06 +0000 (14:44 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Mon, 26 Sep 2011 18:44:06 +0000 (14:44 -0400)
popcorn.js
test/popcorn.unit.archaic.js
test/popcorn.unit.js

index 9450dcaf6fbc17cd5c839d60d02670b6278905b1..8794882820d37302fb503ae9c88df9c408178253 100644 (file)
@@ -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 " +
     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 = [];
 
index e1df25c9ab2c37c38684e0745cdc6f87d531ca9f..0b78131dcecec395a6f3a0f8024b07a5b1fa620b 100644 (file)
@@ -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");
 
index b975bc71bee2814a3278279127b79f3f29045c5b..8162ed0fe1406bb13e8531e86c7c255546812a31 100644 (file)
@@ -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() {