From: rwldrn Date: Wed, 31 Aug 2011 17:54:23 +0000 (-0400) Subject: [#700] Popcorn dummies; Includes test suite w/ 59 tests X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=52f84a09c42149ceed8886f6a61b0384aa3e2beb;p=popcorn-js.git [#700] Popcorn dummies; Includes test suite w/ 59 tests --- diff --git a/popcorn.js b/popcorn.js index 51659a7..2b5ad22 100644 --- a/popcorn.js +++ b/popcorn.js @@ -1,6 +1,19 @@ (function(global, document) { - // Cache refs to speed up calls to native utils + // Popcorn.js does not support archaic browsers + if ( !document.addEventListener ) { + global.Popcorn = {}; + + var methods = ( "removeInstance addInstance getInstanceById removeInstanceById " + + "forEach extend effects error guid sizeOf isArray nop position disable enable " + + "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " + + "timeUpdate plugin removePlugin compose effect parser xhr getJSONP getScript" ).split(/\s+/); + + while( methods.length ) { + global.Popcorn[ methods.shift() ] = function(){}; + } + return; + } var diff --git a/test/archaic.html b/test/archaic.html new file mode 100644 index 0000000..c72a4b2 --- /dev/null +++ b/test/archaic.html @@ -0,0 +1,110 @@ + + + + Simulate Archaic Browser + + + + + + + + + + + + + + + + + +

Archaic

+ +

+ Popcorn.js: Simulate Archaic Browser +

+

+
+

+
    +
    + + + + + +
    + + diff --git a/test/index.html b/test/index.html index dd813c1..b54d7e7 100644 --- a/test/index.html +++ b/test/index.html @@ -20,6 +20,8 @@

    Popcorn.js API + + diff --git a/test/popcorn.unit.archaic.js b/test/popcorn.unit.archaic.js new file mode 100644 index 0000000..e1df25c --- /dev/null +++ b/test/popcorn.unit.archaic.js @@ -0,0 +1,56 @@ +module("Core"); +test("Dummy", function () { + + expect(1); + + ok( Popcorn, "Popcorn dummy exists"); +}); + +module("Static Methods"); +(function() { + + var method, + methods = ( "removeInstance addInstance getInstanceById removeInstanceById " + + "forEach extend effects error guid sizeOf isArray nop position disable enable " + + "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " + + "timeUpdate plugin removePlugin compose effect parser xhr getJSONP getScript" ).split(/\s+/); + + while( methods.length ) { + + method = methods.shift(); + + test( method, function () { + + expect(1); + + ok( Popcorn[ method ], "Popcorn." + method + " exists"); + }); + } + +})( Popcorn ); + + +module("Attempt"); +(function() { + + var method, + methods = ( "removeInstance addInstance getInstanceById removeInstanceById " + + "forEach extend effects error guid sizeOf isArray nop position disable enable " + + "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " + + "timeUpdate plugin removePlugin compose effect parser xhr getJSONP getScript" ).split(/\s+/); + + while( methods.length ) { + + method = methods.shift(); + + test( method, function () { + + expect(1); + + equal( Popcorn[ method ](), undefined, "Popcorn." + method + "() dummy returns undefined without throwing exception"); + + }); + } + +})( Popcorn ); + diff --git a/test/popcorn.unit.archaic.setup.js b/test/popcorn.unit.archaic.setup.js new file mode 100644 index 0000000..16cff7b --- /dev/null +++ b/test/popcorn.unit.archaic.setup.js @@ -0,0 +1,3 @@ + + +document.addEventListener = null; diff --git a/test/popcorn.unit.setup.js b/test/popcorn.unit.setup.js index ebfa253..4f23948 100644 --- a/test/popcorn.unit.setup.js +++ b/test/popcorn.unit.setup.js @@ -1,13 +1,15 @@ // suppress console log errors if ( !window['console'] ) { - var console = {}, - methods = 'log debug info warn error exception assert dir dirxml trace group groupEnd groupCollapsed time timeEnd profile profileEnd count clear notifyFirebug getFirebugElement firebug element'.split(' '); - - for ( var m in methods ) { - console[ methods[m] ] = function () { - //Array.prototype.slice.call(arguments) - }; - } +// var console = {}, +// methods = 'log debug info warn error exception assert dir dirxml trace group groupEnd groupCollapsed time timeEnd profile profileEnd count clear notifyFirebug getFirebugElement firebug element'.split(' '); +// +// for ( var m in methods ) { +// console[ methods[m] ] = function () { +// //Array.prototype.slice.call(arguments) +// }; +// } + + jQuery.getScript("https://getfirebug.com/firebug-lite-debug.js"); } diff --git a/test/ready.html b/test/ready.html index 8bf78d1..deccc2b 100644 --- a/test/ready.html +++ b/test/ready.html @@ -4,89 +4,89 @@ Popcorn API - - + + -

    Popcorn(/* DOM Ready */)

    +

    Popcorn(/* DOM Ready */)