Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated runner, so global dom elements are setup in the test document…

…s instead of stomping all over the globals. also fixed a domtohtml regression
  • Loading branch information...
commit ee035f696ca96064642a3ea9feaae1c9c1b243af 1 parent 337501f
@tmpvar authored
View
1  lib/jsdom/browser/domtohtml.js
@@ -15,7 +15,6 @@ var singleTags = {
input: 1,
isindex: 1,
link: 1,
- meta: 1,
param: 1,
embed: 1
};
View
37 test/level1/core/files/hc_nodtdstaff.xml.js
@@ -1,26 +1,27 @@
+var dom = require(__dirname + "/../../../../lib/jsdom/level1/core").dom.level1.core;
exports.hc_nodtdstaff = function() {
- var doc = new Document("html");
- var implementation = new DOMImplementation(doc, {
+ var doc = new dom.Document("html");
+ var implementation = new dom.DOMImplementation(doc, {
"XML" : "1.0"
});
doc.implementation = implementation;
-
-/*
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>hc_nodtdstaff</title></head><body>
- <p>
- <em>EMP0001</em>
- <strong>Margaret Martin</strong>
- <code>Accountant</code>
- <sup>56,000</sup>
- <var>Female</var>
-
- <acronym title="Yes">1230 North Ave. Dallas, Texas 98551</acronym>
- </p>
-</body></html>
-*/
-
+
+/*
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>hc_nodtdstaff</title></head><body>
+ <p>
+ <em>EMP0001</em>
+ <strong>Margaret Martin</strong>
+ <code>Accountant</code>
+ <sup>56,000</sup>
+ <var>Female</var>
+
+ <acronym title="Yes">1230 North Ave. Dallas, Texas 98551</acronym>
+ </p>
+</body></html>
+*/
+
doc.normalize();
return doc;
-};
+};
View
15 test/level1/core/files/hc_staff.xml.js
@@ -1,12 +1,13 @@
-var sys = require("sys");
+var dom = require(__dirname + "/../../../../lib/jsdom/level1/core").dom.level1.core;
+
exports.hc_staff = function() {
- var doc = new Document("html");
- var implementation = new DOMImplementation(doc, {
+ var doc = new dom.Document("html");
+ var implementation = new dom.DOMImplementation(doc, {
"XML" : "1.0"
});
- var notations = new NotationNodeMap(
+ var notations = new dom.NotationNodeMap(
doc,
doc.createNotationNode("notation1","notation1File", null),
doc.createNotationNode("notation2",null, "notation2File")
@@ -14,7 +15,7 @@ exports.hc_staff = function() {
// TODO: consider importing the master list of entities
// http://www.w3schools.com/tags/ref_symbols.asp
- var entities = new EntityNodeMap(
+ var entities = new dom.EntityNodeMap(
doc,
doc.createEntityNode("alpha", "α"),
doc.createEntityNode("beta", "&#946;"),
@@ -25,14 +26,14 @@ exports.hc_staff = function() {
// <!ATTLIST acronym dir CDATA "ltr">
- var defaultAttributes = new NamedNodeMap(doc);
+ var defaultAttributes = new dom.NamedNodeMap(doc);
var acronym = doc.createElement("acronym");
acronym.setAttribute("dir", "ltr");
defaultAttributes.setNamedItem(acronym);
- var doctype = new DocumentType(doc, "xml", entities, notations, defaultAttributes);
+ var doctype = new dom.DocumentType(doc, "xml", entities, notations, defaultAttributes);
doc.doctype = doctype;
doc.implementation = implementation;
View
115 test/level1/core/files/staff.xml.js
@@ -1,13 +1,13 @@
-var sys = require("sys");
+var dom = require(__dirname + "/../../../../lib/jsdom/level1/core").dom.level1.core;
exports.staff = function() {
- var doc = new Document("staff");
+ var doc = new dom.Document("staff");
- var implementation = new DOMImplementation(doc, {
+ var implementation = new dom.DOMImplementation(doc, {
"XML" : "1.0"
});
- var notations = new NotationNodeMap(
+ var notations = new dom.NotationNodeMap(
doc,
doc.createNotationNode("notation1","notation1File", null),
doc.createNotationNode("notation2",null, "notation2File")
@@ -27,7 +27,7 @@ exports.staff = function() {
ent5.systemId = "entityFile";
ent5.notationName = "notation1";
- var entities = new EntityNodeMap(
+ var entities = new dom.EntityNodeMap(
doc,
doc.createEntityNode("ent1", doc.createTextNode("es")),
doc.createEntityNode("ent2",doc.createTextNode("1900 Dallas Road")),
@@ -36,21 +36,7 @@ exports.staff = function() {
ent5
);
-
-
- // Setup the DTD/Default Attribute Values
-
-/*
-<!ATTLIST entElement
- attr1 CDATA "Attr">
-<!ATTLIST address
- domestic CDATA #IMPLIED
- street CDATA "Yes">
-<!ATTLIST entElement
- domestic CDATA "MALE" >
-*/
-
- var defaultAttributes = new NamedNodeMap(doc);
+ var defaultAttributes = new dom.NamedNodeMap(doc);
var entElement = doc.createElement("entElement");
entElement.setAttribute("attr1", "Attr");
entElement.setAttribute("domestic", "MALE");
@@ -60,7 +46,7 @@ exports.staff = function() {
defaultAddress.setAttribute("street", "Yes");
defaultAttributes.setNamedItem(defaultAddress);
- doc.doctype = new DocumentType(doc, "staff", entities, notations, defaultAttributes);
+ doc.doctype = new dom.DocumentType(doc, "staff", entities, notations, defaultAttributes);
doc.implementation = implementation;
@@ -159,93 +145,6 @@ exports.staff = function() {
positions[4].appendChild(doc.createTextNode("Computer Specialist"));
doc.appendChild(doc.createProcessingInstruction("TEST-STYLE", "PIDATA"));
-
-/*
-<!ELEMENT employeeId (#PCDATA)>
-<!ELEMENT name (#PCDATA)>
-<!ELEMENT position (#PCDATA)>
-<!ELEMENT salary (#PCDATA)>
-<!ELEMENT address (#PCDATA)>
-<!ELEMENT entElement ( #PCDATA ) >
-<!ELEMENT gender ( #PCDATA | entElement )* >
-<!ELEMENT employee (employeeId, name, position, salary, gender, address) >
-<!ELEMENT staff (employee)+>
-<!ATTLIST entElement
- attr1 CDATA "Attr">
-<!ATTLIST address
- domestic CDATA #IMPLIED
- street CDATA "Yes">
-<!ATTLIST entElement
- domestic CDATA "MALE" >
-
-*/
-
- /*<?xml version="1.0"?><?TEST-STYLE PIDATA?>
-<!DOCTYPE staff SYSTEM "staff.dtd" [
- <!ENTITY ent1 "es">
- <!ENTITY ent2 "1900 Dallas Road">
- <!ENTITY ent3 "Texas">
- <!ENTITY ent4 "<entElement domestic='Yes'>Element data</entElement><?PItarget PIdata?>">
- <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
- <!ENTITY ent1 "This entity should be discarded">
- <!NOTATION notation1 PUBLIC "notation1File">
- <!NOTATION notation2 SYSTEM "notation2File">
-]>
-
-<!-- This is comment number 1.-->
-<staff>
- <employee>
- <employeeId>EMP0001</employeeId>
- <name>Margaret Martin</name>
- <position>Accountant</position>
- <salary>56,000</salary>
- <gender>Female</gender>
-
- <address domestic="Yes">1230 North Ave. Dallas, Texas 98551</address>
- </employee>
- <employee>
- <employeeId>EMP0002</employeeId>
- <name>Martha Raynolds<![CDATA[This is a CDATASection with EntityReference number 2 &ent2;]]>
-<![CDATA[This is an adjacent CDATASection with a reference to a tab &tab;]]></name>
- <position>Secretary</position>
-
- <salary>35,000</salary>
- <gender>Female</gender>
- <address domestic="Yes" street="Yes">&ent2; Dallas, &ent3;
- 98554</address>
- </employee>
- <employee>
-
- <employeeId>EMP0003</employeeId>
- <name>Roger
- Jones</name>
- <position>Department Manager</position>
- <salary>100,000</salary>
- <gender>&ent4;</gender>
- <address domestic="Yes" street="No">PO Box 27 Irving, texas 98553</address>
-
- </employee>
- <employee>
- <employeeId>EMP0004</employeeId>
- <name>Jeny Oconnor</name>
- <position>Personnel Director</position>
- <salary>95,000</salary>
- <gender>Female</gender>
-
- <address domestic="Yes" street="Y&ent1;">27 South Road. Dallas, Texas 98556</address>
- </employee>
- <employee>
- <employeeId>EMP0005</employeeId>
- <name>Robert Myers</name>
- <position>Computer Specialist</position>
- <salary>90,000</salary>
-
- <gender>male</gender>
- <address street="Yes">1821 Nordic. Road, Irving Texas 98558</address>
- </employee>
- </staff>
-*/
-
doc.appendChild(doc.createComment(" This is comment number 1."));
doc.appendChild(staff);
View
37 test/level1/html/files/hc_nodtdstaff.html.js
@@ -1,26 +1,27 @@
+var dom = require(__dirname + "/../../../../lib/jsdom/level1/core").dom.level1.core;
exports.hc_nodtdstaff = function() {
- var doc = new Document("html");
- var implementation = new DOMImplementation(doc, {
+ var doc = new dom.Document("html");
+ var implementation = new dom.DOMImplementation(doc, {
"XML" : "1.0"
});
doc.implementation = implementation;
-
-/*
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>hc_nodtdstaff</title></head><body>
- <p>
- <em>EMP0001</em>
- <strong>Margaret Martin</strong>
- <code>Accountant</code>
- <sup>56,000</sup>
- <var>Female</var>
-
- <acronym title="Yes">1230 North Ave. Dallas, Texas 98551</acronym>
- </p>
-</body></html>
-*/
-
+
+/*
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>hc_nodtdstaff</title></head><body>
+ <p>
+ <em>EMP0001</em>
+ <strong>Margaret Martin</strong>
+ <code>Accountant</code>
+ <sup>56,000</sup>
+ <var>Female</var>
+
+ <acronym title="Yes">1230 North Ave. Dallas, Texas 98551</acronym>
+ </p>
+</body></html>
+*/
+
doc.normalize();
return doc;
-};
+};
View
14 test/level1/html/files/hc_staff.html.js
@@ -1,13 +1,13 @@
-var sys = require("sys");
+var dom = require(__dirname + "/../../../../lib/jsdom/level1/core").dom.level1.core;
exports.hc_staff = function() {
- var doc = new Document("html");
+ var doc = new dom.Document("html");
- var implementation = new DOMImplementation(doc, {
+ var implementation = new dom.DOMImplementation(doc, {
"HTML" : "1.0"
});
- var notations = new NotationNodeMap(
+ var notations = new dom.NotationNodeMap(
doc,
doc.createNotationNode("notation1","notation1File", null),
doc.createNotationNode("notation2",null, "notation2File")
@@ -15,7 +15,7 @@ exports.hc_staff = function() {
// TODO: consider importing the master list of entities
// http://www.w3schools.com/tags/ref_symbols.asp
- var entities = new EntityNodeMap(
+ var entities = new dom.EntityNodeMap(
doc,
doc.createEntityNode("alpha", "α"),
doc.createEntityNode("beta", "&#946;"),
@@ -26,14 +26,14 @@ exports.hc_staff = function() {
// <!ATTLIST acronym dir CDATA "ltr">
- var defaultAttributes = new NamedNodeMap(doc);
+ var defaultAttributes = new dom.NamedNodeMap(doc);
var acronym = doc.createElement("acronym");
acronym.setAttribute("dir", "ltr");
defaultAttributes.setNamedItem(acronym);
- var doctype = new DocumentType(doc, "html", entities, notations, defaultAttributes);
+ var doctype = new dom.DocumentType(doc, "html", entities, notations, defaultAttributes);
doc.doctype = doctype;
doc.implementation = implementation;
View
37 test/level1/svg/files/hc_nodtdstaff.svg.js
@@ -1,26 +1,27 @@
+var dom = require(__dirname + "/../../../../lib/jsdom/level1/core").dom.level1.core;
exports.hc_nodtdstaff = function() {
- var doc = new Document("html");
- var implementation = new DOMImplementation(doc, {
+ var doc = new dom.Document("html");
+ var implementation = new dom.DOMImplementation(doc, {
"XML" : "1.0"
});
doc.implementation = implementation;
-
-/*
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>hc_nodtdstaff</title></head><body>
- <p>
- <em>EMP0001</em>
- <strong>Margaret Martin</strong>
- <code>Accountant</code>
- <sup>56,000</sup>
- <var>Female</var>
-
- <acronym title="Yes">1230 North Ave. Dallas, Texas 98551</acronym>
- </p>
-</body></html>
-*/
-
+
+/*
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>hc_nodtdstaff</title></head><body>
+ <p>
+ <em>EMP0001</em>
+ <strong>Margaret Martin</strong>
+ <code>Accountant</code>
+ <sup>56,000</sup>
+ <var>Female</var>
+
+ <acronym title="Yes">1230 North Ave. Dallas, Texas 98551</acronym>
+ </p>
+</body></html>
+*/
+
doc.normalize();
return doc;
-};
+};
View
16 test/level1/svg/files/hc_staff.svg.js
@@ -1,12 +1,12 @@
-var sys = require("sys");
+var dom = require(__dirname + "/../../../../lib/jsdom/level1/core").dom.level1.core;
exports.hc_staff = function() {
- var doc = new Document("html");
- var implementation = new DOMImplementation(doc, {
+ var doc = new dom.Document("html");
+ var implementation = new dom.DOMImplementation(doc, {
"XML" : "1.0"
});
- var notations = new NotationNodeMap(
+ var notations = new dom.NotationNodeMap(
doc,
doc.createNotationNode("notation1","notation1File", null),
doc.createNotationNode("notation2",null, "notation2File")
@@ -14,7 +14,7 @@ exports.hc_staff = function() {
// TODO: consider importing the master list of entities
// http://www.w3schools.com/tags/ref_symbols.asp
- var entities = new EntityNodeMap(
+ var entities = new dom.EntityNodeMap(
doc,
doc.createEntityNode("alpha", "α"),
doc.createEntityNode("beta", "&#946;"),
@@ -25,14 +25,14 @@ exports.hc_staff = function() {
// <!ATTLIST acronym dir CDATA "ltr">
- var defaultAttributes = new NamedNodeMap(doc);
+ var defaultAttributes = new dom.NamedNodeMap(doc);
var acronym = doc.createElement("acronym");
acronym.setAttribute("dir", "ltr");
defaultAttributes.setNamedItem(acronym);
- var doctype = new DocumentType(doc, "svg", entities, notations, defaultAttributes);
+ var doctype = new dom.DocumentType(doc, "svg", entities, notations, defaultAttributes);
doc.doctype = doctype;
doc.implementation = implementation;
@@ -256,4 +256,4 @@ This is an adjacent CDATASection with a reference to a tab &amp;tab;</strong>
<acronym title="Yes">1821 Nordic. Road, Irving Texas 98558</acronym>
</p>
</body></svg>
-*/
+*/
View
14 test/level1/svg/files/staff.svg.js
@@ -1,13 +1,13 @@
-var sys = require("sys");
+var dom = require(__dirname + "/../../../../lib/jsdom/level1/core").dom.level1.core;
exports.staff = function() {
- var doc = new Document("staff");
+ var doc = new dom.Document("staff");
- var implementation = new DOMImplementation(doc, {
+ var implementation = new dom.DOMImplementation(doc, {
"XML" : "1.0"
});
- var notations = new NotationNodeMap(
+ var notations = new dom.NotationNodeMap(
doc,
doc.createNotationNode("notation1","notation1File", null),
doc.createNotationNode("notation2",null, "notation2File")
@@ -36,7 +36,7 @@ exports.staff = function() {
entsvgtest.systemId = "svgtest.js"
- var entities = new EntityNodeMap(
+ var entities = new dom.EntityNodeMap(
doc,
doc.createEntityNode("ent1", doc.createTextNode("es")),
doc.createEntityNode("ent2",doc.createTextNode("1900 Dallas Road")),
@@ -61,7 +61,7 @@ exports.staff = function() {
domestic CDATA "MALE" >
*/
- var defaultAttributes = new NamedNodeMap(doc);
+ var defaultAttributes = new dom.NamedNodeMap(doc);
var entElement = doc.createElement("entElement");
entElement.setAttribute("attr1", "Attr");
entElement.setAttribute("domestic", "MALE");
@@ -71,7 +71,7 @@ exports.staff = function() {
defaultAddress.setAttribute("street", "Yes");
defaultAttributes.setNamedItem(defaultAddress);
- doc.doctype = new DocumentType(doc, "svg", entities, notations, defaultAttributes);
+ doc.doctype = new dom.DocumentType(doc, "svg", entities, notations, defaultAttributes);
doc.implementation = implementation;
View
23 test/runner.js
@@ -32,10 +32,20 @@ global.builder = {
};
global.load = function(docRef, doc, name) {
- return require(__dirname + "/" +
- global.builder.testDirectory +
- "/files/" + name + "." +
- global.builder.type)[name]();
+ var file = __dirname + "/" + global.builder.testDirectory +
+ "/files/" + name + "." + global.builder.type,
+ fn = require(file);
+
+
+ if (!fn[name]) {
+ throw new Error("Test method " + name + " not found..");
+ }
+
+ try {
+ return fn[name].call(global);
+ } catch (e) {
+ debug(e.stack);
+ }
};
global.checkInitialization = function() {
@@ -48,7 +58,7 @@ global.debug = function(val) {
try {
str = JSON.stringify(val, null, " ");
} catch (e) {
- str = sys.inspect(val);
+ str = sys.inspect(val, null, true);
}
sys.puts(str);
process.exit();
@@ -76,7 +86,6 @@ var suites = {
}
},
"level2/core" : { cases: require("./level2/core").tests, setUp : function() {
- mixin(global, require("../lib/jsdom/level2/core").dom.level2.core);
global.builder.contentType = "text/xml";
global.builder.type = "xml";
global.builder.testDirectory = "level2/core";
@@ -125,6 +134,4 @@ var suites = {
*/
};
-
require("mjsunit.runner/lib/runner").run(suites);
-
View
11 test/window/index.js
@@ -1,11 +1,14 @@
exports.tests = {
addmetatohead : function() {
var meta = window.document.createElement("meta");
- window.document.getElementsByTagName("head")[0].appendChild(meta);
- var elements = window.document.getElementsByTagName("head")[0].childNodes;
+ window.document.getElementsByTagName("head").item(0).appendChild(meta);
+ var elements = window.document.getElementsByTagName("head").item(0).childNodes;
+
assertTrue("last element should be the new meta tag",
- elements[elements.length-1] === meta);
+ elements.item(elements.length-1) === meta);
assertTrue("meta should be stringified with a closing tag",
- window.document.innerHTML.indexOf("<meta></meta>") > -1);
+ window.document.innerHTML.indexOf("<meta>") > -1 &&
+ window.document.innerHTML.indexOf("</meta>") > -1
+ );
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.