зеркало из https://github.com/mozilla/popcorn-js.git
Merge pull request #35 from ScottDowne/t796
[#796] calling destroy on all popcorns in tests.
This commit is contained in:
Коммит
2d21e790ca
|
@ -130,6 +130,8 @@ test( "Popcorn.getTrackEvents", function() {
|
||||||
Popcorn.removeTrackEvent( popcorn, Popcorn.getTrackEvents( popcorn )[ 0 ]._id );
|
Popcorn.removeTrackEvent( popcorn, Popcorn.getTrackEvents( popcorn )[ 0 ]._id );
|
||||||
|
|
||||||
equal( Popcorn.getTrackEvents( popcorn ).length, 0, "Popcorn.getTrackEvents() has no items after removal" );
|
equal( Popcorn.getTrackEvents( popcorn ).length, 0, "Popcorn.getTrackEvents() has no items after removal" );
|
||||||
|
|
||||||
|
popcorn.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "Popcorn.getTrackEvent", function() {
|
test( "Popcorn.getTrackEvent", function() {
|
||||||
|
@ -145,6 +147,7 @@ test( "Popcorn.getTrackEvent", function() {
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
Popcorn.removePlugin( "temp" );
|
Popcorn.removePlugin( "temp" );
|
||||||
Popcorn.removeTrackEvent( popcorn, Popcorn.getTrackEvents( popcorn )[ 0 ]._id );
|
Popcorn.removeTrackEvent( popcorn, Popcorn.getTrackEvents( popcorn )[ 0 ]._id );
|
||||||
|
popcorn.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,6 +298,8 @@ test( "Popcorn.removeTrackEvent", function() {
|
||||||
Popcorn.forEach([ "a", "b", "c", "d" ], function( name ) {
|
Popcorn.forEach([ "a", "b", "c", "d" ], function( name ) {
|
||||||
Popcorn.removePlugin( name );
|
Popcorn.removePlugin( name );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pop.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "Popcorn.forEach", function() {
|
test( "Popcorn.forEach", function() {
|
||||||
|
@ -585,6 +590,8 @@ test( "Object", function() {
|
||||||
|
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
|
|
||||||
|
popObj.destroy();
|
||||||
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -701,22 +708,29 @@ test( "Instance", function() {
|
||||||
ok( a.data.trackEvents.previousUpdateTime >= -1, "instance a has data.trackEvents.previousUpdateTime property" );
|
ok( a.data.trackEvents.previousUpdateTime >= -1, "instance a has data.trackEvents.previousUpdateTime property" );
|
||||||
ok( b.data.trackEvents.previousUpdateTime >= -1, "instance b has data.trackEvents.previousUpdateTime property" );
|
ok( b.data.trackEvents.previousUpdateTime >= -1, "instance b has data.trackEvents.previousUpdateTime property" );
|
||||||
|
|
||||||
|
a.destroy();
|
||||||
|
b.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "Bogus Selector", 2, function() {
|
test( "Bogus Selector", 2, function() {
|
||||||
|
var p;
|
||||||
try {
|
try {
|
||||||
Popcorn( "#[object HTMLDivElement]" );
|
p = Popcorn( "#[object HTMLDivElement]" );
|
||||||
|
|
||||||
|
p.destroy();
|
||||||
ok(false, "Should not fail silently" );
|
ok(false, "Should not fail silently" );
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
// no need to call destroy here, as the constructor failed, and no instance exists
|
||||||
ok( true, "Exception raised on bogus selector: " + e.message );
|
ok( true, "Exception raised on bogus selector: " + e.message );
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Popcorn( document.getElementById( "video" ) );
|
p = Popcorn( document.getElementById( "video" ) );
|
||||||
|
|
||||||
|
p.destroy();
|
||||||
ok( true, "No error is raised for using the media element itself" );
|
ok( true, "No error is raised for using the media element itself" );
|
||||||
} catch( e ) {
|
} catch( e ) {
|
||||||
|
// no need to call destroy here, as the constructor failed, and no instance exists
|
||||||
ok( false, "Exception thrown for using a valid media element" );
|
ok( false, "Exception thrown for using a valid media element" );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -742,6 +756,8 @@ test( "Popcorn.[addTrackEvent | removeTrackEvent].ref()", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
equal( Popcorn.sizeOf( popped.data.trackRefs ), 0, "There are 0 trackRefs in popped.data.trackRefs" );
|
equal( Popcorn.sizeOf( popped.data.trackRefs ), 0, "There are 0 trackRefs in popped.data.trackRefs" );
|
||||||
|
|
||||||
|
popped.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
module( "Popcorn Prototype Methods" );
|
module( "Popcorn Prototype Methods" );
|
||||||
|
@ -775,6 +791,8 @@ test( "deprecated method warning", function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
$pop.listen( "foo", handler).trigger( "foo" ).unlisten( "foo", handler );
|
$pop.listen( "foo", handler).trigger( "foo" ).unlisten( "foo", handler );
|
||||||
|
|
||||||
|
$pop.destroy();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -791,6 +809,7 @@ test( "roundTime", function() {
|
||||||
popped.play().pause().currentTime( 0.98 );
|
popped.play().pause().currentTime( 0.98 );
|
||||||
|
|
||||||
equal( 1, popped.roundTime(), ".roundTime() returns 1 when currentTime is 0.98s" );
|
equal( 1, popped.roundTime(), ".roundTime() returns 1 when currentTime is 0.98s" );
|
||||||
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -815,8 +834,8 @@ test( "exec", function() {
|
||||||
|
|
||||||
equal( loop, expects, "cue callback repeat check, only called twice" );
|
equal( loop, expects, "cue callback repeat check, only called twice" );
|
||||||
Popcorn.removePlugin( popped, "cue" );
|
Popcorn.removePlugin( popped, "cue" );
|
||||||
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
|
|
||||||
}, 1000 );
|
}, 1000 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -857,6 +876,8 @@ test( "mute", function() {
|
||||||
|
|
||||||
function plus(){
|
function plus(){
|
||||||
if ( ++count == expects ) {
|
if ( ++count == expects ) {
|
||||||
|
video.destroy();
|
||||||
|
audio.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -904,6 +925,7 @@ test( "play(n)/pause(n) as shorthand to currentTime(n).play()/pause()", function
|
||||||
|
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count == expects ) {
|
if ( ++count == expects ) {
|
||||||
|
$pop.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1189,7 +1211,8 @@ test( "position", function() {
|
||||||
$relative = $( ".relative" ),
|
$relative = $( ".relative" ),
|
||||||
$fixed = $( ".fixed" ),
|
$fixed = $( ".fixed" ),
|
||||||
$static = $( ".static" ),
|
$static = $( ".static" ),
|
||||||
tests;
|
tests,
|
||||||
|
p;
|
||||||
|
|
||||||
$( "#position-tests" ).show();
|
$( "#position-tests" ).show();
|
||||||
|
|
||||||
|
@ -1217,8 +1240,10 @@ test( "position", function() {
|
||||||
];
|
];
|
||||||
|
|
||||||
Popcorn.forEach( tests, function( test ) {
|
Popcorn.forEach( tests, function( test ) {
|
||||||
equal( Popcorn( "#vid-" + test.id ).position().top, test.top, "Popcorn( '#vid-" + test.id + "' ).position().top" );
|
p = Popcorn( "#vid-" + test.id );
|
||||||
equal( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn( '#vid-" + test.id + "' ).position().left" );
|
equal( p.position().top, test.top, "Popcorn( '#vid-" + test.id + "' ).position().top" );
|
||||||
|
equal( p.position().left, test.left, "Popcorn( '#vid-" + test.id + "' ).position().left" );
|
||||||
|
p.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
|
@ -1235,8 +1260,10 @@ test( "position", function() {
|
||||||
];
|
];
|
||||||
|
|
||||||
Popcorn.forEach( tests, function( test ) {
|
Popcorn.forEach( tests, function( test ) {
|
||||||
equal( Popcorn( "#vid-" + test.id ).position().top, test.top, "Popcorn( '#vid-" + test.id + "' ).position().top" );
|
p = Popcorn( "#vid-" + test.id );
|
||||||
equal( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn( '#vid-" + test.id + "' ).position().left" );
|
equal( p.position().top, test.top, "Popcorn( '#vid-" + test.id + "' ).position().top" );
|
||||||
|
equal( p.position().left, test.left, "Popcorn( '#vid-" + test.id + "' ).position().left" );
|
||||||
|
p.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
|
@ -1253,8 +1280,10 @@ test( "position", function() {
|
||||||
];
|
];
|
||||||
|
|
||||||
Popcorn.forEach( tests, function( test ) {
|
Popcorn.forEach( tests, function( test ) {
|
||||||
equal( Popcorn( "#vid-" + test.id ).position().top, test.top, "Popcorn('#vid-" + test.id + "').position().top" );
|
p = Popcorn( "#vid-" + test.id );
|
||||||
equal( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
|
equal( p.position().top, test.top, "Popcorn('#vid-" + test.id + "').position().top" );
|
||||||
|
equal( p.position().left, test.left, "Popcorn('#vid-" + test.id + "').position().left" );
|
||||||
|
p.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
|
@ -1281,16 +1310,20 @@ test( "position", function() {
|
||||||
];
|
];
|
||||||
|
|
||||||
Popcorn.forEach( tests, function( test ) {
|
Popcorn.forEach( tests, function( test ) {
|
||||||
equal( Popcorn( "#vid-" + test.id ).position().top, test.top, "Popcorn( '#vid-" + test.id + "' ).position().top" );
|
p = Popcorn( "#vid-" + test.id );
|
||||||
equal( Popcorn( "#vid-" + test.id ).position().left, test.left, "Popcorn( '#vid-" + test.id + "' ).position().left" );
|
equal( p.position().top, test.top, "Popcorn( '#vid-" + test.id + "' ).position().top" );
|
||||||
|
equal( p.position().left, test.left, "Popcorn( '#vid-" + test.id + "' ).position().left" );
|
||||||
|
p.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ok( Popcorn( "#audio" ).position(), "position called from audio" );
|
p = Popcorn( "#audio" );
|
||||||
|
ok( p.position(), "position called from audio" );
|
||||||
} catch( e ) {
|
} catch( e ) {
|
||||||
ok( false, e );
|
ok( false, e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.destroy();
|
||||||
$( "#position-tests" ).hide();
|
$( "#position-tests" ).hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1554,6 +1587,8 @@ test( "on/off/emit", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$pop.emit( "foo" );
|
$pop.emit( "foo" );
|
||||||
|
|
||||||
|
$pop.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1919,10 +1954,11 @@ test( "Plugin toString", function() {
|
||||||
trackEvent = $pop.getTrackEvent( $pop.getLastTrackEventId() );
|
trackEvent = $pop.getTrackEvent( $pop.getLastTrackEventId() );
|
||||||
result = trackEvent.toString();
|
result = trackEvent.toString();
|
||||||
|
|
||||||
|
|
||||||
ok( result, "BOO YA!", "Custom toString value" );
|
ok( result, "BOO YA!", "Custom toString value" );
|
||||||
|
|
||||||
Popcorn.removePlugin( "stringify" );
|
Popcorn.removePlugin( "stringify" );
|
||||||
|
|
||||||
|
$pop.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "Exceptions", function() {
|
test( "Exceptions", function() {
|
||||||
|
@ -1939,8 +1975,8 @@ test( "Exceptions", function() {
|
||||||
Popcorn.removePlugin( "exceptions" );
|
Popcorn.removePlugin( "exceptions" );
|
||||||
Popcorn.plugin.debug = true;
|
Popcorn.plugin.debug = true;
|
||||||
Popcorn.plugin.errors = [];
|
Popcorn.plugin.errors = [];
|
||||||
start();
|
|
||||||
$pop.destroy();
|
$pop.destroy();
|
||||||
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2627,7 +2663,6 @@ asyncTest( "Popcorn Compose", function() {
|
||||||
Popcorn.removePlugin( "testPlugin" );
|
Popcorn.removePlugin( "testPlugin" );
|
||||||
Popcorn.removePlugin( "pluginOptions1" );
|
Popcorn.removePlugin( "pluginOptions1" );
|
||||||
Popcorn.removePlugin( "pluginOptions2" );
|
Popcorn.removePlugin( "pluginOptions2" );
|
||||||
|
|
||||||
popped.destroy();
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
@ -2869,6 +2904,7 @@ test( "Teardown end tester", function() {
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
Popcorn.removePlugin( "teardownEndTester" );
|
Popcorn.removePlugin( "teardownEndTester" );
|
||||||
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2921,6 +2957,7 @@ test( "Teardown end noise", function() {
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
Popcorn.removePlugin( "teardownEndTester" );
|
Popcorn.removePlugin( "teardownEndTester" );
|
||||||
Popcorn.removePlugin( "noise" );
|
Popcorn.removePlugin( "noise" );
|
||||||
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2979,6 +3016,7 @@ test( "Plugin Breaker", function() {
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count == expects ) {
|
if ( ++count == expects ) {
|
||||||
Popcorn.removePlugin( "breaker" );
|
Popcorn.removePlugin( "breaker" );
|
||||||
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3039,6 +3077,7 @@ test( "Plugin Empty", function() {
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count == expects ) {
|
if ( ++count == expects ) {
|
||||||
Popcorn.removePlugin( "empty" );
|
Popcorn.removePlugin( "empty" );
|
||||||
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3074,6 +3113,7 @@ test( "Plugin Closure", function() {
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count == expects ) {
|
if ( ++count == expects ) {
|
||||||
Popcorn.removePlugin( "closure" );
|
Popcorn.removePlugin( "closure" );
|
||||||
|
popped.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3134,8 +3174,10 @@ test( "Remove Plugin", function() {
|
||||||
|
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
start();
|
|
||||||
Popcorn.removePlugin( "cleanup" );
|
Popcorn.removePlugin( "cleanup" );
|
||||||
|
p.destroy();
|
||||||
|
p2.destroy();
|
||||||
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3284,6 +3326,8 @@ test( "Protected Names", function() {
|
||||||
ok( true, "Attempting to overwrite '" + name + "' threw an exception " );
|
ok( true, "Attempting to overwrite '" + name + "' threw an exception " );
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
popped.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "Defaulting Empty End Values", function() {
|
test( "Defaulting Empty End Values", function() {
|
||||||
|
@ -3315,6 +3359,9 @@ test( "Defaulting Empty End Values", function() {
|
||||||
apikey: "CHAyhB5IisvLqqzGYNYbmA",
|
apikey: "CHAyhB5IisvLqqzGYNYbmA",
|
||||||
mediaid: "13607892"
|
mediaid: "13607892"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
popped.destroy();
|
||||||
|
popped2.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "In/Out aliases", function() {
|
test( "In/Out aliases", function() {
|
||||||
|
@ -3329,7 +3376,7 @@ test( "In/Out aliases", function() {
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
Popcorn.removePlugin( "aliasTester" );
|
Popcorn.removePlugin( "aliasTester" );
|
||||||
Popcorn.destroy( popcorn );
|
popcorn.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3385,7 +3432,6 @@ test( "Functions", function() {
|
||||||
|
|
||||||
var popped = Popcorn( "#video" ), ffTrackId, rwTrackId, rw2TrackId, rw3TrackId, historyRef, trackEvents;
|
var popped = Popcorn( "#video" ), ffTrackId, rwTrackId, rw2TrackId, rw3TrackId, historyRef, trackEvents;
|
||||||
|
|
||||||
|
|
||||||
Popcorn.plugin( "ff", function() {
|
Popcorn.plugin( "ff", function() {
|
||||||
return {
|
return {
|
||||||
start: function() {},
|
start: function() {},
|
||||||
|
@ -3472,6 +3518,8 @@ test( "Functions", function() {
|
||||||
trackEvents = popped.getTrackEvents();
|
trackEvents = popped.getTrackEvents();
|
||||||
|
|
||||||
equal( trackEvents.length, 3, "3 user created trackEvents returned by popped.getTrackEvents()" );
|
equal( trackEvents.length, 3, "3 user created trackEvents returned by popped.getTrackEvents()" );
|
||||||
|
|
||||||
|
popped.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "getTrackEvent", function() {
|
test( "getTrackEvent", function() {
|
||||||
|
@ -3480,7 +3528,7 @@ test( "getTrackEvent", function() {
|
||||||
expect( 5 );
|
expect( 5 );
|
||||||
|
|
||||||
var popped = Popcorn( "#video" ),
|
var popped = Popcorn( "#video" ),
|
||||||
trackIds = [], obj, oldId;
|
trackIds = [], obj, oldId;
|
||||||
|
|
||||||
Popcorn.plugin( "ff", function() {
|
Popcorn.plugin( "ff", function() {
|
||||||
return {
|
return {
|
||||||
|
@ -3531,6 +3579,8 @@ test( "getTrackEvent", function() {
|
||||||
popped.removeTrackEvent( oldId );
|
popped.removeTrackEvent( oldId );
|
||||||
|
|
||||||
equal( popped.getTrackEvent( oldId ), undefined, "returned undefined when id is not found" );
|
equal( popped.getTrackEvent( oldId ), undefined, "returned undefined when id is not found" );
|
||||||
|
|
||||||
|
popped.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "Index Integrity ( removing tracks )", function() {
|
test( "Index Integrity ( removing tracks )", function() {
|
||||||
|
@ -3733,9 +3783,9 @@ asyncTest( "Popcorn.disable/enable/toggle (timeupdate)", function() {
|
||||||
|
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
start();
|
|
||||||
Popcorn.removePlugin( "toggler" );
|
Popcorn.removePlugin( "toggler" );
|
||||||
$pop.destroy();
|
$pop.destroy();
|
||||||
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3886,9 +3936,10 @@ test( "end undefined or false should never be fired", function() {
|
||||||
|
|
||||||
function plus() {
|
function plus() {
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
start();
|
|
||||||
Popcorn.removePlugin( "neverEndingStory" );
|
Popcorn.removePlugin( "neverEndingStory" );
|
||||||
Popcorn.removePlugin( "endingStory" );
|
Popcorn.removePlugin( "endingStory" );
|
||||||
|
$pop.destroy();
|
||||||
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4340,6 +4391,8 @@ test( "Basic Audio Support (timeupdate)", function() {
|
||||||
|
|
||||||
if ( ++count === expects ) {
|
if ( ++count === expects ) {
|
||||||
|
|
||||||
|
popped.destroy();
|
||||||
|
popObj.destroy();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче