Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merging Aria's changes

  • Loading branch information...
commit 8fbb5e4ef35192eec0d99d1895ca47a9d4e358b5 2 parents 53f5763 + 20e006f
@tmpvar authored
Showing with 975 additions and 378 deletions.
  1. +7 −1 lib/jsdom/browser/htmltodom.js
  2. +1 −1  lib/jsdom/browser/index.js
  3. +39 −9 lib/jsdom/level1/core.js
  4. +253 −76 lib/jsdom/level2/core.js
  5. +12 −23 test/level2/core.js
  6. +159 −0 test/level2/core/files/hc_staff.xml.js
  7. 0  test/level2/core/files/{ → orig}/back.gif
  8. 0  test/level2/core/files/{ → orig}/blank.gif
  9. 0  test/level2/core/files/{ → orig}/hc_staff.html
  10. 0  test/level2/core/files/{ → orig}/hc_staff.html.1
  11. 0  test/level2/core/files/{ → orig}/hc_staff.svg
  12. 0  test/level2/core/files/{ → orig}/hc_staff.xhtml
  13. 0  test/level2/core/files/{ → orig}/hc_staff.xhtml.1
  14. 0  test/level2/core/files/{ → orig}/hc_staff.xml
  15. 0  test/level2/core/files/{ → orig}/image2.gif
  16. 0  test/level2/core/files/{ → orig}/index.html
  17. 0  test/level2/core/files/{ → orig}/index.html.1
  18. 0  test/level2/core/files/{ → orig}/index.html?C=D;O=A
  19. 0  test/level2/core/files/{ → orig}/index.html?C=M;O=A
  20. 0  test/level2/core/files/{ → orig}/index.html?C=N;O=D
  21. 0  test/level2/core/files/{ → orig}/index.html?C=S;O=A
  22. 0  test/level2/core/files/{ → orig}/internalSubset01.js
  23. 0  test/level2/core/files/{ → orig}/nodtdstaff.svg
  24. 0  test/level2/core/files/{ → orig}/nodtdstaff.svg.1
  25. 0  test/level2/core/files/{ → orig}/nodtdstaff.xml
  26. 0  test/level2/core/files/{ → orig}/nodtdstaff.xml.1
  27. 0  test/level2/core/files/{ → orig}/robots.txt
  28. 0  test/level2/core/files/{ → orig}/staff.dtd
  29. 0  test/level2/core/files/{ → orig}/staff.dtd.1
  30. 0  test/level2/core/files/{ → orig}/staff.svg
  31. 0  test/level2/core/files/{ → orig}/staff.svg.1
  32. 0  test/level2/core/files/{ → orig}/staff.xml
  33. 0  test/level2/core/files/{ → orig}/staff.xml.1
  34. 0  test/level2/core/files/{ → orig}/staff2.dtd
  35. 0  test/level2/core/files/{ → orig}/staff2.svg
  36. 0  test/level2/core/files/{ → orig}/staff2.xml
  37. 0  test/level2/core/files/{ → orig}/staff2.xml.1
  38. 0  test/level2/core/files/{ → orig}/staffNS.dtd
  39. 0  test/level2/core/files/{ → orig}/staffNS.dtd.1
  40. 0  test/level2/core/files/{ → orig}/staffNS.svg
  41. 0  test/level2/core/files/{ → orig}/staffNS.svg.1
  42. +9 −0 test/level2/core/files/{ → orig}/staffNS.xml
  43. 0  test/level2/core/files/{ → orig}/svgtest.js
  44. 0  test/level2/core/files/{ → orig}/svgunit.js
  45. 0  test/level2/core/files/{ → orig}/text.gif
  46. 0  test/level2/core/files/{ → orig}/unknown.gif
  47. 0  test/level2/core/files/{ → orig}/xhtml-lat1.ent
  48. 0  test/level2/core/files/{ → orig}/xhtml-special.ent
  49. 0  test/level2/core/files/{ → orig}/xhtml-symbol.ent
  50. 0  test/level2/core/files/{ → orig}/xhtml1-frameset.dtd
  51. 0  test/level2/core/files/{ → orig}/xhtml1-strict.dtd
  52. 0  test/level2/core/files/{ → orig}/xhtml1-transitional.dtd
  53. +159 −0 test/level2/core/files/staff.xml.js
  54. +159 −0 test/level2/core/files/staff2.xml.js
  55. +0 −59 test/level2/core/files/staffNS.xml.1
  56. +173 −206 test/level2/core/files/staffNS.xml.js
  57. +4 −3 test/runner.js
View
8 lib/jsdom/browser/htmltodom.js
@@ -74,7 +74,13 @@ var HtmlToDom = function(parser){
}
-
+ } else if(parser && parser.moduleName == 'HTML5') { /* HTML5 parser */
+ this.appendHtmlToElement = function(html, element) {
+ if(typeof html !== 'string') html += '';
+ var p = new parser.Parser({document: element.ownerDocument});
+ var tree = p.parse_fragment(html, element);
+ throw new Error("Fixme!");
+ }
} else {
this.appendHtmlToElement = function(){
View
2  lib/jsdom/browser/index.js
@@ -56,7 +56,7 @@ exports.windowAugmentation = function(dom, options) {
Window.document.documentElement.appendChild(Window.document.createElement('head'));
Window.document.documentElement.appendChild(Window.document.createElement('body'));
- Window.document.getElementsByTagName('head')[0].appendChild(Window.document.createElement('title'));
+ Window.document.getElementsByTagName('head').item(0).appendChild(Window.document.createElement('title'));
Window.document.documentElement.style = {};
Window.document.documentElement.hasAttribute = true;
View
48 lib/jsdom/level1/core.js
@@ -50,7 +50,9 @@ var sys = require("sys");
core.DOMException = function(code, msg) {
this._code = code;
- this._msg = msg || ""
+ Error.call(this, messages[code]);
+ this.message = messages[code];
+ if(Error.captureStackTrace) Error.captureStackTrace(this, core.DOMException);
};
core.DOMException.prototype = {
@@ -72,6 +74,18 @@ var NOT_FOUND_ERR = core.NOT_FOUND_ERR = 8;
var NOT_SUPPORTED_ERR = core.NOT_SUPPORTED_ERR = 9;
var INUSE_ATTRIBUTE_ERR = core.INUSE_ATTRIBUTE_ERR = 10;
+var messages = {}
+messages[INDEX_SIZE_ERR] = "Index size error";
+messages[DOMSTRING_SIZE_ERR] = "DOMString size error";
+messages[HIERARCHY_REQUEST_ERR] = "Heirarchy request error";
+messages[WRONG_DOCUMENT_ERR] = "Wrong document";
+messages[INVALID_CHARACTER_ERR] = "Invalid character";
+messages[NO_DATA_ALLOWED_ERR] = "No data allowed";
+messages[NO_MODIFICATION_ALLOWED_ERR] = "No modification allowed";
+messages[NOT_FOUND_ERR] = "Not found";
+messages[NOT_SUPPORTED_ERR] = "Not supported";
+messages[INUSE_ATTRIBUTE_ERR] = "Attribute in use";
+
core.NodeList = function(document, element, tagName) {
this._document = document;
this._element = element;
@@ -101,10 +115,10 @@ core.LiveNodeList = function(document, element, callback) {
this._callback = callback;
this._element = element;
this._document = document || element;
- var results = core.mapDOMNodes(this._element, true, this._callback);
+/* var results = core.mapDOMNodes(this._element, true, this._callback);
for (var i = 0;i < results.length;i++) {
this[i] = results[i];
- }
+ }*/
};
core.LiveNodeList.prototype = {
@@ -128,22 +142,36 @@ core.DOMImplementation = function(document, /* Object */ features) {
this._ownerDocument = document;
this._features = features;
};
+
core.DOMImplementation.prototype = {
get ownerDocument() { return this._ownerDocument;},
hasFeature: function(/* string */ feature, /* string */ version) {
for (var i in this._features) {
- if (this._features.hasOwnProperty(i) &&
- i.toLowerCase() === feature.toLowerCase() &&
- (this._features[i] === version || !version))
+ if (this._features.hasOwnProperty(i) &&
+ i.toLowerCase() === feature.toLowerCase())
{
- return true;
+ if (!version) {
+ return true;
+ }
+ var versions = this._features[i];
+
+ if (typeof versions === 'string' && versions === version) {
+ return true;
+ } else {
+ var j=0, l=versions.length;
+ for (j; j<l; j++)
+ {
+ if (versions[j] === version) {
+ return true;
+ }
+ }
+ }
}
}
return false;
}
};
-
core.Node = function (ownerDocument) {
this._children = new core.NodeList();
this._nodeValue = null;
@@ -449,6 +477,7 @@ core.Node.prototype = {
if (newChild.ownerDocument &&
this.ownerDocument &&
newChild.ownerDocument !== this.ownerDocument) {
+
throw new core.DOMException(WRONG_DOCUMENT_ERR);
}
@@ -681,7 +710,7 @@ core.NamedNodeMap.prototype = {
}
// arg is from a different document
- if (arg && arg.ownerDocument !== this._ownerDocument) {
+ if (arg && arg._ownerDocument !== this._ownerDocument) {
throw new core.DOMException(WRONG_DOCUMENT_ERR);
}
@@ -976,6 +1005,7 @@ core.DocumentFragment.prototype = {
core.DocumentFragment.prototype.__proto__ = core.Element.prototype;
core.ProcessingInstruction = function (document, target, data) {
+ this._ownerDocument = document;
core.Node.call(this, document);
this._nodeName = target;
this._tagName = target;
View
329 lib/jsdom/level2/core.js
@@ -1,4 +1,21 @@
-var core = require("../level1/core").dom.level1.core;
+var core = require("../level1/core").dom.level1.core,
+ sys = require("sys");
+
+var testNamespaceName = function(ns, nsuri) {
+ if (!ns || ns.match(/[^0-9a-z\.:\-_]/i) !== null) {
+ throw new core.DOMException(core.INVALID_CHARACTER_ERR);
+ }
+ if ((ns === 'xmlns' && nsuri !== "http://www.w3.org/2000/xmlns/") ||
+ (ns === "xml" && nsuri !== "http://www.w3.org/XML/1998/namespace") ||
+ ns.indexOf('::') > -1 ||
+ nsuri === null ||
+ ns[ns.length-1] === ':' || // handle "namespace:"
+ ns[0] === ':' ||
+ ns.match(/.+:.+:/))
+ {
+ throw new core.DOMException(core.NAMESPACE_ERR);
+ }
+}
var INVALID_STATE_ERR = core.INVALID_STATE_ERR = 11;
var SYNTAX_ERR = core.SYNTAX_ERR = 12
@@ -10,10 +27,11 @@ core.DOMImplementation.prototype.createDocumentType = function(/* String */ qual
/* String */ publicId,
/* String */ systemId)
{
- var doctype = new core.DocumentType(this._ownerDocument, qualifiedName);
- doctype.publicId = publicId ? publicId : '';
- doctype.systemId = systemId ? systemId : '';
- return doctype;
+ testNamespaceName(qualifiedName);
+ var doctype = new core.DocumentType(null, qualifiedName);
+ doctype._publicId = publicId ? publicId : '';
+ doctype._systemId = systemId ? systemId : '';
+ return doctype;
};
/**
@@ -24,104 +42,161 @@ core.DOMImplementation.prototype.createDocument = function(/* String */ na
/* String */ qualifiedName,
/* DocumentType */ doctype)
{
-
-
-};
-
-
-core.Element.prototype.getElementsByTagNameNS = function(/* String */ namespaceURI,
- /* String */ localName)
-{
- var queryFunction = function(child) {f
- if (!child) {
- return false;
- }
-
- if (child.nodeType &&
- child.nodeType === dom.Node.prototype.ENTITY_REFERENCE_NODE)
- {
- child = child._entity;
- }
+ testNamespaceName(qualifiedName, namespaceURI);
- var classString = child.className;
- if (classString) {
- var s = classString.split(" ");
- for (var i=0; i<s.length; i++) {
- if (s[i] === className) {
- return true;
- }
- }
- }
- return false;
- }
+ if (doctype && doctype.ownerDocuemnt !== null) {
+ throw new core.DOMException(core.WRONG_DOCUMENT_ERR);
+ }
- if (this.ownerDocument &&
- this.ownerDocument.implementation &&
- this.ownerDocument.implementation.hasFeature("DisableLiveLists"))
- {
- return dom.mapDOMNodes(this, true, queryFunction);
- } else {
- return new dom.LiveNodeList(this._document, this, queryFunction);
- }
+ var document = new core.Document();
+ document.namespaceURI = namespaceURI;
+ document.qualifiedName = qualifiedName;
+ document.doctype = doctype;
+ document._ownerDocument = document;
+ return document;
};
-
core.Node.prototype.__defineGetter__("ownerDocument", function() {
-
+ return this._ownerDocument || null;
});
-core.Node.prototype.isSupported = function(/* string */ feature, /* string */ version) {
-
-
+core.Node.prototype.isSupported = function(/* string */ feature,
+ /* string */ version)
+{
+ return this._ownerDocument._implementation.hasFeature(feature, version);
};
+core.Node.prototype._namespaceURI = null;
core.Node.prototype.__defineGetter__("namespaceURI", function() {
-
+ return this._namespaceURI || null;
+});
+
+core.Node.prototype.__defineSetter__("namespaceURI", function(value) {
+ this._namespaceURI = value;
});
core.Node.prototype.__defineGetter__("prefix", function() {
-
+ return this._prefix || null;
});
-core.Node.prototype.__defineSetter__("prefix", function() {
- throw new core.DOMException();
+core.Node.prototype.__defineSetter__("prefix", function(value) {
+ if (this._prefix === "xmlns") {
+ throw new core.DOMException(core.NAMESPACE_ERR);
+ }
+ testNamespaceName(value, this._namespaceURI);
+
+ this._prefix = value;
});
core.Node.prototype.__defineGetter__("localName", function() {
-
+ return this._localName || null;
});
/* return boolean */
core.Node.prototype.hasAttributes = function() {
-
+ return (this._attributes && this._attributes.length > 0);
};
core.NamedNodeMap.prototype.getNamedItemNS = function(/* string */ namespaceURI,
/* string */ localName)
{
+ var defaultNode = null;
+ return this._map(function(item) {
+
+ if (namespaceURI === item.namespaceURI)
+ {
+ if (item.localName === localName) {
+ return true;
+ }
+ } else if (!namespaceURI && !defaultNode) {
+ defaultNode = true;
+ return true;
+ }
+ return false;
+ })[0] || null;
+};
+core.AttrNodeMap.prototype.setNamedItem = function(/* Node */ arg) {
+ if (arg.nodeType !== this._ownerDocument.ATTRIBUTE_NODE) {
+ throw new core.DOMException(core.HIERARCHY_REQUEST_ERR);
+ }
+
+ return core.NamedNodeMap.prototype.setNamedItem.call(this, arg);
};
core.NamedNodeMap.prototype.setNamedItemNS = function(/* Node */ arg)
{
+ var owner = this._ownerDocument;
+ if (this.parentNode &&
+ this.parentNode.parentNode &&
+ this.parentNode.parentNode.nodeType === owner.ENTITY_NODE)
+ {
+ throw new core.DOMException(core.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ if (arg.nodeType !== owner.ATTRIBUTE_NODE) {
+ throw new core.DOMException(core.HIERARCHY_REQUEST_ERR);
+ }
+
+ if (arg.parentNode) {
+ throw new core.DOMException(core.INUSE_ATTRIBUTE_ERR);
+ }
+ return this.setNamedItem(arg);
};
core.NamedNodeMap.prototype.removeNamedItemNS = function(/*string */ namespaceURI,
/* string */ localName)
{
+ if (this.parentNode &&
+ this.parentNode.parentNode &&
+ this.parentNode.parentNode.nodeType === this._ownerDocument.ENTITY_NODE)
+ {
+ throw new core.DOMException(core.NO_MODIFICATION_ALLOWED_ERR);
+ }
+
+ throw new core.DOMException(core.NOT_FOUND_ERR);
};
core.Attr.prototype.__defineGetter__("ownerElement", function() {
+ return this._ownerElement || null;
+});
+core.Node.prototype.__defineSetter__("qualifiedName", function(qualifiedName) {
+ testNamespaceName(qualifiedName, this._namespaceURI);
+ qualifiedName = qualifiedName || "";
+ this._localName = qualifiedName.split(":")[1] || null;
+ this.prefix = qualifiedName.split(":")[0] || null;
+ this._qualifiedName = qualifiedName;
});
+core.NamedNodeMap.prototype._map = function(fn) {
+
+ if (this._attributes && this._attributes.length) {
+ var ret = [], l = this._attributes.length, i = 0, attribute;
+ for(i; i<l; i++) {
+ attribute = this._attributes.item(i);
+ if (fn && fn(attribute)) {
+ ret.push(attribute);
+ }
+ }
+ return ret;
+ }
+ return [];
+};
core.Element.prototype.getAttributeNS = function(/* string */ namespaceURI,
/* string */ localName)
{
-
+ var attr = this._attributes._map(function(attr) {
+ if (namespaceURI === attr.namespaceURI &&
+ attr.localName === localName)
+ {
+ return true;
+ }
+ })[0];
+
+ return (attr) ? attr.nodeValue : null;
};
core.Element.prototype.setAttributeNS = function(/* string */ namespaceURI,
@@ -129,40 +204,107 @@ core.Element.prototype.setAttributeNS = function(/* string */ namespaceURI,
/* string */ value)
{
+ testNamespaceName(qualifiedName, namespaceURI);
+
+ if (qualifiedName.split(':').shift() === "xml" &&
+ namespaceURI !== "http://www.w3.org/XML/1998/namespace")
+ {
+ throw new core.DOMException(core.NAMESPACE_ERR);
+ }
+
+
+ var attr = this.setAttribute(qualifiedName, value);
+ attr.namespaceURI = namespaceURI;
+ var s = qualifiedName.split(':');
+ attr._localName = s.pop();
+ attr._prefix = (s.length > 0) ? s.pop() : null;
+
+
+ return attr;
};
core.Element.prototype.removeAttributeNS = function(/* string */ namespaceURI,
/* string */ localName)
{
-
+ var qualifiedName = this._attributes._map(function(attr) {
+ if (namespaceURI === attr.namespaceURI &&
+ attr.localName === localName)
+ {
+ return true;
+ }
+ })[0] || null;
+ return this.removeAttribute(qualifiedName);
};
core.Element.prototype.getAttributeNodeNS = function(/* string */ namespaceURI,
/* string */ localName)
{
-
+ return this._attributes._map(function(attr) {
+ if (namespaceURI === attr.namespaceURI &&
+ attr.localName === localName)
+ {
+ return true;
+ }
+ })[0] || null;
};
core.Element.prototype.setAttributeNodeNS = function(/* Attr */ newAttr)
{
+ if (newAttr.ownerElement) {
+ throw new core.DOMException(core.INUSE_ATTRIBUTE_ERR);
+ }
+ newAttr._ownerElement = this;
+ return this.setAttributeNode(newAttr);
};
-core.Element.prototype.getElementsByTagNameNS = function(/* string */ namespaceURI,
- /* string */ localName)
+core.Element.prototype.getElementsByTagNameNS = function(/* String */ namespaceURI,
+ /* String */ localName)
{
+ var nsPrefixCache = {};
+ var queryFunction = function(child) {
+ if (child.nodeType && child.nodeType === this.ENTITY_REFERENCE_NODE) {
+ child = child._entity;
+ }
+
+ var localMatch = child.localName === localName,
+ nsMatch = child.namespaceURI === namespaceURI;
+ if ((localMatch || localName === "*") &&
+ (nsMatch || namespaceURI === "*"))
+ {
+ return true;
+ }
+ return false;
+ }
+ if (this.ownerDocument &&
+ this.ownerDocument.implementation &&
+ this.ownerDocument.implementation.hasFeature("DisableLiveLists"))
+ {
+ return core.mapDOMNodes(this, true, queryFunction);
+ } else {
+ return new core.LiveNodeList(this._document, this, queryFunction);
+ }
};
core.Element.prototype.hasAttribute = function(/* string */name)
{
-
+ if (!this.attributes()) {
+ return false;
+ }
+ return this.attributes().exists(name);
};
core.Element.prototype.hasAttributeNS = function(/* string */namespaceURI,
/* string */localName)
{
-
+ if (!this._attributes ||
+ !this._attributes.length ||
+ this._attributes.length < 1)
+ {
+ return false;
+ }
+ return this.hasAttribute(localName);
};
core.DocumentType.prototype.__defineGetter__("publicId", function() {
@@ -174,36 +316,74 @@ core.DocumentType.prototype.__defineGetter__("systemId", function() {
});
core.DocumentType.prototype.__defineGetter__("internalSubset", function() {
- return this._internalSubset || "";
+ return this._internalSubset || null;
});
core.Document.prototype.importNode = function(/* Node */ importedNode,
- /* bool */ deep)
+ /* bool */ deep)
{
-
+ if (importedNode && importedNode.nodeType) {
+ if (importedNode.nodeType === this.DOCUMENT_NODE ||
+ importedNode.nodeType === this.DOCUMENT_TYPE_NODE) {
+ throw new core.DOMException(core.NOT_SUPPORTED_ERR);
+ }
+ }
+
+ var newNode = importedNode.cloneNode(deep);
+ newNode._ownerDocument = this;
+ newNode._ownerElement = null;
+ newNode._prefix = importedNode.prefix;
+ newNode._localName = importedNode.localName;
+ newNode._namespaceURI = importedNode.namespaceURI;
+ return newNode;
};
core.Document.prototype.createElementNS = function(/* string */ namespaceURI,
/* string */ qualifiedName)
{
+ testNamespaceName(qualifiedName, namespaceURI);
+ var element = this.createElement(qualifiedName),
+ sploded = qualifiedName.split(':');
+
+ element.namespaceURI = namespaceURI;
+ element.qualifiedName = qualifiedName;
+
+ element._localName = sploded.pop();
+
+ if (sploded.length > 0) {
+ element.prefix = sploded.pop();
+ } else if (namespaceURI === "http://www.w3.org/2000/xmlns/") {
+ element.prefix = "xmlns";
+ } else if (namespaceURI === "http://www.w3.org/XML/1998/namespace") {
+ element.prefix = "xml";
+ }
+
+ return element;
};
core.Document.prototype.createAttributeNS = function(/* string */ namespaceURI,
/* string */ qualifiedName)
{
-
-};
-
-core.Document.prototype.getElementsByTagNameNS = function(/* string */ namespaceURI,
- /* string */ localName)
-{
-
+ testNamespaceName(qualifiedName, namespaceURI);
+ var attribute = this.createAttribute(qualifiedName);
+ attribute.qualifiedName = qualifiedName;
+ attribute.namespaceURI = namespaceURI;
+ var s = qualifiedName.split(':');
+ attribute._localName = s.pop();
+ attribute._prefix = (s.length > 0) ? s.pop() : null;
+ return attribute;
};
-core.Document.prototype.getElementById = function(/* string */ elementId)
-{
-
+core.Document.prototype.getElementById = function(id) {
+ return core.mapDOMNodes(this, true, function(element) {
+ if (element && element.getAttribute) {
+ var elementId = element.getAttribute("id");
+ if (elementId === id) {
+ return true;
+ }
+ }
+ })[0] || null;
};
exports.dom =
@@ -212,6 +392,3 @@ exports.dom =
core : core
}
};
-
-
-
View
35 test/level2/core.js
@@ -24,16 +24,19 @@ attrgetownerelement01 : function () {
var attributes;
var nullNS = null;
+
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
elementList = doc.getElementsByTagNameNS("http://www.nist.gov","employee");
+
element = elementList.item(1);
attributes = element.attributes;
attr = attributes.getNamedItemNS(nullNS,"defaultAttr");
+
ownerElement = attr.ownerElement;
ownerElementName = ownerElement.nodeName;
@@ -68,6 +71,7 @@ attrgetownerelement02 : function () {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
+
element = doc.createElement("root");
attr = doc.createAttributeNS("http://www.w3.org/DOM/L1","L1:att");
newAttr = element.setAttributeNodeNS(attr);
@@ -869,7 +873,8 @@ createDocument08 : function () {
var domImpl;
var aNewDoc;
var charact;
- domImpl = getImplementation();
+ var doc = load(null, "doc", "staffNS");
+ domImpl = doc.implementation;
{
success = false;
@@ -1070,7 +1075,7 @@ createDocumentType04 : function () {
var docType = null;
var domImpl;
- domImpl = getImplementation();
+ domImpl = load(null, "doc", "staffNS").implementation;
{
success = false;
@@ -2759,7 +2764,7 @@ documentimportnode14 : function () {
doc = load(docRef, "doc", "staffNS");
childList = doc.getElementsByTagNameNS("*","employee");
employeeElem = childList.item(3);
- domImpl = getImplementation();
+ domImpl = load(null, "doc", "staffNS").implementation;
newDoc = domImpl.createDocument(nullNS,"staff",nullDocType);
imported = newDoc.importNode(employeeElem,true);
attrNode = imported.getAttributeNodeNS(nullNS,"defaultAttr");
@@ -3751,7 +3756,7 @@ for(var indexN10073 = 0;indexN10073 < qualifiedNames.length; indexN10073++) {
Retrieve the entire DOM document and invoke its
- "getImplementation()" method. This should create a
+ "load(null, "doc", "staffNS").implementation" method. This should create a
DOMImplementation object whose "hasFeature(feature,
@@ -3796,7 +3801,7 @@ assertTrue("domimplementationFeaturecoreAssert",state);
Retrieve the entire DOM document and invoke its
- "getImplementation()" method. This should create a
+ "load(null, "doc", "staffNS").implementation" method. This should create a
DOMImplementation object whose "hasFeature(feature,
@@ -11501,7 +11506,6 @@ prefix09 : function () {
elementList = doc.getElementsByTagName("address");
addrNode = elementList.item(3);
addrAttr = addrNode.getAttributeNode("xmlns");
-
{
success = false;
try {
@@ -12462,23 +12466,8 @@ setAttributeNodeNS02 : function () {
docRef = this.doc;
}
doc = load(docRef, "doc", "staffNS");
-
- if(
- (getImplementationAttribute("expandEntityReferences") == false)
- ) {
- genderList = doc.getElementsByTagName("gender");
- gender = genderList.item(2);
- genList = gender.childNodes;
-
- gen = genList.item(0);
-
- }
-
- else {
- gen = doc.createEntityReference("ent4");
-
- }
- gList = gen.childNodes;
+ gen = doc.createEntityReference("ent4");
+ gList = gen.childNodes;
genElement = gList.item(0);
assertNotNull("notnull",genElement);
View
159 test/level2/core/files/hc_staff.xml.js
@@ -0,0 +1,159 @@
+var sys = require("sys"),
+ dom = require(__dirname + "/../../../../lib/jsdom/level2/core").dom.level2.core;
+
+exports.hc_staff = function() {
+
+ var doc = new dom.Document("html");
+ var implementation = new dom.DOMImplementation(doc, {
+ "XML" : ["1.0", "2.0"],
+ "core": ["1.0", "2.0", "3.0"]
+ });
+
+ var notations = new dom.NotationNodeMap(
+ doc,
+ doc.createNotationNode("notation1","notation1File", null),
+ doc.createNotationNode("notation2",null, "notation2File")
+ );
+
+ // TODO: consider importing the master list of entities
+ // http://www.w3schools.com/tags/ref_symbols.asp
+ var entities = new dom.EntityNodeMap(
+ doc,
+ doc.createEntityNode("alpha", "α"),
+ doc.createEntityNode("beta", "&#946;"),
+ doc.createEntityNode("gamma", "&#947;"),
+ doc.createEntityNode("delta", "&#948;"),
+ doc.createEntityNode("epsilon", "&#949;")
+ );
+
+ // <!ATTLIST acronym dir CDATA "ltr">
+
+ var defaultAttributes = new dom.NamedNodeMap(doc);
+ var acronym = doc.createElementNS("http://www.w3.org/2000/xmlns/","acronym");
+ acronym.setAttribute("dir", "ltr");
+ defaultAttributes.setNamedItem(acronym);
+
+
+
+ var doctype = new dom.DocumentType(doc, "xml", entities, notations, defaultAttributes);
+ doc.doctype = doctype;
+ doc.implementation = implementation;
+
+ doc.appendChild(doc.createComment(" This is comment number 1."));
+
+ var html = doc.createElementNS("http://www.w3.org/2000/xmlns/","html");
+ var html = doc.appendChild(html);
+
+ var head = doc.createElementNS("http://www.w3.org/2000/xmlns/","head");
+ var head = html.appendChild(head);
+
+ var meta = doc.createElementNS("http://www.w3.org/2000/xmlns/","meta");
+ meta.setAttribute("http-equiv", "Content-Type");
+ meta.setAttribute("content", "text/html; charset=UTF-8");
+ head.appendChild(meta);
+
+ var title = doc.createElementNS("http://www.w3.org/2000/xmlns/","title")
+ title.appendChild(doc.createTextNode("hc_staff"));
+ var title = head.appendChild(title);
+
+ // make the tests work....
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+
+ var body = doc.createElementNS("http://www.w3.org/2000/xmlns/","body");
+ var staff = html.appendChild(body);
+
+ var employees = [];
+ var addresses = [];
+ var names = [];
+ var positions = [];
+ var genders = [];
+ var ids = [];
+ var salaries = [];
+
+ // create 5 employees
+ for (var i=0; i<5; i++)
+ {
+ var employee = doc.createElementNS("http://www.w3.org/2000/xmlns/","p");
+ var address = doc.createElementNS("http://www.w3.org/2000/xmlns/","acronym");
+ var name = doc.createElementNS("http://www.w3.org/2000/xmlns/","strong");
+ var position = doc.createElementNS("http://www.w3.org/2000/xmlns/","code");
+ var gender = doc.createElementNS("http://www.w3.org/2000/xmlns/","var");
+ var id = doc.createElementNS("http://www.w3.org/2000/xmlns/","em");
+ var salary = doc.createElementNS("http://www.w3.org/2000/xmlns/","sup");
+
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(id);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(name);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(position);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(salary);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(gender);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(address);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ staff.appendChild(employee);
+
+ names.push(name);
+ employees.push(employee);
+ addresses.push(address);
+ genders.push(gender);
+ positions.push(position);
+ ids.push(id);
+ salaries.push(salary);
+ }
+
+ ids[0].appendChild(doc.createTextNode("EMP0001"));
+ salaries[0].appendChild(doc.createTextNode("56,000"));
+ addresses[0].setAttribute("title", "Yes");
+ addresses[0].appendChild(doc.createTextNode('1230 North Ave. Dallas, Texas 98551'));
+ names[0].appendChild(doc.createTextNode("Margaret Martin"));
+ genders[0].appendChild(doc.createTextNode("Female"));
+ positions[0].appendChild(doc.createTextNode("Accountant"));
+
+ ids[1].appendChild(doc.createTextNode("EMP0002"));
+ salaries[1].appendChild(doc.createTextNode("35,000"));
+ addresses[1].setAttribute("title", "Yes");
+ addresses[1].setAttribute("class", "Yes");
+ addresses[1].appendChild(doc.createTextNode("β Dallas, γ\n 98554"));
+ names[1].appendChild(doc.createTextNode("Martha Raynolds"));
+ names[1].appendChild(doc.createCDATASection("This is a CDATASection with EntityReference number 2 &amp;ent2;"));
+ names[1].appendChild(doc.createCDATASection("This is an adjacent CDATASection with a reference to a tab &amp;tab;"));
+ genders[1].appendChild(doc.createTextNode("Female"));
+ positions[1].appendChild(doc.createTextNode("Secretary"));
+
+ ids[2].appendChild(doc.createTextNode("EMP0003"));
+ salaries[2].appendChild(doc.createTextNode("100,000"));
+ addresses[2].setAttribute("title", "Yes");
+ addresses[2].setAttribute("class", "No");
+ addresses[2].appendChild(doc.createTextNode("PO Box 27 Irving, texas 98553"));
+ names[2].appendChild(doc.createTextNode("Roger\n Jones")) ;
+ genders[2].appendChild(doc.createEntityReference("&delta;"));//Text("&delta;"));
+ positions[2].appendChild(doc.createTextNode("Department Manager"));
+
+ ids[3].appendChild(doc.createTextNode("EMP0004"));
+ salaries[3].appendChild(doc.createTextNode("95,000"));
+ addresses[3].setAttribute("title", "Yes");
+ addresses[3].setAttribute("class", "");
+ addresses[3].appendChild(doc.createTextNode("27 South Road. Dallas, Texas 98556"));
+ names[3].appendChild(doc.createTextNode("Jeny Oconnor"));
+ genders[3].appendChild(doc.createTextNode("Female"));
+ positions[3].appendChild(doc.createTextNode("Personal Director"));
+
+ ids[4].appendChild(doc.createTextNode("EMP0005"));
+ salaries[4].appendChild(doc.createTextNode("90,000"));
+ addresses[4].setAttribute("title", "Yes");
+ addresses[4].appendChild(doc.createTextNode("1821 Nordic. Road, Irving Texas 98558"));
+ names[4].appendChild(doc.createTextNode("Robert Myers"));
+ genders[4].appendChild(doc.createTextNode("male"));
+ positions[4].appendChild(doc.createTextNode("Computer Specialist"));
+
+ doc.appendChild(doc.createProcessingInstruction("TEST-STYLE", "PIDATA"));
+
+ doc.normalize();
+ return doc;
+};
View
0  test/level2/core/files/back.gif → test/level2/core/files/orig/back.gif
File renamed without changes
View
0  test/level2/core/files/blank.gif → test/level2/core/files/orig/blank.gif
File renamed without changes
View
0  test/level2/core/files/hc_staff.html → test/level2/core/files/orig/hc_staff.html
File renamed without changes
View
0  test/level2/core/files/hc_staff.html.1 → test/level2/core/files/orig/hc_staff.html.1
File renamed without changes
View
0  test/level2/core/files/hc_staff.svg → test/level2/core/files/orig/hc_staff.svg
File renamed without changes
View
0  test/level2/core/files/hc_staff.xhtml → test/level2/core/files/orig/hc_staff.xhtml
File renamed without changes
View
0  test/level2/core/files/hc_staff.xhtml.1 → test/level2/core/files/orig/hc_staff.xhtml.1
File renamed without changes
View
0  test/level2/core/files/hc_staff.xml → test/level2/core/files/orig/hc_staff.xml
File renamed without changes
View
0  test/level2/core/files/image2.gif → test/level2/core/files/orig/image2.gif
File renamed without changes
View
0  test/level2/core/files/index.html → test/level2/core/files/orig/index.html
File renamed without changes
View
0  test/level2/core/files/index.html.1 → test/level2/core/files/orig/index.html.1
File renamed without changes
View
0  test/level2/core/files/index.html?C=D;O=A → test/level2/core/files/orig/index.html?C=D;O=A
File renamed without changes
View
0  test/level2/core/files/index.html?C=M;O=A → test/level2/core/files/orig/index.html?C=M;O=A
File renamed without changes
View
0  test/level2/core/files/index.html?C=N;O=D → test/level2/core/files/orig/index.html?C=N;O=D
File renamed without changes
View
0  test/level2/core/files/index.html?C=S;O=A → test/level2/core/files/orig/index.html?C=S;O=A
File renamed without changes
View
0  test/level2/core/files/internalSubset01.js → test/level2/core/files/orig/internalSubset01.js
File renamed without changes
View
0  test/level2/core/files/nodtdstaff.svg → test/level2/core/files/orig/nodtdstaff.svg
File renamed without changes
View
0  test/level2/core/files/nodtdstaff.svg.1 → test/level2/core/files/orig/nodtdstaff.svg.1
File renamed without changes
View
0  test/level2/core/files/nodtdstaff.xml → test/level2/core/files/orig/nodtdstaff.xml
File renamed without changes
View
0  test/level2/core/files/nodtdstaff.xml.1 → test/level2/core/files/orig/nodtdstaff.xml.1
File renamed without changes
View
0  test/level2/core/files/robots.txt → test/level2/core/files/orig/robots.txt
File renamed without changes
View
0  test/level2/core/files/staff.dtd → test/level2/core/files/orig/staff.dtd
File renamed without changes
View
0  test/level2/core/files/staff.dtd.1 → test/level2/core/files/orig/staff.dtd.1
File renamed without changes
View
0  test/level2/core/files/staff.svg → test/level2/core/files/orig/staff.svg
File renamed without changes
View
0  test/level2/core/files/staff.svg.1 → test/level2/core/files/orig/staff.svg.1
File renamed without changes
View
0  test/level2/core/files/staff.xml → test/level2/core/files/orig/staff.xml
File renamed without changes
View
0  test/level2/core/files/staff.xml.1 → test/level2/core/files/orig/staff.xml.1
File renamed without changes
View
0  test/level2/core/files/staff2.dtd → test/level2/core/files/orig/staff2.dtd
File renamed without changes
View
0  test/level2/core/files/staff2.svg → test/level2/core/files/orig/staff2.svg
File renamed without changes
View
0  test/level2/core/files/staff2.xml → test/level2/core/files/orig/staff2.xml
File renamed without changes
View
0  test/level2/core/files/staff2.xml.1 → test/level2/core/files/orig/staff2.xml.1
File renamed without changes
View
0  test/level2/core/files/staffNS.dtd → test/level2/core/files/orig/staffNS.dtd
File renamed without changes
View
0  test/level2/core/files/staffNS.dtd.1 → test/level2/core/files/orig/staffNS.dtd.1
File renamed without changes
View
0  test/level2/core/files/staffNS.svg → test/level2/core/files/orig/staffNS.svg
File renamed without changes
View
0  test/level2/core/files/staffNS.svg.1 → test/level2/core/files/orig/staffNS.svg.1
File renamed without changes
View
9 test/level2/core/files/staffNS.xml → test/level2/core/files/orig/staffNS.xml
@@ -13,6 +13,7 @@
]>
<!-- This is comment number 1.-->
<staff>
+
<employee xmlns="http://www.nist.gov" xmlns:dmstc="http://www.usa.com">
<employeeId>EMP0001</employeeId>
<name>Margaret Martin</name>
@@ -21,6 +22,8 @@
<gender>Female</gender>
<address dmstc:domestic="Yes">1230 North Ave. Dallas, Texas 98551</address>
</employee>
+
+
<employee xmlns:dmstc="http://www.usa.com">
<employeeId>EMP0002</employeeId>
<name>Martha Raynolds
@@ -32,6 +35,8 @@
<address dmstc:domestic="Yes" street="Yes">&ent2; Dallas, &ent3;
98554</address>
</employee>
+
+
<employee xmlns:dmstc="http://www.netzero.com">
<employeeId>EMP0003</employeeId>
<name>Roger
@@ -41,6 +46,8 @@
<gender>&ent4;</gender>
<address dmstc:domestic="Yes" street="No">PO Box 27 Irving, texas 98553</address>
</employee>
+
+
<emp:employee xmlns:emp="http://www.nist.gov" xmlns:nm="http://www.altavista.com" > <emp:employeeId>EMP0004</emp:employeeId>
<nm:name>Jeny Oconnor</nm:name>
<emp:position>Personnel Director</emp:position>
@@ -48,6 +55,8 @@
<emp:gender>Female</emp:gender>
<emp:address emp:domestic="Yes" street="Y&ent1;" emp:zone="CANADA" emp:local1="TRUE">27 South Road. Dallas, texas 98556</emp:address>
</emp:employee>
+
+
<employee xmlns:emp2="http://www.nist.gov">
<employeeId>EMP0005</employeeId>
<name>Robert Myers</name>
View
0  test/level2/core/files/svgtest.js → test/level2/core/files/orig/svgtest.js
File renamed without changes
View
0  test/level2/core/files/svgunit.js → test/level2/core/files/orig/svgunit.js
File renamed without changes
View
0  test/level2/core/files/text.gif → test/level2/core/files/orig/text.gif
File renamed without changes
View
0  test/level2/core/files/unknown.gif → test/level2/core/files/orig/unknown.gif
File renamed without changes
View
0  test/level2/core/files/xhtml-lat1.ent → test/level2/core/files/orig/xhtml-lat1.ent
File renamed without changes
View
0  test/level2/core/files/xhtml-special.ent → test/level2/core/files/orig/xhtml-special.ent
File renamed without changes
View
0  test/level2/core/files/xhtml-symbol.ent → test/level2/core/files/orig/xhtml-symbol.ent
File renamed without changes
View
0  test/level2/core/files/xhtml1-frameset.dtd → test/level2/core/files/orig/xhtml1-frameset.dtd
File renamed without changes
View
0  test/level2/core/files/xhtml1-strict.dtd → test/level2/core/files/orig/xhtml1-strict.dtd
File renamed without changes
View
0  test/level2/core/files/xhtml1-transitional.dtd → test/level2/core/files/orig/xhtml1-transitional.dtd
File renamed without changes
View
159 test/level2/core/files/staff.xml.js
@@ -0,0 +1,159 @@
+var sys = require("sys"),
+ dom = require(__dirname + "/../../../../lib/jsdom/level2/core").dom.level2.core;
+
+exports.staff = function() {
+
+ var doc = new dom.Document("html");
+ var implementation = new dom.DOMImplementation(doc, {
+ "XML" : ["1.0", "2.0"],
+ "core": ["1.0", "2.0", "3.0"]
+ });
+
+ var notations = new dom.NotationNodeMap(
+ doc,
+ doc.createNotationNode("notation1","notation1File", null),
+ doc.createNotationNode("notation2",null, "notation2File")
+ );
+
+ // TODO: consider importing the master list of entities
+ // http://www.w3schools.com/tags/ref_symbols.asp
+ var entities = new dom.EntityNodeMap(
+ doc,
+ doc.createEntityNode("alpha", "α"),
+ doc.createEntityNode("beta", "&#946;"),
+ doc.createEntityNode("gamma", "&#947;"),
+ doc.createEntityNode("delta", "&#948;"),
+ doc.createEntityNode("epsilon", "&#949;")
+ );
+
+ // <!ATTLIST acronym dir CDATA "ltr">
+
+ var defaultAttributes = new dom.NamedNodeMap(doc);
+ var acronym = doc.createElementNS("http://www.w3.org/2000/xmlns/","acronym");
+ acronym.setAttribute("dir", "ltr");
+ defaultAttributes.setNamedItem(acronym);
+
+
+
+ var doctype = new dom.DocumentType(doc, "xml", entities, notations, defaultAttributes);
+ doc.doctype = doctype;
+ doc.implementation = implementation;
+
+ doc.appendChild(doc.createComment(" This is comment number 1."));
+
+ var html = doc.createElementNS("http://www.w3.org/2000/xmlns/","html");
+ var html = doc.appendChild(html);
+
+ var head = doc.createElementNS("http://www.w3.org/2000/xmlns/","head");
+ var head = html.appendChild(head);
+
+ var meta = doc.createElementNS("http://www.w3.org/2000/xmlns/","meta");
+ meta.setAttribute("http-equiv", "Content-Type");
+ meta.setAttribute("content", "text/html; charset=UTF-8");
+ head.appendChild(meta);
+
+ var title = doc.createElementNS("http://www.w3.org/2000/xmlns/","title")
+ title.appendChild(doc.createTextNode("hc_staff"));
+ var title = head.appendChild(title);
+
+ // make the tests work....
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+
+ var body = doc.createElementNS("http://www.w3.org/2000/xmlns/","body");
+ var staff = html.appendChild(body);
+
+ var employees = [];
+ var addresses = [];
+ var names = [];
+ var positions = [];
+ var genders = [];
+ var ids = [];
+ var salaries = [];
+
+ // create 5 employees
+ for (var i=0; i<5; i++)
+ {
+ var employee = doc.createElementNS("http://www.w3.org/2000/xmlns/","p");
+ var address = doc.createElementNS("http://www.w3.org/2000/xmlns/","acronym");
+ var name = doc.createElementNS("http://www.w3.org/2000/xmlns/","strong");
+ var position = doc.createElementNS("http://www.w3.org/2000/xmlns/","code");
+ var gender = doc.createElementNS("http://www.w3.org/2000/xmlns/","var");
+ var id = doc.createElementNS("http://www.w3.org/2000/xmlns/","em");
+ var salary = doc.createElementNS("http://www.w3.org/2000/xmlns/","sup");
+
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(id);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(name);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(position);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(salary);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(gender);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(address);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ staff.appendChild(employee);
+
+ names.push(name);
+ employees.push(employee);
+ addresses.push(address);
+ genders.push(gender);
+ positions.push(position);
+ ids.push(id);
+ salaries.push(salary);
+ }
+
+ ids[0].appendChild(doc.createTextNode("EMP0001"));
+ salaries[0].appendChild(doc.createTextNode("56,000"));
+ addresses[0].setAttribute("title", "Yes");
+ addresses[0].appendChild(doc.createTextNode('1230 North Ave. Dallas, Texas 98551'));
+ names[0].appendChild(doc.createTextNode("Margaret Martin"));
+ genders[0].appendChild(doc.createTextNode("Female"));
+ positions[0].appendChild(doc.createTextNode("Accountant"));
+
+ ids[1].appendChild(doc.createTextNode("EMP0002"));
+ salaries[1].appendChild(doc.createTextNode("35,000"));
+ addresses[1].setAttribute("title", "Yes");
+ addresses[1].setAttribute("class", "Yes");
+ addresses[1].appendChild(doc.createTextNode("β Dallas, γ\n 98554"));
+ names[1].appendChild(doc.createTextNode("Martha Raynolds"));
+ names[1].appendChild(doc.createCDATASection("This is a CDATASection with EntityReference number 2 &amp;ent2;"));
+ names[1].appendChild(doc.createCDATASection("This is an adjacent CDATASection with a reference to a tab &amp;tab;"));
+ genders[1].appendChild(doc.createTextNode("Female"));
+ positions[1].appendChild(doc.createTextNode("Secretary"));
+
+ ids[2].appendChild(doc.createTextNode("EMP0003"));
+ salaries[2].appendChild(doc.createTextNode("100,000"));
+ addresses[2].setAttribute("title", "Yes");
+ addresses[2].setAttribute("class", "No");
+ addresses[2].appendChild(doc.createTextNode("PO Box 27 Irving, texas 98553"));
+ names[2].appendChild(doc.createTextNode("Roger\n Jones")) ;
+ genders[2].appendChild(doc.createEntityReference("&delta;"));//Text("&delta;"));
+ positions[2].appendChild(doc.createTextNode("Department Manager"));
+
+ ids[3].appendChild(doc.createTextNode("EMP0004"));
+ salaries[3].appendChild(doc.createTextNode("95,000"));
+ addresses[3].setAttribute("title", "Yes");
+ addresses[3].setAttribute("class", "");
+ addresses[3].appendChild(doc.createTextNode("27 South Road. Dallas, Texas 98556"));
+ names[3].appendChild(doc.createTextNode("Jeny Oconnor"));
+ genders[3].appendChild(doc.createTextNode("Female"));
+ positions[3].appendChild(doc.createTextNode("Personal Director"));
+
+ ids[4].appendChild(doc.createTextNode("EMP0005"));
+ salaries[4].appendChild(doc.createTextNode("90,000"));
+ addresses[4].setAttribute("title", "Yes");
+ addresses[4].appendChild(doc.createTextNode("1821 Nordic. Road, Irving Texas 98558"));
+ names[4].appendChild(doc.createTextNode("Robert Myers"));
+ genders[4].appendChild(doc.createTextNode("male"));
+ positions[4].appendChild(doc.createTextNode("Computer Specialist"));
+
+ doc.appendChild(doc.createProcessingInstruction("TEST-STYLE", "PIDATA"));
+
+ doc.normalize();
+ return doc;
+};
View
159 test/level2/core/files/staff2.xml.js
@@ -0,0 +1,159 @@
+var sys = require("sys"),
+ dom = require(__dirname + "/../lib/jsdom/level1/core").dom.level1.core;
+
+exports.hc_staff = function() {
+
+ var doc = new dom.Document("html");
+ var implementation = new dom.DOMImplementation(doc, {
+ "XML" : ["1.0", "2.0"],
+ "core": ["1.0", "2.0", "3.0"]
+ });
+
+ var notations = new dom.NotationNodeMap(
+ doc,
+ doc.createNotationNode("notation1","notation1File", null),
+ doc.createNotationNode("notation2",null, "notation2File")
+ );
+
+ // TODO: consider importing the master list of entities
+ // http://www.w3schools.com/tags/ref_symbols.asp
+ var entities = new dom.EntityNodeMap(
+ doc,
+ doc.createEntityNode("alpha", "α"),
+ doc.createEntityNode("beta", "&#946;"),
+ doc.createEntityNode("gamma", "&#947;"),
+ doc.createEntityNode("delta", "&#948;"),
+ doc.createEntityNode("epsilon", "&#949;")
+ );
+
+ // <!ATTLIST acronym dir CDATA "ltr">
+
+ var defaultAttributes = new dom.NamedNodeMap(doc);
+ var acronym = doc.createElementNS("http://www.w3.org/2000/xmlns/","acronym");
+ acronym.setAttribute("dir", "ltr");
+ defaultAttributes.setNamedItem(acronym);
+
+
+
+ var doctype = new dom.DocumentType(doc, "xml", entities, notations, defaultAttributes);
+ doc.doctype = doctype;
+ doc.implementation = implementation;
+
+ doc.appendChild(doc.createComment(" This is comment number 1."));
+
+ var html = doc.createElementNS("http://www.w3.org/2000/xmlns/","html");
+ var html = doc.appendChild(html);
+
+ var head = doc.createElementNS("http://www.w3.org/2000/xmlns/","head");
+ var head = html.appendChild(head);
+
+ var meta = doc.createElementNS("http://www.w3.org/2000/xmlns/","meta");
+ meta.setAttribute("http-equiv", "Content-Type");
+ meta.setAttribute("content", "text/html; charset=UTF-8");
+ head.appendChild(meta);
+
+ var title = doc.createElementNS("http://www.w3.org/2000/xmlns/","title")
+ title.appendChild(doc.createTextNode("hc_staff"));
+ var title = head.appendChild(title);
+
+ // make the tests work....
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+ head.appendChild(doc.createElementNS("http://www.w3.org/2000/xmlns/","script"));
+
+ var body = doc.createElementNS("http://www.w3.org/2000/xmlns/","body");
+ var staff = html.appendChild(body);
+
+ var employees = [];
+ var addresses = [];
+ var names = [];
+ var positions = [];
+ var genders = [];
+ var ids = [];
+ var salaries = [];
+
+ // create 5 employees
+ for (var i=0; i<5; i++)
+ {
+ var employee = doc.createElementNS("http://www.w3.org/2000/xmlns/","p");
+ var address = doc.createElementNS("http://www.w3.org/2000/xmlns/","acronym");
+ var name = doc.createElementNS("http://www.w3.org/2000/xmlns/","strong");
+ var position = doc.createElementNS("http://www.w3.org/2000/xmlns/","code");
+ var gender = doc.createElementNS("http://www.w3.org/2000/xmlns/","var");
+ var id = doc.createElementNS("http://www.w3.org/2000/xmlns/","em");
+ var salary = doc.createElementNS("http://www.w3.org/2000/xmlns/","sup");
+
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(id);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(name);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(position);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(salary);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(gender);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ employee.appendChild(address);
+ employee.appendChild(doc.createTextNode("\r\n"));
+ staff.appendChild(employee);
+
+ names.push(name);
+ employees.push(employee);
+ addresses.push(address);
+ genders.push(gender);
+ positions.push(position);
+ ids.push(id);
+ salaries.push(salary);
+ }
+
+ ids[0].appendChild(doc.createTextNode("EMP0001"));
+ salaries[0].appendChild(doc.createTextNode("56,000"));
+ addresses[0].setAttribute("title", "Yes");
+ addresses[0].appendChild(doc.createTextNode('1230 North Ave. Dallas, Texas 98551'));
+ names[0].appendChild(doc.createTextNode("Margaret Martin"));
+ genders[0].appendChild(doc.createTextNode("Female"));
+ positions[0].appendChild(doc.createTextNode("Accountant"));
+
+ ids[1].appendChild(doc.createTextNode("EMP0002"));
+ salaries[1].appendChild(doc.createTextNode("35,000"));
+ addresses[1].setAttribute("title", "Yes");
+ addresses[1].setAttribute("class", "Yes");
+ addresses[1].appendChild(doc.createTextNode("β Dallas, γ\n 98554"));
+ names[1].appendChild(doc.createTextNode("Martha Raynolds"));
+ names[1].appendChild(doc.createCDATASection("This is a CDATASection with EntityReference number 2 &amp;ent2;"));
+ names[1].appendChild(doc.createCDATASection("This is an adjacent CDATASection with a reference to a tab &amp;tab;"));
+ genders[1].appendChild(doc.createTextNode("Female"));
+ positions[1].appendChild(doc.createTextNode("Secretary"));
+
+ ids[2].appendChild(doc.createTextNode("EMP0003"));
+ salaries[2].appendChild(doc.createTextNode("100,000"));
+ addresses[2].setAttribute("title", "Yes");
+ addresses[2].setAttribute("class", "No");
+ addresses[2].appendChild(doc.createTextNode("PO Box 27 Irving, texas 98553"));
+ names[2].appendChild(doc.createTextNode("Roger\n Jones")) ;
+ genders[2].appendChild(doc.createEntityReference("&delta;"));//Text("&delta;"));
+ positions[2].appendChild(doc.createTextNode("Department Manager"));
+
+ ids[3].appendChild(doc.createTextNode("EMP0004"));
+ salaries[3].appendChild(doc.createTextNode("95,000"));
+ addresses[3].setAttribute("title", "Yes");
+ addresses[3].setAttribute("class", "");
+ addresses[3].appendChild(doc.createTextNode("27 South Road. Dallas, Texas 98556"));
+ names[3].appendChild(doc.createTextNode("Jeny Oconnor"));
+ genders[3].appendChild(doc.createTextNode("Female"));
+ positions[3].appendChild(doc.createTextNode("Personal Director"));
+
+ ids[4].appendChild(doc.createTextNode("EMP0005"));
+ salaries[4].appendChild(doc.createTextNode("90,000"));
+ addresses[4].setAttribute("title", "Yes");
+ addresses[4].appendChild(doc.createTextNode("1821 Nordic. Road, Irving Texas 98558"));
+ names[4].appendChild(doc.createTextNode("Robert Myers"));
+ genders[4].appendChild(doc.createTextNode("male"));
+ positions[4].appendChild(doc.createTextNode("Computer Specialist"));
+
+ doc.appendChild(doc.createProcessingInstruction("TEST-STYLE", "PIDATA"));
+
+ doc.normalize();
+ return doc;
+};
View
59 test/level2/core/files/staffNS.xml.1
@@ -1,59 +0,0 @@
-<?xml version="1.0"?><?TEST-STYLE PIDATA?>
-<!DOCTYPE staff PUBLIC "STAFF" "staffNS.dtd"
-[
- <!ENTITY ent1 "es">
- <!ENTITY ent2 "1900 Dallas Road">
- <!ENTITY ent3 "Texas">
- <!ENTITY ent4 "<entElement1 xmlns:local1='www.xyz.com'>Element data</entElement1><?PItarget PIdata?>">
- <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
- <!ENTITY ent6 PUBLIC "uri" "file" NDATA notation2>
- <!ENTITY ent1 "This entity should be discarded">
- <!NOTATION notation1 PUBLIC "notation1File">
- <!NOTATION notation2 SYSTEM "notation2File">
-]>
-<!-- This is comment number 1.-->
-<staff>
- <employee xmlns="http://www.nist.gov" xmlns:dmstc="http://www.usa.com">
- <employeeId>EMP0001</employeeId>
- <name>Margaret Martin</name>
- <position>Accountant</position>
- <salary>56,000</salary>
- <gender>Female</gender>
- <address dmstc:domestic="Yes">1230 North Ave. Dallas, Texas 98551</address>
- </employee>
- <employee xmlns:dmstc="http://www.usa.com">
- <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 dmstc:domestic="Yes" street="Yes">&ent2; Dallas, &ent3;
- 98554</address>
- </employee>
- <employee xmlns:dmstc="http://www.netzero.com">
- <employeeId>EMP0003</employeeId>
- <name>Roger
- Jones</name>
- <position>Department Manager</position>
- <salary>100,000</salary>
- <gender>&ent4;</gender>
- <address dmstc:domestic="Yes" street="No">PO Box 27 Irving, texas 98553</address>
- </employee>
- <emp:employee xmlns:emp="http://www.nist.gov" xmlns:nm="http://www.altavista.com" > <emp:employeeId>EMP0004</emp:employeeId>
- <nm:name>Jeny Oconnor</nm:name>
- <emp:position>Personnel Director</emp:position>
- <emp:salary>95,000</emp:salary>
- <emp:gender>Female</emp:gender>
- <emp:address emp:domestic="Yes" street="Y&ent1;" emp:zone="CANADA" emp:local1="TRUE">27 South Road. Dallas, texas 98556</emp:address>
- </emp:employee>
- <employee xmlns:emp2="http://www.nist.gov">
- <employeeId>EMP0005</employeeId>
- <name>Robert Myers</name>
- <position>Computer Specialist</position>
- <salary>90,000</salary>
- <gender>male</gender>
- <address street="Yes" xmlns="http://www.nist.gov">1821 Nordic. Road, Irving Texas 98558</address>
- </employee>
- </staff>
View
379 test/level2/core/files/staffNS.xml.js
@@ -1,13 +1,16 @@
-var sys = require("sys");
+var sys = require("sys"),
+ dom = require(__dirname + "/../../../../lib/jsdom/level2/core").dom.level2.core;
+
exports.staffNS = function() {
- var doc = new Document("staff");
+ var doc = new dom.Document("staff");
- var implementation = new DOMImplementation(doc, {
- "XML" : "1.0"
+ var implementation = new dom.DOMImplementation(doc, {
+ "XML" : ["1.0", "2.0"],
+ "core": ["1.0", "2.0", "3.0"]
});
- var notations = new NotationNodeMap(
+ var notations = new dom.NotationNodeMap(
doc,
doc.createNotationNode("notation1","notation1File", null),
doc.createNotationNode("notation2",null, "notation2File")
@@ -16,7 +19,7 @@ exports.staffNS = function() {
//<entElement domestic='Yes'>Element data</entElement><?PItarget PIdata?>
- var entElement = doc.createElement("entElement");
+ var entElement = doc.createElementNS("http://www.w3.org/2000/xmlns/","entElement");
entElement.setAttribute("domestic", "Yes");
entElement.appendChild(doc.createTextNode("Element data"));
var procElement = doc.createProcessingInstruction("PItarget", "PfIdata");
@@ -27,7 +30,7 @@ exports.staffNS = 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")),
@@ -35,220 +38,184 @@ exports.staffNS = function() {
ent4,
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 entElement = doc.createElement("entElement");
+ var defaultAttributes = new dom.NamedNodeMap(doc);
+ var entElement = doc.createElementNS("http://www.w3.org/2000/xmlns/","entElement");
entElement.setAttribute("attr1", "Attr");
entElement.setAttribute("domestic", "MALE");
defaultAttributes.setNamedItem(entElement);
- var defaultAddress = doc.createElement("address");
+ var defaultAddress = doc.createElementNS("http://www.w3.org/2000/xmlns/","address");
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.doctype._systemId = "staffNS.dtd";
doc.implementation = implementation;
- var staff = doc.createElement("staff");
- var employees = [];
- var addresses = [];
- var names = [];
- var positions = [];
- var genders = [];
- var ids = [];
- var salaries = [];
-
- // create 5 employees
- for (var i=0; i<5; i++)
- {
- var employee = doc.createElement("employee");
- var address = doc.createElement("address");
- var name = doc.createElement("name");
- var position = doc.createElement("position");
- var gender = doc.createElement("gender");
- var id = doc.createElement("employeeId");
- var salary = doc.createElement("salary");
-
- employee.appendChild(id);
- employee.appendChild(name);
- employee.appendChild(position);
- employee.appendChild(salary);
- employee.appendChild(gender);
- employee.appendChild(address);
- staff.appendChild(employee);
-
- names.push(name);
- employees.push(employee);
- addresses.push(address);
- genders.push(gender);
- positions.push(position);
- ids.push(id);
- salaries.push(salary);
- }
-
- ids[0].appendChild(doc.createTextNode("EMP0001"));
- salaries[0].appendChild(doc.createTextNode("56,000"));
- addresses[0].setAttribute("domestic", "Yes");
- addresses[0].appendChild(doc.createTextNode('1230 North Ave. Dallas, Texas 98551'));
- names[0].appendChild(doc.createTextNode("Margaret Martin"));
- genders[0].appendChild(doc.createTextNode("Female"));
- positions[0].appendChild(doc.createTextNode("Accountant"));
-
-
- ids[1].appendChild(doc.createTextNode("EMP0002"));
- salaries[1].appendChild(doc.createTextNode("35,000"));
-
- addresses[1].setAttribute("domestic", "Yes");
- addresses[1].setAttribute("street", "Yes");
- addresses[1].appendChild(doc.createEntityReference("ent2"));
- addresses[1].appendChild(doc.createTextNode(" Dallas, "));
- addresses[1].appendChild(doc.createEntityReference("ent3"));
- addresses[1].appendChild(doc.createTextNode("\n 98554"));
+ var staff = doc.createElementNS("http://www.w3.org/2000/xmlns/","staff");
+
+ var employee, address, name, position,gender,id, salary;
+
+ /************************************
+ * EMPLOYEEE 1 *
+ ************************************/
+ employee = doc.createElementNS("http://www.w3.org/2000/xmlns/","employee");
+ address = doc.createElementNS("http://www.w3.org/2000/xmlns/","address");
+ name = doc.createElementNS("http://www.w3.org/2000/xmlns/","name");
+ position = doc.createElementNS("http://www.w3.org/2000/xmlns/","position");
+ gender = doc.createElementNS("http://www.w3.org/2000/xmlns/","gender");
+ id = doc.createElementNS("http://www.w3.org/2000/xmlns/","employeeId");
+ salary = doc.createElementNS("http://www.w3.org/2000/xmlns/","salary");
+
+ employee.appendChild(id);
+ employee.appendChild(name);
+ employee.appendChild(position);
+ employee.appendChild(salary);
+ employee.appendChild(gender);
+ employee.appendChild(address);
+ staff.appendChild(employee);
+
+ employee.namespaceURI = "http://www.nist.gov";
+ employee.setAttribute("xmlns", "http://www.nist.gov")
+ employee.setAttributeNS("http://www.nist.gov", "xmlns:dmstc", "http://www.usa.com");
+
+ id.appendChild(doc.createTextNode("EMP0001"));
+ salary.appendChild(doc.createTextNode("56,000"));
+ address.appendChild(doc.createTextNode('1230 North Ave. Dallas, Texas 98551'));
+ address.setAttributeNS("http://www.usa.com", "dmstc:domestic", "Yes");
+ name.appendChild(doc.createTextNode("Margaret Martin"));
+ gender.appendChild(doc.createTextNode("Female"));
+ position.appendChild(doc.createTextNode("Accountant"));
+
+ /************************************
+ * EMPLOYEEE 2 *
+ ************************************/
+ employee = doc.createElementNS("http://www.w3.org/2000/xmlns/","employee");
+ address = doc.createElementNS("http://www.w3.org/2000/xmlns/","address");
+ name = doc.createElementNS("http://www.w3.org/2000/xmlns/","name");
+ position = doc.createElementNS("http://www.w3.org/2000/xmlns/","position");
+ gender = doc.createElementNS("http://www.w3.org/2000/xmlns/","gender");
+ id = doc.createElementNS("http://www.w3.org/2000/xmlns/","employeeId");
+ salary = doc.createElementNS("http://www.w3.org/2000/xmlns/","salary");
+
+ employee.appendChild(id);
+ employee.appendChild(name);
+ employee.appendChild(position);
+ employee.appendChild(salary);
+ employee.appendChild(gender);
+ employee.appendChild(address);
+ staff.appendChild(employee);
+
+ employee.setAttributeNS("http://www.nist.gov", "xmlns:dmstc", "http://www.usa.com");
+ id.appendChild(doc.createTextNode("EMP0002"));
+ salary.appendChild(doc.createTextNode("35,000"));
+ address.setAttributeNS("http://www.usa.com", "dmstc:domestic", "Yes");
+ address.setAttribute("street", "Yes");
+ address.appendChild(doc.createEntityReference("ent2"));
+ address.appendChild(doc.createTextNode(" Dallas, "));
+ address.appendChild(doc.createEntityReference("ent3"));
+ address.appendChild(doc.createTextNode("\n 98554"));
- names[1].appendChild(doc.createTextNode("Martha Raynolds"));
- names[1].appendChild(doc.createCDATASection("This is a CDATASection with EntityReference number 2 &ent2;"));
- names[1].appendChild(doc.createTextNode("\r\n"));
- names[1].appendChild(doc.createCDATASection("This is an adjacent CDATASection with a reference to a tab &tab;"));
- genders[1].appendChild(doc.createTextNode("Female"));
- positions[1].appendChild(doc.createTextNode("Secretary"));
-
-
- ids[2].appendChild(doc.createTextNode("EMP0003"));
- salaries[2].appendChild(doc.createTextNode("100,000"));
- addresses[2].setAttribute("domestic", "Yes");
- addresses[2].setAttribute("street", "No");
- addresses[2].appendChild(doc.createTextNode("PO Box 27 Irving, texas 98553"));
- names[2].appendChild(doc.createTextNode("Roger\n Jones")) ;
- genders[2].appendChild(doc.createEntityReference("ent4"));//Text("&ent4"));
- positions[2].appendChild(doc.createTextNode("Department Manager"));
-
-
- ids[3].appendChild(doc.createTextNode("EMP0004"));
- salaries[3].appendChild(doc.createTextNode("95,000"));
- addresses[3].setAttribute("domestic", "Yes");
- addresses[3].setAttribute("street", "Y");
+ name.appendChild(doc.createTextNode("Martha Raynolds"));
+ name.appendChild(doc.createCDATASection("This is a CDATASection with EntityReference number 2 &ent2;"));
+ name.appendChild(doc.createTextNode("\r\n"));
+ name.appendChild(doc.createCDATASection("This is an adjacent CDATASection with a reference to a tab &tab;"));
+ gender.appendChild(doc.createTextNode("Female"));
+ position.appendChild(doc.createTextNode("Secretary"));
+
+
+ /************************************
+ * EMPLOYEEE 3 *
+ ************************************/
+ employee = doc.createElementNS("http://www.nist.gov","employee");
+ address = doc.createElementNS("http://www.w3.org/2000/xmlns/","address");
+ name = doc.createElementNS("http://www.w3.org/2000/xmlns/","name");
+ position = doc.createElementNS("http://www.w3.org/2000/xmlns/","position");
+ gender = doc.createElementNS("http://www.w3.org/2000/xmlns/","gender");
+ id = doc.createElementNS("http://www.w3.org/2000/xmlns/","employeeId");
+ salary = doc.createElementNS("http://www.w3.org/2000/xmlns/","salary");
+
+ employee.appendChild(id);
+ employee.appendChild(name);
+ employee.appendChild(position);
+ employee.appendChild(salary);
+ employee.appendChild(gender);
+ employee.appendChild(address);
+ staff.appendChild(employee);
+ employee.setAttributeNS("http://www.nist.gov", "xmlns:dmstc", "http://www.netzero.com");
+ id.appendChild(doc.createTextNode("EMP0003"));
+ salary.appendChild(doc.createTextNode("100,000"));
+ address.setAttributeNS("http://www.usa.com", "dmstc:domestic", "Yes");
+ address.setAttribute("street", "No");
+ address.appendChild(doc.createTextNode("PO Box 27 Irving, texas 98553"));
+ name.appendChild(doc.createTextNode("Roger\n Jones")) ;
+ gender.appendChild(doc.createEntityReference("ent4"));
+ position.appendChild(doc.createTextNode("Department Manager"));
+
+ /************************************
+ * EMPLOYEEE 4 *
+ ************************************/
+ employee = doc.createElementNS("http://www.nist.gov", "emp:employee");
+ address = doc.createElementNS("http://www.nist.gov", "emp:address");
+ name = doc.createElementNS("http://www.altavista.com", "nm:name");
+ position = doc.createElementNS("http://www.nist.gov", "emp:position");
+ gender = doc.createElementNS("http://www.nist.gov", "emp:gender");
+ id = doc.createElementNS("http://www.nist.gov", "emp:employeeId");
+ salary = doc.createElementNS("http://www.nist.gov", "emp:salary");
+
+ employee.appendChild(id);
+ employee.appendChild(name);
+ employee.appendChild(position);
+ employee.appendChild(salary);
+ employee.appendChild(gender);
+ employee.appendChild(address);
+ staff.appendChild(employee);
+
+ employee.setAttributeNS("http://www.nist.gov", "xmlns:emp", "http://www.nist.gov");
+ employee.setAttributeNS("http://www.altavista.com", "xmlns:nm", "http://www.altavista.com");
+ id.appendChild(doc.createTextNode("EMP0004"));
+ salary.appendChild(doc.createTextNode("95,000"));
+ address.setAttribute("emp:domestic", "Yes");
+ address.setAttribute("emp:street", "Y");
var ent1Ref = doc.createEntityReference("ent1");
- addresses[3].attributes.getNamedItem("street").childNodes.push(ent1Ref);
- addresses[3].appendChild(doc.createTextNode("27 South Road. Dallas, Texas 98556"));
- names[3].appendChild(doc.createTextNode("Jeny Oconnor"));
- genders[3].appendChild(doc.createTextNode("Female"));
- positions[3].appendChild(doc.createTextNode("Personal Director"));
-
+ //address.attributes.getNamedItem("street").childNodes.push(ent1Ref);
+ address.appendChild(doc.createTextNode("27 South Road. Dallas, Texas 98556"));
+ name.appendChild(doc.createTextNode("Jeny Oconnor"));
+ gender.appendChild(doc.createTextNode("Female"));
+ position.appendChild(doc.createTextNode("Personal Director"));
+
+ /************************************
+ * EMPLOYEEE 5 *
+ ************************************/
+ employee = doc.createElementNS("http://www.w3.org/2000/xmlns/","employee");
+ address = doc.createElementNS("http://www.w3.org/2000/xmlns/","address");
+ name = doc.createElementNS("http://www.w3.org/2000/xmlns/","name");
+ position = doc.createElementNS("http://www.w3.org/2000/xmlns/","position");
+ gender = doc.createElementNS("http://www.w3.org/2000/xmlns/","gender");
+ id = doc.createElementNS("http://www.w3.org/2000/xmlns/","employeeId");
+ salary = doc.createElementNS("http://www.w3.org/2000/xmlns/","salary");
+
+ employee.appendChild(id);
+ employee.appendChild(name);
+ employee.appendChild(position);
+ employee.appendChild(salary);
+ employee.appendChild(gender);
+ employee.appendChild(address);
+ staff.appendChild(employee);
+
+ id.appendChild(doc.createTextNode("EMP0005"));
+ salary.appendChild(doc.createTextNode("90,000"));
+ address.setAttribute("street", "Yes");
+ address.appendChild(doc.createTextNode("1821 Nordic. Road, Irving Texas 98558"));
+ name.appendChild(doc.createTextNode("Robert Myers"));
+ gender.appendChild(doc.createTextNode("male"));
+ position.appendChild(doc.createTextNode("Computer Specialist"));
- ids[4].appendChild(doc.createTextNode("EMP0005"));
- salaries[4].appendChild(doc.createTextNode("90,000"));
- addresses[4].setAttribute("street", "Yes");
- addresses[4].appendChild(doc.createTextNode("1821 Nordic. Road, Irving Texas 98558"));
- names[4].appendChild(doc.createTextNode("Robert Myers"));
- genders[4].appendChild(doc.createTextNode("male"));
- 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);
-
- doc.normalize();
+
+ doc.normalize();
return doc;
};
View
7 test/runner.js
@@ -20,7 +20,6 @@ var mixin = function(target) {
return target;
};
-mixin(global, require(__dirname + "/../lib/jsdom/level1/core").dom.level1.core);
mixin(global, require(__dirname + "/mjsunit"));
mixin(global, require("./DOMTestCase"));
@@ -60,7 +59,7 @@ global.debug = function(val) {
} catch (e) {
str = sys.inspect(val, null, true);
}
- sys.puts(str);
+ sys.debug(str);
process.exit();
}
@@ -68,18 +67,21 @@ global.debug = function(val) {
var suites = {
"level1/core" : { cases: require("./level1/core").tests, setUp : function() {
+ mixin(global, require("../lib/jsdom/level1/core").dom.level1.core);
global.builder.contentType = "text/xml";
global.builder.type = "xml";
global.builder.testDirectory = "level1/core";
}
},
"level1/html" : { cases: require("./level1/html").tests, setUp : function() {
+ mixin(global, require("../lib/jsdom/level1/core").dom.level1.core);
global.builder.contentType = "text/html";
global.builder.type = "html";
global.builder.testDirectory = "level1/html";
}
},
"level1/svg" : { cases: require("./level1/svg").tests, setUp : function() {
+ mixin(global, require("../lib/jsdom/level1/core").dom.level1.core);
global.builder.contentType = "image/svg+xml";
global.builder.type = "svg";
global.builder.testDirectory = "level1/svg";
@@ -89,7 +91,6 @@ var suites = {
global.builder.contentType = "text/xml";
global.builder.type = "xml";
global.builder.testDirectory = "level2/core";
-
}
},
"browser" : { cases: require("./browser").tests, setUp : function() {
Please sign in to comment.
Something went wrong with that request. Please try again.