Skip to content

Commit

Permalink
Modified Popcorn.protect.natives to capture all keys on Popcorn.p.pro…
Browse files Browse the repository at this point in the history
…totype. [#738]
  • Loading branch information
Christopher De Cairos committed Sep 27, 2011
2 parents a12ed63 + 5b14231 commit 534d825
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
11 changes: 5 additions & 6 deletions popcorn.js
Expand Up @@ -755,12 +755,6 @@
Popcorn.p[ key ] = Popcorn.events.fn[ key ];
});

// Protected API methods
Popcorn.protect = {
natives: ( "load play pause currentTime playbackRate mute volume duration removePlugin roundTime trigger listen unlisten exec" +
"preload playbackRate autoplay loop controls muted buffered readyState seeking paused played seekable ended" ).toLowerCase().split( /\s+/ )
};

// Internal Only - Adds track events to the instance object
Popcorn.addTrackEvent = function( obj, track ) {

Expand Down Expand Up @@ -1784,6 +1778,11 @@
// alias for exec function
Popcorn.p.cue = Popcorn.p.exec;

// Protected API methods
Popcorn.protect = {
natives: Object.keys( Popcorn.p ).join( "," ).toLowerCase().split( "," )
};

// Exposes Popcorn to global context
global.Popcorn = Popcorn;

Expand Down
29 changes: 19 additions & 10 deletions test/popcorn.unit.js
Expand Up @@ -2503,6 +2503,7 @@ test("Remove Plugin", function() {
function plus() {
if ( ++count === expects ) {
start();
Popcorn.removePlugin( "cleanup" );
}
}

Expand Down Expand Up @@ -2622,26 +2623,34 @@ test("Remove Plugin", function() {

});

test( "Protected Names", function() {

var keys = Object.keys( Popcorn.p ),
len = keys.length,
count = 0,
popped = Popcorn( "#video" );

expect( len );

test("Protected Names", function() {
//QUnit.reset();

expect(8);

var popped = Popcorn("#video");
function plus() {
if ( ++count === len ) {
start();
}
}

$.each( "load play pause currentTime playbackRate mute volume duration".split(/\s+/), function(k, name) {
Popcorn.forEach( keys, function( name ) {
try {

Popcorn.plugin( name, {});
} catch (e) {
Popcorn.plugin( name, {} );
} catch ( e ) {

ok( name, "Attempting to overwrite '" + name + "' threw an exception " );

plus();
};
});

stop( 5000 );

});

test("Defaulting Empty End Values", function() {
Expand Down

0 comments on commit 534d825

Please sign in to comment.