Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'travis-ci'

* travis-ci:
  Setup travis-ci integration to run test suite. - Added server.js for node connect static server - Updated unit.js to hook into QUnit events - Added run-qunit.js for phantomjs - Setup .travis.yml config to launch static server and run test suite in phantomjs
  • Loading branch information...
commit b13f5f5381ea75273f7e8bf7dc7be89bf9ad9c8e 2 parents 1dd860d + e09725d
Ryan Seddon ryanseddon authored
12 .travis.yml
View
@@ -0,0 +1,12 @@
+language: node_js
+node_js:
+ - 0.7
+notifications:
+ email: false
+before_script:
+ - "export DISPLAY=:99.0"
+ - "sh -e /etc/init.d/xvfb start"
+ - npm install connect
+ - sudo node test/js/server.js &
+ - sleep 5
+script: phantomjs test/qunit/run-qunit.js 'http://localhost:80/test/index.html?filter=!caniuse.com'
2  readme.md
View
@@ -1,4 +1,4 @@
-Modernizr
+Modernizr [![Build Status](https://secure.travis-ci.org/Modernizr/Modernizr.png?branch=travis-ci)](http://travis-ci.org/Modernizr/Modernizr)
=========
### a JavaScript library allowing you to use CSS3 & HTML5 while maintaining control over unsupported browsers
65 test/basic.html
View
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html class="+no-js no-js- no-js i-has-no-js">
+<head>
+ <meta charset="UTF-8">
+ <title>Modernizr Test Suite</title>
+ <link rel="stylesheet" href="qunit/qunit.css">
+ <style>
+ body { margin-bottom: 150px;}
+ #testbed { font-family: Helvetica; color: #444; padding-bottom: 100px;}
+ #testbed button { margin: 30px; font-size: 13px;}
+ .data-notes, .offScreen { display:none;}
+ table { width: 100%;}
+ tbody tr:nth-child(even) td, tbody tr:nth-child(even) th { border: 1px solid #ccc; border-left: 0; border-right: 0;}
+ table td:nth-child(even), table th:nth-child(even) { background: #e6e6e6;}
+ table tbody tr:hover td, table tbody tr:hover th { background: #e1e100!important;}
+ td.wrong { background:red!important;}
+ #html5section { visibility: hidden; }
+ h1 label { display:none;}
+ .output { padding: 0 0 0 16px;}
+ .output ul { margin: 0;}
+ .output li { color: #854747; }
+ .output li.yes{color:#090;}
+ .output li b{color:#000;}
+ .output {font:14px/1.3 Inconsolata,Consolas,monospace;
+ -webkit-column-count: 5;
+ -moz-column-count: 5;
+ column-count: 5;}
+ .output + .output { border-top: 5px solid #ccc; }
+ textarea { width: 100%; min-height: 75px;}
+ #caniusetrigger { font-size: 38px; font-family: monospace; display:block; }
+ </style>
+
+ <script src="https://raw.github.com/Modernizr/Modernizr/master/modernizr.js"></script>
+
+ <script>window.Modernizr || document.write('<script src="../modernizr.js"><\/script>')</script>
+
+ <script src="js/lib/polyfills.js"></script>
+ <script src="js/lib/detect-global.js"></script>
+
+ <script src="qunit/qunit.js"></script>
+ <script src="js/lib/jquery-1.7b2.js"></script>
+
+ <script src="js/setup.js"></script>
+
+ <script src="js/unit.js"></script>
+</head>
+<body>
+ <h1 id="qunit-header">Modernizr Test Suite</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+
+ <ol id="qunit-tests"></ol>
+
+ <div id="mod-output" class=output></div>
+ <div id="mod-feattest-output" class=output></div>
+
+
+ <br>
+
+ <section><aside>this is an aside within a section</aside></section>
+
+
+</body>
+</html>
65 test/js/basic.html
View
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html class="+no-js no-js- no-js i-has-no-js">
+<head>
+ <meta charset="UTF-8">
+ <title>Modernizr Test Suite</title>
+ <link rel="stylesheet" href="qunit/qunit.css">
+ <style>
+ body { margin-bottom: 150px;}
+ #testbed { font-family: Helvetica; color: #444; padding-bottom: 100px;}
+ #testbed button { margin: 30px; font-size: 13px;}
+ .data-notes, .offScreen { display:none;}
+ table { width: 100%;}
+ tbody tr:nth-child(even) td, tbody tr:nth-child(even) th { border: 1px solid #ccc; border-left: 0; border-right: 0;}
+ table td:nth-child(even), table th:nth-child(even) { background: #e6e6e6;}
+ table tbody tr:hover td, table tbody tr:hover th { background: #e1e100!important;}
+ td.wrong { background:red!important;}
+ #html5section { visibility: hidden; }
+ h1 label { display:none;}
+ .output { padding: 0 0 0 16px;}
+ .output ul { margin: 0;}
+ .output li { color: #854747; }
+ .output li.yes{color:#090;}
+ .output li b{color:#000;}
+ .output {font:14px/1.3 Inconsolata,Consolas,monospace;
+ -webkit-column-count: 5;
+ -moz-column-count: 5;
+ column-count: 5;}
+ .output + .output { border-top: 5px solid #ccc; }
+ textarea { width: 100%; min-height: 75px;}
+ #caniusetrigger { font-size: 38px; font-family: monospace; display:block; }
+ </style>
+
+ <script src="https://raw.github.com/Modernizr/Modernizr/master/modernizr.js"></script>
+
+ <script>window.Modernizr || document.write('<script src="../modernizr.js"><\/script>'); console.log("Loading in the /js folder *trollface*")</script>
+
+ <script src="js/lib/polyfills.js"></script>
+ <script src="js/lib/detect-global.js"></script>
+
+ <script src="qunit/qunit.js"></script>
+ <script src="js/lib/jquery-1.7b2.js"></script>
+
+ <script src="js/setup.js"></script>
+
+ <script src="js/unit.js"></script>
+</head>
+<body>
+ <h1 id="qunit-header">Modernizr Test Suite</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+
+ <ol id="qunit-tests"></ol>
+
+ <div id="mod-output" class=output></div>
+ <div id="mod-feattest-output" class=output></div>
+
+
+ <br>
+
+ <section><aside>this is an aside within a section</aside></section>
+
+
+</body>
+</html>
10 test/js/server.js
View
@@ -0,0 +1,10 @@
+var connect = require('connect'),
+ args = process.argv.slice(2),
+ folder = args[0] || '/../../',
+ port = args[1] || '80';
+
+var server = connect.createServer(
+ connect.static(__dirname + folder)
+).listen(port);
+
+console.log("Server started on port %s in %s", port, folder);
19 test/js/unit.js
View
@@ -1,3 +1,22 @@
+QUnit.begin = function() {
+ console.log("Starting test suite");
+ console.log("================================================\n");
+};
+
+QUnit.moduleDone = function(opts) {
+ if(opts.failed === 0) {
+ console.log("\u2714 All tests passed in '"+opts.name+"' module");
+ } else {
+ console.log("\u2716 "+ opts.failed +" tests failed in '"+opts.name+"' module");
+ }
+};
+
+QUnit.done = function(opts) {
+ console.log("\n================================================");
+ console.log("Tests completed in "+opts.runtime+" milliseconds");
+ console.log(opts.passed + " tests of "+opts.total+" passed, "+opts.failed+" failed.");
+};
+
module('Basics', {
setup:function() {
},
72 test/qunit/run-qunit.js
View
@@ -0,0 +1,72 @@
+/**
+* Wait until the test condition is true or a timeout occurs. Useful for waiting
+* on a server response or for a ui change (fadeIn, etc.) to occur.
+*
+* @param testFx javascript condition that evaluates to a boolean,
+* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
+* as a callback function.
+* @param onReady what to do when testFx condition is fulfilled,
+* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
+* as a callback function.
+* @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
+*/
+function waitFor(testFx, onReady, timeOutMillis) {
+ var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3001, //< Default Max Timout is 3s
+ start = new Date().getTime(),
+ condition = false,
+ interval = setInterval(function() {
+ if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
+ // If not time-out yet and condition not yet fulfilled
+ condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
+ } else {
+ if(!condition) {
+ // If condition still not fulfilled (timeout but condition is 'false')
+ console.log("'waitFor()' timeout");
+ phantom.exit(1);
+ } else {
+ // Condition fulfilled (timeout and/or condition is 'true')
+ typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
+ clearInterval(interval); //< Stop this interval
+ }
+ }
+ }, 100); //< repeat check every 250ms
+};
+
+
+if (phantom.args.length === 0 || phantom.args.length > 2) {
+ console.log('Usage: run-qunit.js URL');
+ phantom.exit();
+}
+
+var page = new WebPage();
+
+// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
+page.onConsoleMessage = function(msg) {
+ console.log(msg);
+};
+
+page.open(phantom.args[0], function(status){
+ if (status !== "success") {
+ console.log("Unable to access network");
+ phantom.exit();
+ } else {
+ waitFor(function(){
+ return page.evaluate(function(){
+ var el = document.getElementById('qunit-testresult');
+ if (el && el.innerText.match('completed')) {
+ return true;
+ }
+ return false;
+ });
+ }, function(){
+ var failedNum = page.evaluate(function(){
+ var el = document.getElementById('qunit-testresult');
+ try {
+ return el.getElementsByClassName('failed')[0].innerHTML;
+ } catch (e) { }
+ return 10000;
+ });
+ phantom.exit((parseInt(failedNum, 10) > 0) ? 1 : 0);
+ });
+ }
+});
Please sign in to comment.
Something went wrong with that request. Please try again.