// Protected API methods
Popcorn.protect = {
- natives: "load play pause currentTime playbackRate mute volume duration removePlugin roundTime trigger listen unlisten".toLowerCase().split( /\s+/ )
+ natives: "load play pause currentTime playbackRate mute volume duration removePlugin roundTime trigger listen unlisten exec".toLowerCase().split( /\s+/ )
};
// Internal Only - Adds track events to the instance object
Popcorn.plugin = function( name, definition, manifest ) {
if ( Popcorn.protect.natives.indexOf( name.toLowerCase() ) >= 0 ) {
- Popcorn.error("'" + name + "' is a protected function name");
+ Popcorn.error( "'" + name + "' is a protected function name" );
return;
}
name = obj;
obj = Popcorn.p;
+ if ( Popcorn.protect.natives.indexOf( name.toLowerCase() ) >= 0 ) {
+ Popcorn.error( "'" + name + "' is a protected function name" );
+ return;
+ }
+
var registryLen = Popcorn.registry.length,
registryIdx;
});
+test("Protected from removal", function () {
+
+ expect( Popcorn.protect.natives.length * 2 );
+
+ Popcorn.protect.natives.forEach(function( name ) {
+
+ try {
+ Popcorn.plugin( name );
+ } catch( e ) {
+ ok( true, e.message + " and cannot be used as a plugin name" );
+ }
+
+ try {
+ Popcorn.removePlugin( name );
+ } catch( e ) {
+ ok( true, e.message + " and cannot be removed with this API" );
+ }
+ });
+});