Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Added Popcorn.isSupported flag [#730]
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher De Cairos committed Sep 26, 2011
2 parents cd74d28 + e592656 commit 41a3dbd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
9 changes: 7 additions & 2 deletions popcorn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 " +
Expand Down Expand Up @@ -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 = [];

Expand Down
19 changes: 14 additions & 5 deletions test/popcorn.unit.archaic.js
Original file line number Diff line number Diff line change
@@ -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 " +
Expand All @@ -21,7 +30,7 @@ module("Static Methods");

test( method, function () {

expect(1);
expect( 1 );

ok( Popcorn[ method ], "Popcorn." + method + " exists");
});
Expand All @@ -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 " +
Expand All @@ -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");

Expand Down
6 changes: 6 additions & 0 deletions test/popcorn.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down

0 comments on commit 41a3dbd

Please sign in to comment.