1// runs a test and writes a log 2function t(collection, elements) { 3 if (window.layoutTestController) 4 layoutTestController.dumpAsText(); 5 6 var log = "", 7 r = document.getElementById("r"), 8 pass = true 9 if(collection.length != elements.length) { 10 pass = false 11 log += "Got " + collection.length + " elements, expected " + elements.length + ". " 12 } 13 for(var i = 0, max = collection.length > elements.length ? elements.length : collection.length; i < max; i++) { 14 if(collection[i] != elements[i]) { 15 pass = false 16 log += "Got element `" + collection[i].tagName + "` (" + collection[i].namespaceURI + ")" 17 log += ", expected element `" + elements[i].tagName + "` (" + elements[i].namespaceURI + "). " 18 } 19 } 20 r.textContent = pass ? "PASS" : "FAIL (" + log + ")" 21} 22