(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
--- /dev/null
+<!DOCTYPE html>\r
+<html>\r
+<head>\r
+ <title>Simulate Archaic Browser</title>\r
+ <link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">\r
+\r
+ <style>\r
+ body {\r
+ margin: 3px;\r
+ padding: 0px;\r
+ }\r
+ h3 {\r
+ margin: 3px;\r
+ padding: 0px;\r
+ }\r
+ h2 {\r
+ display: inline;\r
+ margin: 3px;\r
+ padding: 0px;\r
+ } \r
+ .pass {\r
+ color: #33FF00;\r
+ }\r
+ .expect {\r
+ color: #2d2d2d;\r
+ } \r
+ .fail {\r
+ color: #FF0000;\r
+ }\r
+ </style>\r
+ <script src="jquery.js"></script>\r
+\r
+\r
+ <script src="qunit/qunit.js"></script>\r
+\r
+ <!--\r
+ do not move - this must be called immediately prior to\r
+ popcorn-api-draft.js\r
+ -->\r
+ <script src="popcorn.unit.setup.js"></script>\r
+ <script src="popcorn.unit.archaic.setup.js"></script>\r
+\r
+ <script src="../popcorn.js"></script>\r
+ <script src="popcorn.unit.archaic.js"></script>\r
+ <script>\r
+ (function( Popcorn, $ ) {\r
+\r
+ var results = {\r
+ pass: 0, \r
+ fail: 0,\r
+ expect: 40\r
+ };\r
+\r
+ $(function() {\r
+\r
+ function isComplete( callback ) {\r
+\r
+ if ( !QUnit.config.queue.length ) {\r
+ // is complete\r
+\r
+ callback && callback( QUnit.config.stats );\r
+\r
+ } else {\r
+ setTimeout(function() {\r
+ isComplete( callback );\r
+ }, 10 );\r
+ }\r
+ }\r
+\r
+ isComplete(function( qResults ) {\r
+\r
+ // Hack together the results as used in ready.html\r
+ results.pass = qResults.all - qResults.bad;\r
+ results.fail = qResults.bad;\r
+ results.expect = qResults.all;\r
+\r
+ $.each( results, function( name, value ) {\r
+ $("#qunit-header").before( \r
+ $("<h2>", {\r
+ className: name, \r
+ html: name + ": " + value \r
+ }) \r
+ );\r
+ });\r
+ \r
+ });\r
+ });\r
+ })( Popcorn, jQuery );\r
+\r
+ </script>\r
+</head>\r
+<body>\r
+ <h3>Archaic<h3>\r
+\r
+ <h1 id="qunit-header">\r
+ Popcorn.js: Simulate Archaic Browser\r
+ </h1>\r
+ <h2 id="qunit-banner"></h2>\r
+ <div id="qunit-testrunner-toolbar"></div>\r
+ <h2 id="qunit-userAgent"></h2>\r
+ <ol id="qunit-tests"></ol>\r
+ <div id="qunit-fixture">\r
+\r
+\r
+\r
+\r
+\r
+ </div>\r
+</body>\r
+</html>\r
<body>
<h1 id="qunit-header">
Popcorn.js API
+ <iframe id="archaic-tests" data-src="archaic.html" style="width:325px;height:60px;float:right;border:0px;margin:-10px 20px 0 -10px;background:#fff" ></iframe>
+
<iframe id="butter-tests" data-src="butter_test.html" style="width:325px;height:60px;float:right;border:0px;margin:-10px 20px 0 -10px;background:#fff" ></iframe>
<iframe id="ready-tests" data-src="ready.html" style="width:325px;height:60px;float:right;border:0px;margin:-10px 20px 0 -10px;background:#fff" ></iframe>
--- /dev/null
+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 );
+
--- /dev/null
+\r
+\r
+document.addEventListener = null;\r
// 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");
}
<title>Popcorn API</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
- <style>
- body {
- margin: 3px;
- padding: 0px;
- }
- h3 {
- margin: 3px;
- padding: 0px;
- }
- h2 {
- display: inline;
- margin: 3px;
- padding: 0px;
- }
- .pass {
- color: #33FF00;
- }
- .expect {
- color: #2d2d2d;
- }
- .fail {
- color: #FF0000;
- }
- </style>
- <script src="jquery.js"></script>
+ <style>
+ body {
+ margin: 3px;
+ padding: 0px;
+ }
+ h3 {
+ margin: 3px;
+ padding: 0px;
+ }
+ h2 {
+ display: inline;
+ margin: 3px;
+ padding: 0px;
+ }
+ .pass {
+ color: #33FF00;
+ }
+ .expect {
+ color: #2d2d2d;
+ }
+ .fail {
+ color: #FF0000;
+ }
+ </style>
+ <script src="jquery.js"></script>
<script src="../popcorn.js"></script>
<script>
- (function( Popcorn, $ ) {
-
- var readyCalled = 0,
- readyOrder = [],
- readyComposed = "Ready Callback 1,Ready Callback 2",
- results = {
- pass: 0,
- fail: 0,
- expect: 2
- };
-
- $(function() {
- readyCalled++;
- });
-
- Popcorn(function (e) {
-
- readyCalled++;
- readyOrder.push("Ready Callback 1");
-
- Popcorn("#video").exec( 1, function () {
-
- results[
- ( readyCalled === 3 ? "pass" : "fail" )
- ]++;
-
- if ( readyOrder.join(",") === readyComposed ) {
- results.pass++;
- }
-
- $.each( results, function( name, value ) {
- $("video").before(
- $("<h2>", {
- className: name,
- html: name + ": " + value
- })
- );
- });
-
- }).play().volume(0);
-
- });
-
- Popcorn(function () {
-
- readyCalled++;
- readyOrder.push("Ready Callback 2");
-
- });
- })( Popcorn, jQuery );
+ (function( Popcorn, $ ) {
+
+ var readyCalled = 0,
+ readyOrder = [],
+ readyComposed = "Ready Callback 1,Ready Callback 2",
+ results = {
+ pass: 0,
+ fail: 0,
+ expect: 2
+ };
+
+ $(function() {
+ readyCalled++;
+ });
+
+ Popcorn(function (e) {
+
+ readyCalled++;
+ readyOrder.push("Ready Callback 1");
+
+ Popcorn("#video").exec( 1, function () {
+
+ results[
+ ( readyCalled === 3 ? "pass" : "fail" )
+ ]++;
+
+ if ( readyOrder.join(",") === readyComposed ) {
+ results.pass++;
+ }
+
+ $.each( results, function( name, value ) {
+ $("video").before(
+ $("<h2>", {
+ className: name,
+ html: name + ": " + value
+ })
+ );
+ });
+
+ }).play().volume(0);
+
+ });
+
+ Popcorn(function () {
+
+ readyCalled++;
+ readyOrder.push("Ready Callback 2");
+
+ });
+ })( Popcorn, jQuery );
</script>
</head>
<body>
- <h3>Popcorn(/* DOM Ready */)<h3>
+ <h3>Popcorn(/* DOM Ready */)<h3>
<video id='video'style="display:none"
controls