1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/* eslint-env browser */
/* global selectedMode, okTests, okTestsCount, failedTestsCount, failedTests */
// Keep `var` in this script since it has to be written in ES5 to able run it in old browsers without transpilation.
var fixture = [];
function test(testcase, mode) {
var el = document.createElement('div');
var tester = document.createElement('div');
var prev = tester.style[testcase.property];
tester.style[testcase.property] = testcase[mode];
var next = tester.style[testcase.property];
el.className = 'testcase';
el.innerText =
testcase.id + ' { ' +
testcase.property + ': ' +
testcase[mode] + ' } ' +
(prev === next ? ' / ' + JSON.stringify(prev) + ' -> ' + JSON.stringify(next) : '');
if (prev !== next) {
el.style.backgroundColor = '#dfd';
return { ok: true, el: el };
} else {
el.style.backgroundColor = '#fdd';
return { ok: false, el: el };
}
}
function runMode(mode) {
okTests.innerHTML = '';
failedTests.innerHTML = '';
for (var i = 0; i < fixture.length; i++) {
const result = test(fixture[i], mode);
if (result.ok) {
okTests.appendChild(result.el);
} else {
failedTests.appendChild(result.el);
}
}
okTestsCount.innerText = 'Passed: ' + okTests.children.length;
failedTestsCount.innerText = 'Failed: ' + failedTests.children.length;
}
runMode(selectedMode.value);
|