8000 jsdom/test/level1/html.js at 4.x · dominicrico/jsdom · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
7480 lines (6198 loc) · 232 KB

html.js

File metadata and controls

7480 lines (6198 loc) · 232 KB
var hc_staff = require('./html/files/hc_staff.html');
exports.tests = {
/**
*
The "getDoctype()" method returns null for XML documents
without a document type declaration.
Retrieve the XML document without a DTD and invoke the
"getDoctype()" method. It should return null.
* @author NIST
* @author Mary Brady
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
*/
documentgetdoctypenodtd: function(test) {
var doc = require('./html/files/hc_nodtdstaff.html').hc_nodtdstaff();
test.equal(doc.doctype, null, 'documentGetDocTypeNoDTDAssert');
test.done();
},
/**
*
Appends a text node to an attribute and checks if the value of
the attribute is changed.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
*/
hc_attrappendchild1: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var retval;
var lastChild;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
textNode = doc.createTextNode("terday");
retval = titleAttr.appendChild(textNode);
value = titleAttr.value;
test.equal(value, "Yesterday", 'attrValue');
value = titleAttr.nodeValue;
test.equal(value, "Yesterday", 'attrNodeValue');
value = retval.nodeValue;
test.equal(value, "terday", 'retvalValue');
lastChild = titleAttr.lastChild;
value = lastChild.nodeValue;
test.equal(value, "terday", 'lastChildValue');
test.done();
},
/**
*
Attempts to append an element to the child nodes of an attribute.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
*/
hc_attrappendchild2: function(test) {
var doc = hc_staff.hc_staff();
var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
var newChild = doc.createElement("terday");
var success = false;
try {
titleAttr.appendChild(newChild);
} catch(ex) {
success = (typeof(ex.code) != 'undefined' && ex.code == 3);
}
test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
test.done();
},
/**
*
Appends a document fragment to an attribute and checks if the value of
the attribute is changed.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
*/
hc_attrappendchild3: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var terNode;
var dayNode;
var retval;
var lastChild;
var docFrag;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
terNode = doc.createTextNode("ter");
dayNode = doc.createTextNode("day");
docFrag = doc.createDocumentFragment();
retval = docFrag.appendChild(terNode);
retval = docFrag.appendChild(dayNode);
retval = titleAttr.appendChild(docFrag);
value = titleAttr.value;
test.equal(value, "Yesterday", 'attrValue');
value = titleAttr.nodeValue;
test.equal(value, "Yesterday", 'attrNodeValue');
value = retval.nodeValue;
test.equal(value, null, 'retvalValue');
lastChild = titleAttr.lastChild;
value = lastChild.nodeValue;
test.equal(value, "day", 'lastChildValue');
test.done();
},
/**
*
Attempt to append a node from another document to an attribute which should result
in a WRONG_DOCUMENT_ERR.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
*/
hc_attrappendchild5: function(test) {
var doc = hc_staff.hc_staff();
var otherDoc = hc_staff.hc_staff();
var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
var textNode = otherDoc.createTextNode("terday");
var success = false;
try {
titleAttr.appendChild(textNode);
} catch(ex) {
success = (typeof(ex.code) != 'undefined' && ex.code == 4);
}
test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
test.done();
},
/**
*
Creates an new attribute node and appends a text node.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
*/
hc_attrappendchild6: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var retval;
var lastChild;
doc = hc_staff.hc_staff();
titleAttr = doc.createAttribute("title");
textNode = doc.createTextNode("Yesterday");
retval = titleAttr.appendChild(textNode);
value = titleAttr.value;
test.equal(value, "Yesterday", 'attrValue');
value = titleAttr.nodeValue;
test.equal(value, "Yesterday", 'attrNodeValue');
value = retval.nodeValue;
test.equal(value, "Yesterday", 'retvalValue');
lastChild = titleAttr.lastChild;
value = lastChild.nodeValue;
test.equal(value, "Yesterday", 'lastChildValue');
test.done();
},
/**
*
Checks that Node.childNodes for an attribute node contains
the expected text node.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
*/
hc_attrchildnodes1: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var childNodes;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
childNodes = titleAttr.childNodes;
test.equal(childNodes.length, 1, 'childNodesSize');
textNode = childNodes.item(0);
value = textNode.nodeValue;
test.equal(value, "Yes", 'child1IsYes');
textNode = childNodes.item(1);
test.equal(textNode, null, 'secondItemIsNull');
test.done();
},
/**
*
Checks Node.childNodes for an attribute with multiple child nodes.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
*/
hc_attrchildnodes2: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var childNodes;
var retval;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
childNodes = titleAttr.childNodes;
textNode = doc.createTextNode("terday");
retval = titleAttr.appendChild(textNode);
test.equal(childNodes.length, 2, 'childNodesSize');
textNode = childNodes.item(0);
value = textNode.nodeValue;
test.equal(value, "Yes", 'child1IsYes');
textNode = childNodes.item(1);
value = textNode.nodeValue;
test.equal(value, "terday", 'child2IsTerday');
textNode = childNodes.item(2);
test.equal(textNode, null, 'thirdItemIsNull');
test.done();
},
/**
*
Appends a text node to an attribute and clones the node.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
*/
hc_attrclonenode1: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var retval;
var lastChild;
var clonedTitle;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
textNode = doc.createTextNode("terday");
retval = titleAttr.appendChild(textNode);
clonedTitle = titleAttr.cloneNode(false);
textNode.nodeValue = "text_node_not_cloned";
value = clonedTitle.value;
test.equal(value, "Yesterday", 'attrValue');
value = clonedTitle.nodeValue;
test.equal(value, "Yesterday", 'attrNodeValue');
lastChild = clonedTitle.lastChild;
value = lastChild.nodeValue;
test.equal(value, "terday", 'lastChildValue');
test.done();
},
/**
*
Create a new DocumentFragment and add a newly created Element node(with one attribute).
Once the element is added, its attribute should be available as an attribute associated
with an Element within a DocumentFragment.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
*/
hc_attrcreatedocumentfragment: function(test) {
var langAttrCount = 0;
var doc = hc_staff.hc_staff();
var docFragment = doc.createDocumentFragment();
var newOne = doc.createElement("html");
newOne.setAttribute("lang","EN");
docFragment.appendChild(newOne);
var attributes = docFragment.firstChild.attributes;
for(var i=0;i<attributes.length;i++) {
attribute = attributes.item(i);
attrName = attribute.name;
if(attrName == "lang") {
langAttrCount += 1;
}
}
test.equal(langAttrCount, 1, 'hasLangAttr');
test.done();
},
/**
*
The "setValue()" method for an attribute creates a
Text node with the unparsed content of the string.
Retrieve the attribute named "class" from the last
child of of the fourth employee and assign the "Y&ent1;"
string to its value attribute. This value is not yet
parsed and therefore should still be the same upon
retrieval. This test uses the "getNamedItem(name)" method
from the NamedNodeMap interface.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
*/
hc_attrcreatetextnode: function(test) {
var success;
var doc;
var addressList;
var testNode;
var attributes;
var streetAttr;
var value;
doc = hc_staff.hc_staff();
addressList = doc.getElementsByTagName("acronym");
testNode = addressList.item(3);
attributes = testNode.attributes;
streetAttr = attributes.getNamedItem("class");
streetAttr.value = "Y&ent1;";
value = streetAttr.value;
test.equal(value, "Y&ent1;", 'value');
value = streetAttr.nodeValue;
test.equal(value, "Y&ent1;", 'nodeValue');
test.done();
},
/**
*
The "setNodeValue()" method for an attribute creates a
Text node with the unparsed content of the string.
Retrieve the attribute named "class" from the last
child of of the fourth employee and assign the "Y&ent1;"
string to its value attribute. This value is not yet
parsed and therefore should still be the same upon
retrieval. This test uses the "getNamedItem(name)" method
from the NamedNodeMap interface.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
* @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
*/
hc_attrcreatetextnode2: function(test) {
var success;
var doc;
var addressList;
var testNode;
var attributes;
var streetAttr;
var value;
doc = hc_staff.hc_staff();
addressList = doc.getElementsByTagName("acronym");
testNode = addressList.item(3);
attributes = testNode.attributes;
streetAttr = attributes.getNamedItem("class");
streetAttr.nodeValue = "Y&ent1;";
value = streetAttr.value;
test.equal(value, "Y&ent1;", 'value');
value = streetAttr.nodeValue;
test.equal(value, "Y&ent1;", 'nodeValue');
test.done();
},
/**
*
If an Attr is explicitly assigned any value, then that value is the attributes effective value.
Retrieve the attribute named "domestic" from the last child of of the first employee
and examine its nodeValue attribute. This test uses the "getNamedItem(name)" method
from the NamedNodeMap interface.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
*/
hc_attreffectivevalue: function(test) {
var success;
var doc;
var addressList;
var testNode;
var attributes;
var domesticAttr;
var value;
doc = hc_staff.hc_staff();
addressList = doc.getElementsByTagName("acronym");
testNode = addressList.item(0);
10BC8 attributes = testNode.attributes;
domesticAttr = attributes.getNamedItem("title");
value = domesticAttr.nodeValue;
test.equal(value, "Yes", 'attrEffectiveValueAssert');
test.done();
},
/**
*
Checks that Node.firstChild for an attribute node contains
the expected text node.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
*/
hc_attrfirstchild: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var otherChild;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
textNode = titleAttr.firstChild;
test.notEqual(textNode, null, 'textNodeNotNull');
value = textNode.nodeValue;
test.equal(value, "Yes", 'child1IsYes');
otherChild = textNode.nextSibling;
test.equal(otherChild, null, 'nextSiblingIsNull');
otherChild = textNode.previousSibling;
test.equal(otherChild, null, 'previousSiblingIsNull');
test.done();
},
/**
*
Checks the value of an attribute that contains entity references.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
*/
hc_attrgetvalue1: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var retval;
var lastChild;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("class");
value = titleAttr.value;
test.equal(value, "Yα", 'attrValue1');
test.done();
},
/**
*
Checks that Node.hasChildNodes() is true for an attribute with content.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
*/
hc_attrhaschildnodes: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var hasChildNodes;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
hasChildNodes = titleAttr.hasChildNodes();
test.ok(hasChildNodes, 'hasChildrenIsTrue');
test.done();
},
/**
*
Appends a text node to an attribute and checks if the value of
the attribute is changed.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
*/
hc_attrinsertbefore1: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var retval;
var firstChild;
var lastChild;
var refChild = null;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
textNode = doc.createTextNode("terday");
retval = titleAttr.insertBefore(textNode,refChild);
value = titleAttr.value;
test.equal(value, "Yesterday", 'attrValue');
value = titleAttr.nodeValue;
test.equal(value, "Yesterday", 'attrNodeValue');
value = retval.nodeValue;
test.equal(value, "terday", 'retvalValue');
firstChild = titleAttr.firstChild;
value = firstChild.nodeValue;
test.equal(value, "Yes", 'firstChildValue');
lastChild = titleAttr.lastChild;
value = lastChild.nodeValue;
test.equal(value, "terday", 'lastChildValue');
test.done();
},
/**
*
Prepends a text node to an attribute and checks if the value of
the attribute is changed.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
*/
hc_attrinsertbefore2: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var retval;
var lastChild;
var firstChild;
var refChild;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
textNode = doc.createTextNode("terday");
refChild = titleAttr.firstChild;
retval = titleAttr.insertBefore(textNode,refChild);
value = titleAttr.value;
test.equal(value, "terdayYes", 'attrValue');
value = titleAttr.nodeValue;
test.equal(value, "terdayYes", 'attrNodeValue');
value = retval.nodeValue;
test.equal(value, "terday", 'retvalValue');
firstChild = titleAttr.firstChild;
value = firstChild.nodeValue;
test.equal(value, "terday", 'firstChildValue');
lastChild = titleAttr.lastChild;
value = lastChild.nodeValue;
test.equal(value, "Yes", 'lastChildValue');
test.done();
},
/**
*
Appends a document fragment to an attribute and checks if the value of
the attribute is changed.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
*/
hc_attrinsertbefore3: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var terNode;
var dayNode;
var docFrag;
var retval;
var firstChild;
var lastChild;
var refChild = null;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
terNode = doc.createTextNode("ter");
dayNode = doc.createTextNode("day");
docFrag = doc.createDocumentFragment();
retval = docFrag.appendChild(terNode);
retval = docFrag.appendChild(dayNode);
retval = titleAttr.insertBefore(docFrag,refChild);
value = titleAttr.value;
test.equal(value, "Yesterday", 'attrValue');
value = titleAttr.nodeValue;
test.equal(value, "Yesterday", 'attrNodeValue');
value = retval.nodeValue;
test.equal(value, null, 'retvalValue');
firstChild = titleAttr.firstChild;
value = firstChild.nodeValue;
test.equal(value, "Yes", 'firstChildValue');
lastChild = titleAttr.lastChild;
value = lastChild.nodeValue;
test.equal(value, "day", 'lastChildValue');
test.done();
},
/**
*
Prepends a document fragment to an attribute and checks if the value of
the attribute is changed.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
*/
hc_attrinsertbefore4: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var terNode;
var dayNode;
var docFrag;
var retval;
var firstChild;
var lastChild;
var refChild;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
terNode = doc.createTextNode("ter");
dayNode = doc.createTextNode("day");
docFrag = doc.createDocumentFragment();
retval = docFrag.appendChild(terNode);
retval = docFrag.appendChild(dayNode);
refChild = titleAttr.firstChild;
retval = titleAttr.insertBefore(docFrag,refChild);
value = titleAttr.value;
test.equal(value, "terdayYes", 'attrValue');
value = titleAttr.nodeValue;
test.equal(value, "terdayYes", 'attrNodeValue');
value = retval.nodeValue;
test.equal(value, null, 'retvalValue');
firstChild = titleAttr.firstChild;
value = firstChild.nodeValue;
test.equal(value, "ter", 'firstChildValue');
lastChild = titleAttr.lastChild;
value = lastChild.nodeValue;
test.equal(value, "Yes", 'lastChildValue');
test.done();
},
/**
*
Attempt to append a text node from another document to an attribute which should result
in a WRONG_DOCUMENT_ERR.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
*/
hc_attrinsertbefore6: function(test) {
var doc = hc_staff.hc_staff();
var otherDoc = hc_staff.hc_staff();
var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
var textNode = otherDoc.createTextNode("terday");
var success = false;
try {
titleAttr.insertBefore(textNode, null);
} catch(ex) {
success = (typeof(ex.code) != 'undefined' && ex.code == 4);
}
test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
test.done();
},
/**
*
Checks that Node.lastChild for an attribute node contains
the expected text node.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
*/
hc_attrlastchild: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var otherChild;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
textNode = titleAttr.firstChild;
test.notEqual(textNode, null, 'textNodeNotNull');
value = textNode.nodeValue;
test.equal(value, "Yes", 'child1IsYes');
otherChild = textNode.nextSibling;
test.equal(otherChild, null, 'nextSiblingIsNull');
otherChild = textNode.previousSibling;
test.equal(otherChild, null, 'previousSiblingIsNull');
test.done();
},
/**
*
Retrieve the attribute named class from the last
child of of the second "p" element and examine its
NodeName.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
* @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
* @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
*/
hc_attrname: function(test) {
var doc = hc_staff.hc_staff();
var streetAttr = doc.getElementsByTagName("acronym").item(1).attributes.getNamedItem("class");
test.equal(streetAttr.name, 'class', 'attribute name');
test.done();
},
/**
*
The "getNextSibling()" method for an Attr node should return null.
Retrieve the attribute named "domestic" from the last child of of the
first employee and examine its NextSibling node. This test uses the
"getNamedItem(name)" method from the NamedNodeMap interface.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
*/
hc_attrnextsiblingnull: function(test) {
var success;
var doc;
var addressList;
var testNode;
var attributes;
var domesticAttr;
var s;
doc = hc_staff.hc_staff();
addressList = doc.getElementsByTagName("acronym");
testNode = addressList.item(0);
attributes = testNode.attributes;
domesticAttr = attributes.getNamedItem("title");
s = domesticAttr.nextSibling;
test.equal(s, null, 'attrNextSiblingNullAssert');
test.done();
},
/**
*
Appends a text node to an attribute, normalizes the attribute
and checks for a single child node.
* @author Curt Arnold
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
*/
hc_attrnormalize: function(test) {
var success;
var doc;
var acronymList;
var testNode;
var attributes;
var titleAttr;
var value;
var textNode;
var retval;
var firstChild;
var secondChild;
doc = hc_staff.hc_staff();
acronymList = doc.getElementsByTagName("acronym");
testNode = acronymList.item(3);
attributes = testNode.attributes;
titleAttr = attributes.getNamedItem("title");
textNode = doc.createTextNode("terday");
retval = titleAttr.appendChild(textNode);
textNode = doc.createTextNode("");
retval = titleAttr.appendChild(textNode);
testNode.normalize();
value = titleAttr.nodeValue;
test.equal(value, "Yesterday", 'attrNodeValue');
firstChild = titleAttr.firstChild;
value = firstChild.nodeValue;
test.equal(value, "Yesterday", 'firstChildValue');
secondChild = firstChild.nextSibling;
test.equal(secondChild, null, 'secondChildIsNull');
test.done();
},
/**
*
0