summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/getElementsByClassName/resources/common.js
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/fast/dom/getElementsByClassName/resources/common.js')
-rw-r--r--LayoutTests/fast/dom/getElementsByClassName/resources/common.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/getElementsByClassName/resources/common.js b/LayoutTests/fast/dom/getElementsByClassName/resources/common.js
new file mode 100644
index 0000000..0ea011d
--- /dev/null
+++ b/LayoutTests/fast/dom/getElementsByClassName/resources/common.js
@@ -0,0 +1,21 @@
+// runs a test and writes a log
+function t(collection, elements) {
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var log = "",
+ r = document.getElementById("r"),
+ pass = true
+ if(collection.length != elements.length) {
+ pass = false
+ log += "Got " + collection.length + " elements, expected " + elements.length + ". "
+ }
+ for(var i = 0, max = collection.length > elements.length ? elements.length : collection.length; i < max; i++) {
+ if(collection[i] != elements[i]) {
+ pass = false
+ log += "Got element `" + collection[i].tagName + "` (" + collection[i].namespaceURI + ")"
+ log += ", expected element `" + elements[i].tagName + "` (" + elements[i].namespaceURI + "). "
+ }
+ }
+ r.textContent = pass ? "PASS" : "FAIL (" + log + ")"
+}