Permalink
Browse files

Fixed tests to be better

  • Loading branch information...
1 parent dff5001 commit 24abdb53b096aa859110cae75292ff5d26218ff3 @Raynos committed Mar 31, 2012
View
@@ -10,6 +10,6 @@ build:
node build.js
test:
- firefox test/test.html
+ firefox test/test.html &
.PHONY: gh-pages build test
View
@@ -18,7 +18,7 @@ var loadScript = ";(function () {\n" +
" script.src = 'http://localhost:8084?features=' + \n" +
" encodeURIComponent(JSON.stringify(load))\n" +
"\n" +
- " document.body.appendChild(script)\n" +
+ " document.getElementsByTagName('head')[0].appendChild(script)\n" +
"}())"
readDirFiles(featurePath, "utf8", function (err, files) {
View
@@ -1,15 +1,34 @@
;(function () { window.features = {};
(function () {
-features["DOM.EventTarget.addEventListener"] = !!document.addEventListener;
+var works = true;
+try {
+ new CustomEvent("click");
+} catch (e) {
+ works = false;
+}
+features["DOM.CustomEvent.Constructor"] = works;
}());
(function () {
-features["DOM.EventTarget.removeEventListener"] = !!document.removeEventListener;
+features["DOM.CustomEvent.exists"] = !!window.CustomEvent;
}());
(function () {
-features["DOM.EventTarget.dispatchEvent"] = !!document.dispatchEvent;
+var works = false,
+ ev,
+ detail = {};
+
+try {
+ ev = new CustomEvent("click", {
+ bubbles: true,
+ cancelable: true,
+ detail: detail
+ });
+} catch (e) { /* empty */ }
+
+
+features["DOM.CustomEvent.detail"] = (ev && ev.detail === detail);
}());
(function () {
@@ -21,11 +40,11 @@ features["DOM.CharacterData.insertData"] = !!(document.createTextNode('foo').ins
}());
(function () {
-features["DOM.CharacterData.remove"] = !!(document.createTextNode('foo').remove);
+features["DOM.CharacterData.exists"] = !!(window.CharacterData);
}());
(function () {
-features["DOM.CharacterData.exists"] = !!(window.CharacterData);
+features["DOM.CharacterData.remove"] = !!(document.createTextNode('foo').remove);
}());
(function () {
@@ -56,6 +75,18 @@ features["DOM.CharacterData.replace"] = !!(document.createTextNode('foo').replac
features["DOM.CharacterData.deleteData"] = !!(document.createTextNode('foo').deleteData);
}());
+(function () {
+features["DOM.EventTarget.addEventListener"] = !!document.addEventListener;
+}());
+
+(function () {
+features["DOM.EventTarget.removeEventListener"] = !!document.removeEventListener;
+}());
+
+(function () {
+features["DOM.EventTarget.dispatchEvent"] = !!document.dispatchEvent;
+}());
+
(function () {
features["DOM.DOMError.exists"] = !!window.DOMError;
}());
@@ -548,9 +579,12 @@ features["DOM.DOMTokenList.remove"] = !!(document.documentElement.classList && d
}());
(function () {
+var node = document.createElement("div")
+node.className = "foo"
+
features["DOM.DOMTokenList.getter"] = !!(
- document.documentElement.classList &&
- document.documentElement.classList[0]);
+ node.classList &&
+ node.classList[0]);
}());
(function () {
@@ -585,18 +619,6 @@ features["DOM.NodeList.exists"] = !!(window.NodeList);
features["DOM.NodeList.length"] = !!("length" in document.childNodes);
}());
-(function () {
-features["DOM.DocumentFragment.append"] = !!(document.createDocumentFragment().append);
-}());
-
-(function () {
-features["DOM.DocumentFragment.exists"] = !!(window.DocumentFragment);
-}());
-
-(function () {
-features["DOM.DocumentFragment.prepend"] = !!(document.createDocumentFragment().prepend);
-}());
-
(function () {
features["DOM.Element.append"] = !!(document.documentElement.append);
}());
@@ -717,6 +739,18 @@ features["DOM.Element.removeAttributeNS"] = !!(document.documentElement.removeAt
features["DOM.Element.firstElementChild"] = !!("firstElementChild" in document.documentElement);
}());
+(function () {
+features["DOM.DocumentFragment.append"] = !!(document.createDocumentFragment().append);
+}());
+
+(function () {
+features["DOM.DocumentFragment.exists"] = !!(window.DocumentFragment);
+}());
+
+(function () {
+features["DOM.DocumentFragment.prepend"] = !!(document.createDocumentFragment().prepend);
+}());
+
(function () {
features["DOM.Event.initEvent"] = !!document.createEvent("Event").initEvent;
}());
@@ -906,15 +940,15 @@ features["DOM.Range.extractContents"] = !!(document.createRange().extractContent
}());
(function () {
-features["DOM.Range.endContainer"] = !!("endContainer" in document.createRange());
+features["DOM.Range.commonAncestorContainer"] = !!("commonAncestorContainer" in document.createRange());
}());
(function () {
-features["DOM.Range.commonAncestorContainer"] = !!("commonAncestorContainer" in document.createRange());
+features["DOM.Range.startContainer"] = !!("startContainer" in document.createRange());
}());
(function () {
-features["DOM.Range.startContainer"] = !!("startContainer" in document.createRange());
+features["DOM.Range.endContainer"] = !!("endContainer" in document.createRange());
}());
(function () {
@@ -962,58 +996,47 @@ features["DOM.Range.selectNode"] = !!(document.createRange().selectNode);
}());
(function () {
-features["DOM.Attr.localName"] = !!("localName" in document.documentElement.attributes[0]);
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
+
+features["DOM.Attr.localName"] = !!("localName" in attr)
}());
(function () {
features["DOM.Attr.exists"] = !!(window.Attr);
}());
(function () {
-features["DOM.Attr.prefix"] = !!("prefix" in document.documentElement.attributes[0]);
-}());
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
-(function () {
-features["DOM.Attr.namespaceURI"] = !!("namespaceURI" in document.documentElement.attributes[0]);
+features["DOM.Attr.prefix"] = !!("prefix" in attr)
}());
(function () {
-features["DOM.Attr.value"] = !!("value" in document.documentElement.attributes[0]);
-}());
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
-(function () {
-features["DOM.Attr.name"] = !!("name" in document.documentElement.attributes[0]);
+features["DOM.Attr.namespaceURI"] = !!("namespaceURI" in attr)
}());
(function () {
-var works = true;
-try {
- new CustomEvent("click");
-} catch (e) {
- works = false;
-}
-features["DOM.CustomEvent.Constructor"] = works;
-}());
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
-(function () {
-features["DOM.CustomEvent.exists"] = !!window.CustomEvent;
+features["DOM.Attr.value"] = !!("value" in attr)
}());
(function () {
-var works = false,
- ev,
- detail = {};
-
-try {
- ev = new CustomEvent("click", {
- bubbles: true,
- cancelable: true,
- detail: detail
- });
-} catch (e) { /* empty */ }
-
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
-features["DOM.CustomEvent.detail"] = (ev && ev.detail === detail);
+features["DOM.Attr.name"] = !!("name" in attr)
}());
(function () {
@@ -1072,5 +1095,5 @@ features["HTML.Microdata.Document.DocumentFragment.getItems"] = !!(document.crea
script.src = 'http://localhost:8084?features=' +
encodeURIComponent(JSON.stringify(load))
- document.getElementsByTagName("head")[0].appendChild(script)
+ document.getElementsByTagName('head')[0].appendChild(script)
}())
@@ -1 +1,5 @@
-features["DOM.Attr.localName"] = !!("localName" in document.documentElement.attributes[0]);
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
+
+features["DOM.Attr.localName"] = !!("localName" in attr)
@@ -1 +1,5 @@
-features["DOM.Attr.name"] = !!("name" in document.documentElement.attributes[0]);
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
+
+features["DOM.Attr.name"] = !!("name" in attr)
@@ -1 +1,5 @@
-features["DOM.Attr.namespaceURI"] = !!("namespaceURI" in document.documentElement.attributes[0]);
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
+
+features["DOM.Attr.namespaceURI"] = !!("namespaceURI" in attr)
@@ -1 +1,5 @@
-features["DOM.Attr.prefix"] = !!("prefix" in document.documentElement.attributes[0]);
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
+
+features["DOM.Attr.prefix"] = !!("prefix" in attr)
@@ -1 +1,5 @@
-features["DOM.Attr.value"] = !!("value" in document.documentElement.attributes[0]);
+var node = document.createElement("div")
+node.setAttribute("foo", "bar")
+var attr = node.attributes[0]
+
+features["DOM.Attr.value"] = !!("value" in attr)
@@ -1,3 +1,6 @@
+var node = document.createElement("div")
+node.className = "foo"
+
features["DOM.DOMTokenList.getter"] = !!(
- document.documentElement.classList &&
- document.documentElement.classList[0]);
+ node.classList &&
+ node.classList[0]);
View
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html data-attr="true" class="lulz">
+<html>
<head>
<title> Test page </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

0 comments on commit 24abdb5

Please sign in to comment.