| OLD | NEW |
| (Empty) |
| 1 // this function creates element with specified property and contents. | |
| 2 function createElement(type, props, contents) { | |
| 3 if (window.testRunner) | |
| 4 testRunner.dumpAsText(); | |
| 5 | |
| 6 var element = document.createElement(type); | |
| 7 | |
| 8 debug('Created element of type: ' + type); | |
| 9 for (var i in props) { | |
| 10 if (props.hasOwnProperty(i)) { | |
| 11 debug('Set attribute: ' + i + ', value: ' + props[i]); | |
| 12 element.setAttribute(i,props[i]); | |
| 13 } | |
| 14 } | |
| 15 if (contents) { | |
| 16 element.innerHTML = contents; | |
| 17 } | |
| 18 return element; | |
| 19 } | |
| 20 | |
| 21 | |
| 22 // runs a test and writes a log | |
| 23 function runTest(collection, elements, title) { | |
| 24 if (window.testRunner) | |
| 25 testRunner.dumpAsText(); | |
| 26 | |
| 27 pass = true; | |
| 28 | |
| 29 if (collection.length != elements.length) { | |
| 30 pass = false | |
| 31 debug('FAIL - expected ' + elements.length + ' elements but got ' + collecti
on.length + " elements. "); | |
| 32 } | |
| 33 for(var i = 0, max = collection.length > elements.length ? elements.length : c
ollection.length; i < max; i++) { | |
| 34 if(collection[i] != elements[i]) { | |
| 35 debug(title); | |
| 36 pass = false | |
| 37 debug('FAIL - expected element : ' + elements[i].tagName + " but got eleme
nt :" + collection[i].tagName); | |
| 38 debug('FAIL - expected element with id: ' + elements[i].id + " but got ele
ment with id:" + collection[i].id); | |
| 39 } | |
| 40 } | |
| 41 if (pass) | |
| 42 debug(title + ': PASS'); | |
| 43 } | |
| OLD | NEW |