mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-17 12:50:57 +00:00
163 lines
No EOL
5 KiB
HTML
163 lines
No EOL
5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
"http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
<title>Test suite runner</title>
|
|
<style type="text/css" media="screen">
|
|
#testlog { background: #efefef; margin-bottom: 1em; border: 1px solid #ccc; padding-top: 0.5em; }
|
|
#testlog p { margin: 0.5em; }
|
|
#total { margin-top: 1em; padding: 0.5em; font-weight: bold; margin-bottom: 2em; }
|
|
iframe { border: 1px solid #ccc; }
|
|
.test-name { display: inline-block; width: 20em; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h2>Test suite runner</h2>
|
|
|
|
<script type="text/javascript">
|
|
(function(){
|
|
|
|
var DELAY_BETWEEN_TESTS = 100,
|
|
|
|
elIframe = createIframeEl(),
|
|
elTestlog = getTestlogEl(),
|
|
elTotal = getTotalEl();
|
|
|
|
document.body.appendChild(elTestlog);
|
|
document.body.appendChild(elTotal);
|
|
document.body.appendChild(elIframe);
|
|
|
|
testModules([
|
|
'extensions/prototype_extensions.html',
|
|
'extensions/ape_extensions.html',
|
|
'canvas_element.html',
|
|
'canvas_object.html',
|
|
'canvas_circle.html',
|
|
'canvas_ellipse.html',
|
|
'canvas_line.html',
|
|
'canvas_polyline.html',
|
|
'canvas_polygon.html',
|
|
'canvas_image.html',
|
|
'canvas_text.html',
|
|
'canvas_group.html',
|
|
'canvas_path.html',
|
|
'canvas_path_group.html',
|
|
'canvas_util.html',
|
|
'canvas_color.html',
|
|
'canvas_parser.html'
|
|
]);
|
|
|
|
function testModules(modules) {
|
|
if (!modules.length) return;
|
|
testModule(modules[0], function(){
|
|
var remainingModules = modules.slice(1);
|
|
testModules(remainingModules);
|
|
});
|
|
}
|
|
|
|
function testModule(src, callback) {
|
|
function onload() {
|
|
// cancel both
|
|
elIframe.onload = null;
|
|
if (elIframe.detachEvent) elIframe.detachEvent('onload', onload);
|
|
|
|
waitForTestsCompletion(function(results) {
|
|
logResults(src, results);
|
|
if (callback) {
|
|
setTimeout(callback, DELAY_BETWEEN_TESTS);
|
|
}
|
|
});
|
|
}
|
|
elIframe.onload = onload;
|
|
if (elIframe.attachEvent) {
|
|
elIframe.attachEvent('onload', onload);
|
|
}
|
|
elIframe.src = src;
|
|
}
|
|
|
|
function logResults(moduleName, result) {
|
|
updateTests(moduleName, result);
|
|
updateTotal(result);
|
|
}
|
|
|
|
function updateTests(moduleName, result) {
|
|
var elP = document.createElement('p');
|
|
var elA = document.createElement('a');
|
|
|
|
elA.href = moduleName;
|
|
elA.appendChild(document.createTextNode(moduleName));
|
|
elA.title = '';
|
|
elA.className = 'test-name';
|
|
|
|
elP.appendChild(elA);
|
|
elP.appendChild(document.createTextNode(buildMessageFromResult(result)));
|
|
|
|
elTestlog.appendChild(elP);
|
|
}
|
|
|
|
function updateTotal(result) {
|
|
var totalResult = getTotalResult(result);
|
|
elTotal.innerHTML = ('<span class="test-name">Total:</span>' + buildMessageFromResult(totalResult));
|
|
}
|
|
|
|
function buildMessageFromResult(result) {
|
|
return (
|
|
result.tests + ' tests, ' +
|
|
result.assertions + ' assertions, ' +
|
|
result.failures + ' failures, ' +
|
|
result.errors + ' errors, ' +
|
|
result.warnings + ' warnings'
|
|
);
|
|
}
|
|
|
|
var total = {
|
|
tests: 0, assertions: 0, failures: 0, errors: 0, warnings: 0
|
|
};
|
|
function getTotalResult(result) {
|
|
total.tests += result.tests;
|
|
total.assertions += result.assertions;
|
|
total.failures += result.failures;
|
|
total.errors += result.errors;
|
|
total.warnings += result.warnings;
|
|
return total;
|
|
}
|
|
|
|
function waitForTestsCompletion(callback) {
|
|
var iframeWindow = window.frames[0],
|
|
pollInterval = 100;
|
|
|
|
function poll() {
|
|
if (!iframeWindow.__testsCompleted) {
|
|
setTimeout(poll, pollInterval);
|
|
}
|
|
else {
|
|
callback(iframeWindow.__result);
|
|
}
|
|
}
|
|
poll();
|
|
}
|
|
|
|
function createIframeEl(src) {
|
|
var elIframe = document.createElement('iframe');
|
|
elIframe.width = '100%';
|
|
elIframe.height = '300px';
|
|
return elIframe;
|
|
}
|
|
|
|
function getTestlogEl(){
|
|
var el = document.createElement('div');
|
|
el.id = 'testlog';
|
|
return el;
|
|
}
|
|
|
|
function getTotalEl() {
|
|
var el = document.createElement('p');
|
|
el.id = 'total';
|
|
return el;
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |