]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Modified Popcorn.protect.natives to capture keys from Popcorn.p, added better tests... t738
authorChristopher De Cairos <chris.decairos@gmail.com>
Mon, 26 Sep 2011 19:15:24 +0000 (15:15 -0400)
committerChristopher De Cairos <chris.decairos@gmail.com>
Mon, 26 Sep 2011 19:15:24 +0000 (15:15 -0400)
popcorn.js
test/popcorn.unit.js

index 9450dcaf6fbc17cd5c839d60d02670b6278905b1..cf46c36d54a34f54b207a7f9a130bd05b4b9c004 100644 (file)
     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 ) {
 
   // 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;
 
index b975bc71bee2814a3278279127b79f3f29045c5b..6f2fa3ba31e22df135e3328ef5279cf5ccb9d9db 100644 (file)
@@ -2497,6 +2497,7 @@ test("Remove Plugin", function() {
   function plus() {
     if ( ++count === expects ) {
       start();
+      Popcorn.removePlugin( "cleanup" );
     }
   }
 
@@ -2616,26 +2617,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() {