var hc_staff = require('./svg/files/hc_staff.svg'); var staff = require('./svg/files/staff.svg'); var hc_nodtdstaff = require('./svg/files/hc_nodtdstaff.svg'); var domTestHelper = require('../DOMTestCase'); exports.tests = { /** * Attr nodes may be associated with Element nodes contained within a DocumentFragment. 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 NIST * @author Mary Brady * @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 */ attrcreatedocumentfragment: function(test) { var success; var doc; var docFragment; var newOne; var domesticNode; var domesticAttr; var attrs; var attrName; var appendedChild; doc = staff.staff(); docFragment = doc.createDocumentFragment(); newOne = doc.createElement("newElement"); newOne.setAttribute("newdomestic","Yes"); appendedChild = docFragment.appendChild(newOne); domesticNode = docFragment.firstChild; domesticAttr = domesticNode.attributes; attrs = domesticAttr.item(0); attrName = attrs.name; test.equal(attrName, 'newdomestic', 'attrCreateDocumentFragmentAssert'); test.done(); }, /** * The "setValue()" method for an attribute creates a Text node with the unparsed content of the string. Retrieve the attribute named "street" 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 NIST * @author Mary Brady * @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 */ attrcreatetextnode: function(test) { var success; var doc; var addressList; var testNode; var attributes; var streetAttr; var value; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(3); attributes = testNode.attributes; streetAttr = attributes.getNamedItem("street"); 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 "street" 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 */ attrcreatetextnode2: function(test) { var success; var doc; var addressList; var testNode; var attributes; var streetAttr; var value; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(3); attributes = testNode.attributes; streetAttr = attributes.getNamedItem("street"); 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 there is not an explicit value assigned to an attribute and there is a declaration for this attribute and that declaration includes a default value, then that default value is the attributes default value. Retrieve the attribute named "street" from the last child of of the first employee and examine its value. That value should be the value given the attribute in the DTD file. The test uses the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @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 * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html */ attrdefaultvalue: function(test) { var success; var doc; var addressList; var testNode; var attributes; var streetAttr; var value; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(0); attributes = testNode.attributes; streetAttr = attributes.getNamedItem("street"); value = streetAttr.nodeValue; test.equal(value, 'Yes', 'attrDefaultValueAssert'); 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 NIST * @author Mary Brady * @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 */ attreffectivevalue: function(test) { var success; var doc; var addressList; var testNode; var attributes; var domesticAttr; var value; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(0); attributes = testNode.attributes; domesticAttr = attributes.getNamedItem("domestic"); value = domesticAttr.nodeValue; test.equal(value, 'Yes', 'attrEffectiveValueAssert'); test.done(); }, /** * The "getValue()" method will return the value of the attribute as a string. The general entity references are replaced with their values. Retrieve the attribute named "street" from the last child of of the fourth employee and examine the string returned by the "getValue()" method. The value should be set to "Yes" after the EntityReference is replaced with its value. This test uses the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 */ attrentityreplacement: function(test) { var success; var doc; var addressList; var testNode; var attributes; var streetAttr; var value; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(3); attributes = testNode.attributes; streetAttr = attributes.getNamedItem("street"); value = streetAttr.value; test.equal(value, 'Yes', 'streetYes'); test.done(); }, /** * The getNodeName() method of an Attribute node. Retrieve the attribute named street from the last child of of the second employee and examine its NodeName. This test uses the getNamedItem(name) method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @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 */ attrname: function(test) { var success; var doc; var addressList; var testNode; var attributes; var streetAttr; var name; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(1); attributes = testNode.attributes; streetAttr = attributes.getNamedItem("street"); name = streetAttr.nodeName; test.equal(name, 'street', 'nodeName'); name = streetAttr.name; test.equal(name, 'street', '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 NIST * @author Mary Brady * @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 */ attrnextsiblingnull: function(test) { var success; var doc; var addressList; var testNode; var attributes; var domesticAttr; var s; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(0); attributes = testNode.attributes; domesticAttr = attributes.getNamedItem("domestic"); s = domesticAttr.nextSibling; test.equal(s, null, 'attrNextSiblingNullAssert'); test.done(); }, /** * The "getSpecified()" method for an Attr node should be set to false if the attribute was not explicitly given a value. Retrieve the attribute named "street" from the last child of of the first employee and examine the value returned by the "getSpecified()" method. This test uses the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273 * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html */ attrnotspecifiedvalue: function(test) { var success; var doc; var addressList; var testNode; var attributes; var streetAttr; var state; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(0); attributes = testNode.attributes; streetAttr = attributes.getNamedItem("street"); state = streetAttr.specified; test.equal(state, false, 'streetNotSpecified'); test.done(); }, /** * The "getParentNode()" method for an Attr node should return null. Retrieve the attribute named "domestic" from the last child of the first employee and examine its parentNode attribute. This test also uses the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 */ attrparentnodenull: function(test) { var success; var doc; var addressList; var testNode; var attributes; var domesticAttr; var s; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(0); attributes = testNode.attributes; domesticAttr = attributes.getNamedItem("domestic"); s = domesticAttr.parentNode; test.equal(s, null, 'attrParentNodeNullAssert'); test.done(); }, /** * The "getPreviousSibling()" 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 PreviousSibling node. This test uses the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024 */ attrprevioussiblingnull: function(test) { var success; var doc; var addressList; var testNode; var attributes; var domesticAttr; var s; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(0); attributes = testNode.attributes; domesticAttr = attributes.getNamedItem("domestic"); s = domesticAttr.previousSibling; test.equal(s, null, 'attrPreviousSiblingNullAssert'); test.done(); }, /** * Removing a child node from an attribute in an entity reference should result in an NO_MODIFICATION_ALLOWED_ERR DOMException. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1734834066')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) */ attrremovechild1: function(test) { var success; var doc; var entRef; var entElement; var attrNode; var textNode; var removedNode; doc = staff.staff(); entRef = doc.createEntityReference("ent4"); test.notEqual(entRef, null, 'createdEntRefNotNull'); entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); attrNode = entElement.getAttributeNode("domestic"); textNode = attrNode.firstChild; test.notEqual(textNode, null, 'attrChildNotNull'); { success = false; try { removedNode = attrNode.removeChild(textNode); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'setValue_throws_NO_MODIFICATION_ERR'); } test.done(); }, /** * Replacing a child node from an attribute in an entity reference should result in an NO_MODIFICATION_ALLOWED_ERR DOMException. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) */ attrreplacechild1: function(test) { var success; var doc; var entRef; var entElement; var attrNode; var textNode; var removedNode; var newChild; doc = staff.staff(); entRef = doc.createEntityReference("ent4"); test.notEqual(entRef, null, 'createdEntRefNotNull'); entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); attrNode = entElement.getAttributeNode("domestic"); textNode = attrNode.firstChild; test.notEqual(textNode, null, 'attrChildNotNull'); newChild = doc.createTextNode("Yesterday"); { success = false; try { removedNode = attrNode.replaceChild(newChild,textNode); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'setValue_throws_NO_MODIFICATION_ERR'); } test.done(); }, /** * The "setValue()" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Get the "domestic" attribute from the entity reference and execute the "setValue()" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#ID-221662474 * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-221662474')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 */ attrsetvaluenomodificationallowederr: function(test) { var success; var doc; var genderList; var gender; var genList; var gen; var gList; var g; var attrList; var attrNode; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); test.notEqual(gender, null, 'genderNotNull'); genList = gender.childNodes; gen = genList.item(0); test.notEqual(gen, null, 'genderFirstChildNotNull'); gList = gen.childNodes; g = gList.item(0); test.notEqual(g, null, 'genderFirstGrandchildNotNull'); attrList = g.attributes; test.notEqual(attrList, null, 'attributesNotNull'); attrNode = attrList.getNamedItem("domestic"); test.notEqual(attrNode, null, 'attrNotNull'); { success = false; try { attrNode.value = "newvalue"; } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'setValue_throws_NO_MODIFICATION'); } { success = false; try { attrNode.nodeValue = "newvalue2"; } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'setNodeValue_throws_NO_MODIFICATION'); } test.done(); }, /** * The "setValue()" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Create an entity reference using document.createEntityReference() Get the "domestic" attribute from the entity reference and execute the "setValue()" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author Curt Arnold * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#ID-221662474 * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-221662474')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474 * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrsetvaluenomodificationallowederr.xml */ attrsetvaluenomodificationallowederrEE: function(test) { var success; var doc; var entRef; var entElement; var attrList; var attrNode; var gender; var genderList; var appendedChild; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); test.notEqual(gender, null, 'genderNotNull'); entRef = doc.createEntityReference("ent4"); test.notEqual(entRef, null, 'entRefNotNull'); appendedChild = gender.appendChild(entRef); entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); attrList = entElement.attributes; attrNode = attrList.getNamedItem("domestic"); { success = false; try { attrNode.value = "newvalue"; } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'setValue_throws_NO_MODIFICATION'); } { success = false; try { attrNode.nodeValue = "newvalue2"; } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'setNodeValue_throws_NO_MODIFICATION'); } test.done(); }, /** * The "getSpecified()" method for an Attr node should be set to true if the attribute was explicitly given a value. Retrieve the attribute named "domestic" from the last child of of the first employee and examine the value returned by the "getSpecified()" method. This test uses the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273 */ attrspecifiedvalue: function(test) { var success; var doc; var addressList; var testNode; var attributes; var domesticAttr; var state; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(0); attributes = testNode.attributes; domesticAttr = attributes.getNamedItem("domestic"); state = domesticAttr.specified; test.ok(state, 'domesticSpecified'); test.done(); }, /** * The "getSpecified()" method for an Attr node should return true if the value of the attribute is changed. Retrieve the attribute named "street" from the last child of of the THIRD employee and change its value to "Yes"(which is the default DTD value). This should cause the "getSpecified()" method to be true. This test uses the "setAttribute(name,value)" method from the Element interface and the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273 */ attrspecifiedvaluechanged: function(test) { var success; var doc; var addressList; var testNode; var attributes; var streetAttr; var state; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(2); testNode.setAttribute("street","Yes"); attributes = testNode.attributes; streetAttr = attributes.getNamedItem("street"); state = streetAttr.specified; test.ok(state, 'streetSpecified'); test.done(); }, /** * To respecify the attribute to its default value from the DTD, the attribute must be deleted. This will then make a new attribute available with the "getSpecified()" method value set to false. Retrieve the attribute named "street" from the last child of of the THIRD employee and delete it. This should then create a new attribute with its default value and also cause the "getSpecified()" method to return false. This test uses the "removeAttribute(name)" method from the Element interface and the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html */ attrspecifiedvalueremove: function(test) { var success; var doc; var addressList; var testNode; var attributes; var streetAttr; var state; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testNode = addressList.item(2); testNode.removeAttribute("street"); attributes = testNode.attributes; streetAttr = attributes.getNamedItem("street"); test.notEqual(streetAttr, null, 'streetAttrNotNull'); state = streetAttr.specified; test.equal(state, false, 'attrSpecifiedValueRemoveAssert'); test.done(); }, /** * Retrieve the last CDATASection node located inside the second child of the second employee and examine its content. Since the CDATASection interface inherits from the CharacterData interface(via the Text node), the "getData()" method can be used to access the CDATA content. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 */ cdatasectiongetdata: function(test) { var success; var doc; var nameList; var child; var lastChild; var data; var nodeType; doc = staff.staff(); nameList = doc.getElementsByTagName("name"); child = nameList.item(1); lastChild = child.lastChild; nodeType = lastChild.nodeType; test.equal(nodeType, 4, 'isCDATA'); data = lastChild.data; test.equal(data, 'This is an adjacent CDATASection with a reference to a tab &tab;', 'data'); test.done(); }, /** * Adjacent CDATASection nodes cannot be merged together by use of the "normalize()" method from the Element interface. Retrieve second child of the second employee and invoke the "normalize()" method. The Element under contains two CDATASection nodes that should not be merged together by the "normalize()" method. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083 */ cdatasectionnormalize: function(test) { var success; var doc; var nameList; var lChild; var childNodes; var cdataN; var data; doc = staff.staff(); nameList = doc.getElementsByTagName("name"); lChild = nameList.item(1); lChild.normalize(); childNodes = lChild.childNodes; cdataN = childNodes.item(1); test.notEqual(cdataN, null, 'firstCDATASection'); data = cdataN.data; test.equal(data, 'This is a CDATASection with EntityReference number 2 &ent2;', 'data1'); cdataN = childNodes.item(3); test.notEqual(cdataN, null, 'secondCDATASection'); data = cdataN.data; test.equal(data, 'This is an adjacent CDATASection with a reference to a tab &tab;', 'data3'); test.done(); }, /** * The "appendData(arg)" method appends a string to the end of the character data of the node. Retrieve the character data from the second child of the first employee. The appendData(arg) method is called with arg=", Esquire". The method should append the specified data to the already existing character data. The new value return by the "getLength()" method should be 24. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F */ characterdataappenddata: function(test) { var success; var doc; var elementList; var nameNode; var child; var childValue; var childLength; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; child.appendData(", Esquire"); childValue = child.data; childLength = childValue.length; test.equal(childLength, 24, 'characterdataAppendDataAssert'); test.done(); }, /** * On successful invocation of the "appendData(arg)" method the "getData()" method provides access to the concatentation of data and the specified string. Retrieve the character data from the second child of the first employee. The appendData(arg) method is called with arg=", Esquire". The method should append the specified data to the already existing character data. The new value return by the "getData()" method should be "Margaret Martin, Esquire". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F */ characterdataappenddatagetdata: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; child.appendData(", Esquire"); childData = child.data; test.equal(childData, 'Margaret Martin, Esquire', 'characterdataAppendDataGetDataAssert'); test.done(); }, /** * The "appendData(arg)" method raises a NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Get the FIRST item from the entity reference and execute the "appendData(arg)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-32791A2F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F */ characterdataappenddatanomodificationallowederr: function(test) { var success; var doc; var genderList; var genderNode; var entElement; var entElementContent; var entReference; var nodeType; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = genderNode.firstChild; test.notEqual(entReference, null, 'entReferenceNotNull'); nodeType = entReference.nodeType; if( (1 == nodeType) ) { entReference = doc.createEntityReference("ent4"); test.notEqual(entReference, null, 'createdEntRefNotNull'); } entElement = entReference.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); entElementContent = entElement.firstChild; test.notEqual(entElementContent, null, 'entElementContentNotNull'); { success = false; try { entElementContent.appendData("newString"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * Create an ent3 entity reference and call appendData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-32791A2F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddatanomodificationallowederr.xml */ characterdataappenddatanomodificationallowederrEE: function(test) { var success; var doc; var genderList; var genderNode; var entText; var entReference; var appendedChild; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = doc.createEntityReference("ent3"); test.notEqual(entReference, null, 'createdEntRefNotNull'); appendedChild = genderNode.appendChild(entReference); entText = entReference.firstChild; test.notEqual(entText, null, 'entTextNotNull'); { success = false; try { entText.appendData("newString"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "deleteData(offset,count)" method removes a range of characters from the node. Delete data at the beginning of the character data. Retrieve the character data from the last child of the first employee. The "deleteData(offset,count)" method is then called with offset=0 and count=16. The method should delete the characters from position 0 thru position 16. The new value of the character data should be "Dallas, Texas 98551". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 */ characterdatadeletedatabegining: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.deleteData(0,16); childData = child.data; test.equal(childData, 'Dallas, Texas 98551', 'characterdataDeleteDataBeginingAssert'); test.done(); }, /** * The "deleteData(offset,count)" method removes a range of characters from the node. Delete data at the end of the character data. Retrieve the character data from the last child of the first employee. The "deleteData(offset,count)" method is then called with offset=30 and count=5. The method should delete the characters from position 30 thru position 35. The new value of the character data should be "1230 North Ave. Dallas, Texas". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 */ characterdatadeletedataend: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.deleteData(30,5); childData = child.data; test.equal(childData, '1230 North Ave. Dallas, Texas ', 'characterdataDeleteDataEndAssert'); test.done(); }, /** * If the sum of the offset and count used in the "deleteData(offset,count) method is greater than the length of the character data then all the characters from the offset to the end of the data are deleted. Retrieve the character data from the last child of the first employee. The "deleteData(offset,count)" method is then called with offset=4 and count=50. The method should delete the characters from position 4 to the end of the data since the offset+count(50+4) is greater than the length of the character data(35). The new value of the character data should be "1230". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 */ characterdatadeletedataexceedslength: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.deleteData(4,50); childData = child.data; test.equal(childData, '1230', 'characterdataDeleteDataExceedsLengthAssert'); test.done(); }, /** * On successful invocation of the "deleteData(offset,count)" method, the "getData()" and "getLength()" methods reflect the changes. Retrieve the character data from the last child of the first employee. The "deleteData(offset,count)" method is then called with offset=30 and count=5. The method should delete the characters from position 30 thru position 35. The new value of the character data should be "1230 North Ave. Dallas, Texas" which is returned by the "getData()" method and "getLength()" method should return 30". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 */ characterdatadeletedatagetlengthanddata: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; var childLength; var result = new Array(); doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.deleteData(30,5); childData = child.data; test.equal(childData, '1230 North Ave. Dallas, Texas ', 'data'); childLength = child.length; test.equal(childLength, 30, 'length'); test.done(); }, /** * The "deleteData(offset,count)" method removes a range of characters from the node. Delete data in the middle of the character data. Retrieve the character data from the last child of the first employee. The "deleteData(offset,count)" method is then called with offset=16 and count=8. The method should delete the characters from position 16 thru position 24. The new value of the character data should be "1230 North Ave. Texas 98551". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 */ characterdatadeletedatamiddle: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.deleteData(16,8); childData = child.data; test.equal(childData, '1230 North Ave. Texas 98551', 'characterdataDeleteDataMiddleAssert'); test.done(); }, /** * The "deleteData(offset,count)" method raises a NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Get the FIRST item from the entity reference and execute the "deleteData(offset,count)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 */ characterdatadeletedatanomodificationallowederr: function(test) { var success; var doc; var genderList; var genderNode; var entElement; var entElementContent; var nodeType; var entReference; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = genderNode.firstChild; test.notEqual(entReference, null, 'entReferenceNotNull'); nodeType = entReference.nodeType; if( (3 == nodeType) ) { entReference = doc.createEntityReference("ent4"); test.notEqual(entReference, null, 'createdEntRefNotNull'); } entElement = entReference.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); entElementContent = entElement.firstChild; test.notEqual(entElementContent, null, 'entElementContentNotNull'); { success = false; try { entElementContent.deleteData(1,3); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * Create an ent3 entity reference and call deleteData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatanomodificationallowederr.xml */ characterdatadeletedatanomodificationallowederrEE: function(test) { var success; var doc; var genderList; var genderNode; var entText; var entReference; var appendedChild; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = doc.createEntityReference("ent3"); test.notEqual(entReference, null, 'createdEntRefNotNull'); appendedChild = genderNode.appendChild(entReference); entText = entReference.firstChild; test.notEqual(entText, null, 'entTextNotNull'); { success = false; try { entText.deleteData(1,3); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "getData()" method retrieves the character data currently stored in the node. Retrieve the character data from the second child of the first employee and invoke the "getData()" method. The method returns the character data string. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 */ characterdatagetdata: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; childData = child.data; test.equal(childData, 'Margaret Martin', 'characterdataGetDataAssert'); test.done(); }, /** * The "getLength()" method returns the number of characters stored in this nodes data. Retrieve the character data from the second child of the first employee and examine the value returned by the getLength() method. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C */ characterdatagetlength: function(test) { var success; var doc; var elementList; var nameNode; var child; var childValue; var childLength; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; childValue = child.data; childLength = childValue.length; test.equal(childLength, 15, 'characterdataGetLengthAssert'); test.done(); }, /** * The "deleteData(offset,count)" method raises an INDEX_SIZE_ERR DOMException if the specified count is negative. Retrieve the character data of the last child of the first employee and invoke its "deleteData(offset,count)" method with offset=10 and count=-3. It should raise the desired exception since the count is negative. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) */ characterdataindexsizeerrdeletedatacountnegative: function(test) { var success; var doc; var elementList; var nameNode; var child; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { child.deleteData(10,-3); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throws_INDEX_SIZE_ERR'); } test.done(); }, /** * The "deleteData(offset,count)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater that the number of characters in the string. Retrieve the character data of the last child of the first employee and invoke its "deleteData(offset,count)" method with offset=40 and count=3. It should raise the desired exception since the offset is greater than the number of characters in the string. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ characterdataindexsizeerrdeletedataoffsetgreater: function(test) { var success; var doc; var elementList; var nameNode; var child; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { child.deleteData(40,3); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throw_INDEX_SIZE_ERR'); } test.done(); }, /** * The "deleteData(offset,count)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative. Retrieve the character data of the last child of the first employee and invoke its "deleteData(offset,count)" method with offset=-5 and count=3. It should raise the desired exception since the offset is negative. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 */ characterdataindexsizeerrdeletedataoffsetnegative: function(test) { var success; var doc; var elementList; var nameNode; var child; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { child.deleteData(-5,3); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throws_INDEX_SIZE_ERR'); } test.done(); }, /** * The "insertData(offset,arg)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the number of characters in the string. Retrieve the character data of the last child of the first employee and invoke its insertData"(offset,arg)" method with offset=40 and arg="ABC". It should raise the desired exception since the offset is greater than the number of characters in the string. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ characterdataindexsizeerrinsertdataoffsetgreater: function(test) { var success; var doc; var elementList; var nameNode; var child; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { child.insertData(40,"ABC"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throw_INDEX_SIZE_ERR'); } test.done(); }, /** * The "insertData(offset,arg)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative. Retrieve the character data of the last child of the first employee and invoke its insertData"(offset,arg)" method with offset=-5 and arg="ABC". It should raise the desired exception since the offset is negative. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) */ characterdataindexsizeerrinsertdataoffsetnegative: function(test) { var success; var doc; var elementList; var nameNode; var child; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { child.insertData(-5,"ABC"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throws_INDEX_SIZE_ERR'); } test.done(); }, /** * The "replaceData(offset,count,arg)" method raises an INDEX_SIZE_ERR DOMException if the specified count is negative. Retrieve the character data of the last child of the first employee and invoke its "replaceData(offset,count,arg) method with offset=10 and count=-3 and arg="ABC". It should raise the desired exception since the count is negative. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) */ characterdataindexsizeerrreplacedatacountnegative: function(test) { var success; var doc; var elementList; var nameNode; var child; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { child.replaceData(10,-3,"ABC"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throws_INDEX_SIZE_ERR'); } test.done(); }, /** * The "replaceData(offset,count,arg)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the length of the string. Retrieve the character data of the last child of the first employee and invoke its "replaceData(offset,count,arg) method with offset=40 and count=3 and arg="ABC". It should raise the desired exception since the offset is greater than the length of the string. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ characterdataindexsizeerrreplacedataoffsetgreater: function(test) { var success; var doc; var elementList; var nameNode; var child; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { child.replaceData(40,3,"ABC"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throw_INDEX_SIZE_ERR'); } test.done(); }, /** * The "replaceData(offset,count,arg)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative. Retrieve the character data of the last child of the first employee and invoke its "replaceData(offset,count,arg) method with offset=-5 and count=3 and arg="ABC". It should raise the desired exception since the offset is negative. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB */ characterdataindexsizeerrreplacedataoffsetnegative: function(test) { var success; var doc; var elementList; var nameNode; var child; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { child.replaceData(-5,3,"ABC"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throws_INDEX_SIZE_ERR'); } test.done(); }, /** * The "substringData(offset,count)" method raises an INDEX_SIZE_ERR DOMException if the specified count is negative. Retrieve the character data of the last child of the first employee and invoke its "substringData(offset,count) method with offset=10 and count=-3. It should raise the desired exception since the count is negative. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) */ characterdataindexsizeerrsubstringcountnegative: function(test) { var success; var doc; var elementList; var nameNode; var child; var badSubstring; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { badSubstring = child.substringData(10,-3); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throws_INDEX_SIZE_ERR'); } test.done(); }, /** * The "substringData(offset,count)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative. Retrieve the character data of the last child of the first employee and invoke its "substringData(offset,count) method with offset=-5 and count=3. It should raise the desired exception since the offset is negative. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) */ characterdataindexsizeerrsubstringnegativeoffset: function(test) { var success; var doc; var elementList; var nameNode; var child; var badString; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { badString = child.substringData(-5,3); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throws_INDEX_SIZE_ERR'); } test.done(); }, /** * The "substringData(offset,count)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the number of characters in the string. Retrieve the character data of the last child of the first employee and invoke its "substringData(offset,count) method with offset=40 and count=3. It should raise the desired exception since the offsets value is greater than the length. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ characterdataindexsizeerrsubstringoffsetgreater: function(test) { var success; var doc; var elementList; var nameNode; var child; var badString; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; { success = false; try { badString = child.substringData(40,3); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throw_INDEX_SIZE_ERR'); } test.done(); }, /** * The "insertData(offset,arg)" method will insert a string at the specified character offset. Insert the data at the beginning of the character data. Retrieve the character data from the second child of the first employee. The "insertData(offset,arg)" method is then called with offset=0 and arg="Mss.". The method should insert the string "Mss." at position 0. The new value of the character data should be "Mss. Margaret Martin". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F */ characterdatainsertdatabeginning: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; child.insertData(0,"Mss. "); childData = child.data; test.equal(childData, 'Mss. Margaret Martin', 'characterdataInsertDataBeginningAssert'); test.done(); }, /** * The "insertData(offset,arg)" method will insert a string at the specified character offset. Insert the data at the end of the character data. Retrieve the character data from the second child of the first employee. The "insertData(offset,arg)" method is then called with offset=15 and arg=", Esquire". The method should insert the string ", Esquire" at position 15. The new value of the character data should be "Margaret Martin, Esquire". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F */ characterdatainsertdataend: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; child.insertData(15,", Esquire"); childData = child.data; test.equal(childData, 'Margaret Martin, Esquire', 'characterdataInsertDataEndAssert'); test.done(); }, /** * The "insertData(offset,arg)" method will insert a string at the specified character offset. Insert the data in the middle of the character data. Retrieve the character data from the second child of the first employee. The "insertData(offset,arg)" method is then called with offset=9 and arg="Ann". The method should insert the string "Ann" at position 9. The new value of the character data should be "Margaret Ann Martin". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F */ characterdatainsertdatamiddle: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; child.insertData(9,"Ann "); childData = child.data; test.equal(childData, 'Margaret Ann Martin', 'characterdataInsertDataMiddleAssert'); test.done(); }, /** * The "insertData(offset,arg)" method raises a NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Get the FIRST item from the entity reference and execute the "insertData(offset,arg)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-3EDB695F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F */ characterdatainsertdatanomodificationallowederr: function(test) { var success; var doc; var genderList; var genderNode; var entElement; var nodeType; var entElementContent; var entReference; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = genderNode.firstChild; test.notEqual(entReference, null, 'entReferenceNotNull'); nodeType = entReference.nodeType; if( (1 == nodeType) ) { entReference = doc.createEntityReference("ent4"); test.notEqual(entReference, null, 'createdEntRefNotNull'); } entElement = entReference.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); entElementContent = entElement.firstChild; test.notEqual(entElementContent, null, 'entElementContentNotNull'); { success = false; try { entElementContent.insertData(1,"newArg"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * Create an ent3 entity reference and call insertData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-3EDB695F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatanomodificationallowederr.xml */ characterdatainsertdatanomodificationallowederrEE: function(test) { var success; var doc; var genderList; var genderNode; var entText; var entReference; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = doc.createEntityReference("ent3"); test.notEqual(entReference, null, 'createdEntRefNotNull'); entText = entReference.firstChild; test.notEqual(entText, null, 'entTextNotNull'); { success = false; try { entText.insertData(1,"newArg"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "replaceData(offset,count,arg)" method replaces the characters starting at the specified offset with the specified string. Test for replacement in the middle of the data. Retrieve the character data from the last child of the first employee. The "replaceData(offset,count,arg)" method is then called with offset=5 and count=5 and arg="South". The method should replace characters five thru 9 of the character data with "South". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB */ characterdatareplacedatabegining: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.replaceData(0,4,"2500"); childData = child.data; test.equal(childData, '2500 North Ave. Dallas, Texas 98551', 'characterdataReplaceDataBeginingAssert'); test.done(); }, /** * The "replaceData(offset,count,arg)" method replaces the characters starting at the specified offset with the specified string. Test for replacement at the end of the data. Retrieve the character data from the last child of the first employee. The "replaceData(offset,count,arg)" method is then called with offset=30 and count=5 and arg="98665". The method should replace characters 30 thru 34 of the character data with "98665". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB */ characterdatareplacedataend: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.replaceData(30,5,"98665"); childData = child.data; test.equal(childData, '1230 North Ave. Dallas, Texas 98665', 'characterdataReplaceDataEndAssert'); test.done(); }, /** * The "replaceData(offset,count,arg)" method replaces the characters starting at the specified offset with the specified string. Test the situation where the length of the arg string is greater than the specified offset. Retrieve the character data from the last child of the first employee. The "replaceData(offset,count,arg)" method is then called with offset=0 and count=4 and arg="260030". The method should replace characters one thru four with "260030". Note that the length of the specified string is greater that the specified offset. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB */ characterdatareplacedataexceedslengthofarg: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.replaceData(0,4,"260030"); childData = child.data; test.equal(childData, '260030 North Ave. Dallas, Texas 98551', 'characterdataReplaceDataExceedsLengthOfArgAssert'); test.done(); }, /** * If the sum of the offset and count exceeds the length then all the characters to the end of the data are replaced. Retrieve the character data from the last child of the first employee. The "replaceData(offset,count,arg)" method is then called with offset=0 and count=50 and arg="2600". The method should replace all the characters with "2600". This is because the sum of the offset and count exceeds the length of the character data. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB */ characterdatareplacedataexceedslengthofdata: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.replaceData(0,50,"2600"); childData = child.data; test.equal(childData, '2600', 'characterdataReplaceDataExceedsLengthOfDataAssert'); test.done(); }, /** * The "replaceData(offset,count,arg)" method replaces the characters starting at the specified offset with the specified string. Test for replacement in the middle of the data. Retrieve the character data from the last child of the first employee. The "replaceData(offset,count,arg)" method is then called with offset=5 and count=5 and arg="South". The method should replace characters five thru 9 of the character data with "South". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB */ characterdatareplacedatamiddle: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); nameNode = elementList.item(0); child = nameNode.firstChild; child.replaceData(5,5,"South"); childData = child.data; test.equal(childData, '1230 South Ave. Dallas, Texas 98551', 'characterdataReplaceDataMiddleAssert'); test.done(); }, /** * The "replaceData(offset,count,arg)" method raises a NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Get the FIRST item from the entity reference and execute the "replaceData(offset,count,arg)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB */ characterdatareplacedatanomodificationallowederr: function(test) { var success; var doc; var genderList; var genderNode; var entElement; var entElementContent; var entReference; var nodeType; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = genderNode.firstChild; test.notEqual(entReference, null, 'entReferenceNotNull'); nodeType = entReference.nodeType; if( (1 == nodeType) ) { entReference = doc.createEntityReference("ent4"); test.notEqual(entReference, null, 'createdEntRefNotNull'); } entElement = entReference.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); entElementContent = entElement.firstChild; test.notEqual(entElementContent, null, 'entElementContentNotNull'); { success = false; try { entElementContent.replaceData(1,3,"newArg"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * Create an ent3 entity reference and call replaceData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatanomodificationallowederr.xml */ characterdatareplacedatanomodificationallowederrEE: function(test) { var success; var doc; var genderList; var genderNode; var entText; var entReference; var appendedNode; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = doc.createEntityReference("ent3"); test.notEqual(entReference, null, 'createdEntRefNotNull'); appendedNode = genderNode.appendChild(entReference); entText = entReference.firstChild; test.notEqual(entText, null, 'entTextNotNull'); { success = false; try { entText.replaceData(1,3,"newArg"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "setData(data)" method raises a NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Get the FIRST item from the entity reference and execute the "setData(data)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-72AB8359')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 */ characterdatasetdatanomodificationallowederr: function(test) { var success; var doc; var genderList; var genderNode; var entElement; var entElementContent; var entReference; var nodeType; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(2); entReference = genderNode.firstChild; test.notEqual(entReference, null, 'entReferenceNotNull'); nodeType = entReference.nodeType; if( (1 == nodeType) ) { entReference = doc.createEntityReference("ent4"); test.notEqual(entReference, null, 'createdEntRefNotNull'); } entElement = entReference.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); entElementContent = entElement.firstChild; test.notEqual(entElementContent, null, 'entElementContentNotNull'); { success = false; try { entElementContent.data = "newData"; } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * Create an ent3 entity reference and call setData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-72AB8359')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasetdatanomodificationallowederr.xml */ characterdatasetdatanomodificationallowederrEE: function(test) { var success; var doc; var genderList; var genderNode; var entText; var entReference; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); genderNode = genderList.item(4); entReference = doc.createEntityReference("ent3"); test.notEqual(entReference, null, 'createdEntRefNotNull'); entText = entReference.firstChild; test.notEqual(entText, null, 'entTextNotNull'); { success = false; try { entText.data = "newData"; } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "setNodeValue()" method changes the character data currently stored in the node. Retrieve the character data from the second child of the first employee and invoke the "setNodeValue()" method, call "getData()" and compare. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359 */ characterdatasetnodevalue: function(test) { var success; var doc; var elementList; var nameNode; var child; var childData; var childValue; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; child.nodeValue = "Marilyn Martin"; childData = child.data; test.equal(childData, 'Marilyn Martin', 'data'); childValue = child.nodeValue; test.equal(childValue, 'Marilyn Martin', 'value'); test.done(); }, /** * If the sum of the "offset" and "count" exceeds the "length" then the "substringData(offset,count)" method returns all the characters to the end of the data. Retrieve the character data from the second child of the first employee and access part of the data by using the substringData(offset,count) method with offset=9 and count=10. The method should return the substring "Martin" since offset+count > length (19 > 15). * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF */ characterdatasubstringexceedsvalue: function(test) { var success; var doc; var elementList; var nameNode; var child; var substring; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; substring = child.substringData(9,10); test.equal(substring, 'Martin', 'characterdataSubStringExceedsValueAssert'); test.done(); }, /** * The "substringData(offset,count)" method returns the specified string. Retrieve the character data from the second child of the first employee and access part of the data by using the substringData(offset,count) method. The method should return the specified substring starting at position "offset" and extract "count" characters. The method should return the string "Margaret". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF */ characterdatasubstringvalue: function(test) { var success; var doc; var elementList; var nameNode; var child; var substring; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(0); child = nameNode.firstChild; substring = child.substringData(0,8); test.equal(substring, 'Margaret', 'characterdataSubStringValueAssert'); test.done(); }, /** * A comment is all the characters between the starting '' Retrieve the nodes of the DOM document. Search for a comment node and the content is its value. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328 * @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-F68D080 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 */ commentgetcomment: function(test) { var success; var doc; var elementList; var child; var childName; var childValue; var commentCount = 0; var childType; doc = staff.staff(); elementList = doc.childNodes; for(var indexN10057 = 0;indexN10057 < elementList.length; indexN10057++) { child = elementList.item(indexN10057); childType = child.nodeType; if( (8 == childType) ) { childName = child.nodeName; test.equal(childName, '#comment', 'nodeName'); childValue = child.nodeValue; test.equal(childValue, ' This is comment number 1.', 'nodeValue'); commentCount = commentCount + 1; } } test.equal(commentCount, 1, 'commentCount'); test.done(); }, /** * The "createAttribute(name)" method creates an Attribute node of the given name. Retrieve the entire DOM document and invoke its "createAttribute(name)" method. It should create a new Attribute node with the given name. The name, value and type of the newly created object are retrieved and output. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 */ documentcreateattribute: function(test) { var success; var doc; var newAttrNode; var attrValue; var attrName; var attrType; doc = staff.staff(); newAttrNode = doc.createAttribute("district"); attrValue = newAttrNode.nodeValue; test.equal(attrValue, '', 'value'); attrName = newAttrNode.nodeName; test.equal(attrName, 'district', 'name'); attrType = newAttrNode.nodeType; test.equal(attrType, 2, 'type'); test.done(); }, /** * The "createCDATASection(data)" method creates a new CDATASection node whose value is the specified string. Retrieve the entire DOM document and invoke its "createCDATASection(data)" method. It should create a new CDATASection node whose "data" is the specified string. The content, name and type are retrieved and output. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D26C0AF8 */ documentcreatecdatasection: function(test) { var success; var doc; var newCDATASectionNode; var newCDATASectionValue; var newCDATASectionName; var newCDATASectionType; doc = staff.staff(); newCDATASectionNode = doc.createCDATASection("This is a new CDATASection node"); newCDATASectionValue = newCDATASectionNode.nodeValue; test.equal(newCDATASectionValue, 'This is a new CDATASection node', 'nodeValue'); newCDATASectionName = newCDATASectionNode.nodeName; test.equal(newCDATASectionName, '#cdata-section', 'nodeName'); newCDATASectionType = newCDATASectionNode.nodeType; test.equal(newCDATASectionType, 4, 'nodeType'); test.done(); }, /** * The "createComment(data)" method creates a new Comment node given the specified string. Retrieve the entire DOM document and invoke its "createComment(data)" method. It should create a new Comment node whose "data" is the specified string. The content, name and type are retrieved and output. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328 */ documentcreatecomment: function(test) { var success; var doc; var newCommentNode; var newCommentValue; var newCommentName; var newCommentType; doc = staff.staff(); newCommentNode = doc.createComment("This is a new Comment node"); newCommentValue = newCommentNode.nodeValue; test.equal(newCommentValue, 'This is a new Comment node', 'value'); newCommentName = newCommentNode.nodeName; test.equal(newCommentName, '#comment', 'name'); newCommentType = newCommentNode.nodeType; test.equal(newCommentType, 8, 'type'); test.done(); }, /** * The "createDocumentFragment()" method creates an empty DocumentFragment object. Retrieve the entire DOM document and invoke its "createDocumentFragment()" method. The content, name, type and value of the newly created object are output. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5 */ documentcreatedocumentfragment: function(test) { var success; var doc; var newDocFragment; var children; var length; var newDocFragmentName; var newDocFragmentType; var newDocFragmentValue; doc = staff.staff(); newDocFragment = doc.createDocumentFragment(); children = newDocFragment.childNodes; length = children.length; test.equal(length, 0, 'length'); newDocFragmentName = newDocFragment.nodeName; test.equal(newDocFragmentName, '#document-fragment', 'name'); newDocFragmentType = newDocFragment.nodeType; test.equal(newDocFragmentType, 11, 'type'); newDocFragmentValue = newDocFragment.nodeValue; test.equal(newDocFragmentValue, null, 'value'); test.done(); }, /** * The "createElement(tagName)" method creates an Element of the type specified. Retrieve the entire DOM document and invoke its "createElement(tagName)" method with tagName="address". The method should create an instance of an Element node whose tagName is "address". The NodeName, NodeType and NodeValue are returned. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 */ documentcreateelement: function(test) { var success; var doc; var newElement; var newElementName; var newElementType; var newElementValue; doc = staff.staff(); newElement = doc.createElement("address"); newElementName = newElement.nodeName; test.equal(newElementName, 'address', 'name'); newElementType = newElement.nodeType; test.equal(newElementType, 1, 'type'); newElementValue = newElement.nodeValue; test.equal(newElementValue, null, 'valueInitiallyNull'); test.done(); }, /** * The tagName parameter in the "createElement(tagName)" method is case-sensitive for XML documents. Retrieve the entire DOM document and invoke its "createElement(tagName)" method twice. Once for tagName equal to "address" and once for tagName equal to "ADDRESS" Each call should create a distinct Element node. The newly created Elements are then assigned attributes that are retrieved. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 */ documentcreateelementcasesensitive: function(test) { var success; var doc; var newElement1; var newElement2; var attribute1; var attribute2; doc = staff.staff(); newElement1 = doc.createElement("ADDRESS"); newElement2 = doc.createElement("address"); newElement1.setAttribute("district","Fort Worth"); newElement2.setAttribute("county","Dallas"); attribute1 = newElement1.getAttribute("district"); attribute2 = newElement2.getAttribute("county"); test.equal(attribute1, 'Fort Worth', 'attrib1'); test.equal(attribute2, 'Dallas', 'attrib2'); test.done(); }, /** * The "createElement(tagName)" method creates an Element of the type specified. In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element. Retrieve the entire DOM document and invoke its "createElement(tagName)" method with tagName="address". The method should create an instance of an Element node whose tagName is "address". The tagName "address" has an attribute with default values, therefore the newly created element will have them. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html */ documentcreateelementdefaultattr: function(test) { var success; var doc; var newElement; var defaultAttr; var child; var name; var value; doc = staff.staff(); newElement = doc.createElement("address"); defaultAttr = newElement.attributes; child = defaultAttr.item(0); test.notEqual(child, null, 'defaultAttrNotNull'); name = child.nodeName; test.equal(name, 'street', 'attrName'); value = child.nodeValue; test.equal(value, 'Yes', 'attrValue'); test.equal(defaultAttr.length, 1, 'attrCount'); test.done(); }, /** * The "createEntityReference(name)" method creates an EntityReferrence node. Retrieve the entire DOM document and invoke its "createEntityReference(name)" method. It should create a new EntityReference node for the Entity with the given name. The name, value and type are retrieved and output. * @author NIST * @author Mary Brady * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 */ documentcreateentityreference: function(test) { var success; var doc; var newEntRefNode; var entRefValue; var entRefName; var entRefType; doc = staff.staff(); newEntRefNode = doc.createEntityReference("ent1"); test.notEqual(newEntRefNode, null, 'createdEntRefNotNull'); entRefValue = newEntRefNode.nodeValue; test.equal(entRefValue, null, 'value'); entRefName = newEntRefNode.nodeName; test.equal(entRefName, 'ent1', 'name'); entRefType = newEntRefNode.nodeType; test.equal(entRefType, 5, 'type'); test.done(); }, /** * The "createEntityReference(name)" method creates an EntityReference node. In addition, if the referenced entity is known, the child list of the "EntityReference" node is the same as the corresponding "Entity" node. Retrieve the entire DOM document and invoke its "createEntityReference(name)" method. It should create a new EntityReference node for the Entity with the given name. The referenced entity is known, therefore the child list of the "EntityReference" node is the same as the corresponding "Entity" node. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE */ documentcreateentityreferenceknown: function(test) { var success; var doc; var newEntRefNode; var newEntRefList; var child; var name; var value; doc = staff.staff(); newEntRefNode = doc.createEntityReference("ent3"); test.notEqual(newEntRefNode, null, 'createdEntRefNotNull'); newEntRefList = newEntRefNode.childNodes; test.equal(newEntRefList.length, 1, 'size'); child = newEntRefNode.firstChild; name = child.nodeName; test.equal(name, '#text', 'name'); value = child.nodeValue; test.equal(value, 'Texas', 'value'); test.done(); }, /** * The "createProcessingInstruction(target,data)" method creates a new ProcessingInstruction node with the specified name and data string. Retrieve the entire DOM document and invoke its "createProcessingInstruction(target,data)" method. It should create a new PI node with the specified target and data. The target, data and type are retrieved and output. * @author NIST * @author Mary Brady * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core# * @see http://lists.w3.org/Archives/Public/www-dom-ts/2001Apr/0020.html * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ documentcreateprocessinginstruction: function(test) { var success; var doc; var newPINode; var piValue; var piName; var piType; doc = staff.staff(); newPINode = doc.createProcessingInstruction("TESTPI","This is a new PI node"); test.notEqual(newPINode, null, 'createdPINotNull'); piName = newPINode.nodeName; test.equal(piName, 'TESTPI', 'name'); piValue = newPINode.nodeValue; test.equal(piValue, 'This is a new PI node', 'value'); piType = newPINode.nodeType; test.equal(piType, 7, 'type'); test.done(); }, /** * The "createTextNode(data)" method creates a Text node given the specfied string. Retrieve the entire DOM document and invoke its "createTextNode(data)" method. It should create a new Text node whose "data" is the specified string. The NodeName and NodeType are also checked. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1975348127 */ documentcreatetextnode: function(test) { var success; var doc; var newTextNode; var newTextName; var newTextValue; var newTextType; doc = staff.staff(); newTextNode = doc.createTextNode("This is a new Text node"); newTextValue = newTextNode.nodeValue; test.equal(newTextValue, 'This is a new Text node', 'value'); newTextName = newTextNode.nodeName; test.equal(newTextName, '#text', 'name'); newTextType = newTextNode.nodeType; test.equal(newTextType, 3, 'type'); test.done(); }, /** * The "getDoctype()" method returns the Document Type Declaration associated with this document. Retrieve the entire DOM document and invoke its "getDoctype()" method. The name of the document type should be returned. The "getName()" method should be equal to "staff" or "svg". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ documentgetdoctype: function(test) { var success; var doc; var docType; var docTypeName; var nodeValue; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); docTypeName = docType.name; test.equal(docTypeName, 'svg', 'doctypeNameSVG'); nodeValue = docType.nodeValue; test.equal(nodeValue, null, 'initiallyNull'); test.done(); }, /** * 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 success; var doc; var docType; doc = hc_nodtdstaff.hc_nodtdstaff(); docType = doc.doctype; test.equal(docType, null, 'documentGetDocTypeNoDTDAssert'); test.done(); }, /** * The "getElementsByTagName(tagName)" method returns a NodeList of all the Elements with a given tagName. Retrieve the entire DOM document and invoke its "getElementsByTagName(tagName)" method with tagName equal to "name". The method should return a NodeList that contains 5 elements. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 */ documentgetelementsbytagnamelength: function(test) { var success; var doc; var nameList; doc = staff.staff(); nameList = doc.getElementsByTagName("name"); test.equal(nameList.length, 5, 'documentGetElementsByTagNameLengthAssert'); test.done(); }, /** * Retrieve the entire DOM document, invoke getElementsByTagName("*") and check the length of the NodeList. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 */ documentgetelementsbytagnametotallength: function(test) { var success; var doc; var nameList; doc = staff.staff(); nameList = doc.getElementsByTagName("*"); test.equal(nameList.length, 39, 'elementCountSVG'); test.done(); }, /** * The "getElementsByTagName(tagName)" method returns a NodeList of all the Elements with a given tagName in a pre-order traversal of the tree. Retrieve the entire DOM document and invoke its "getElementsByTagName(tagName)" method with tagName equal to "name". The method should return a NodeList that contains 5 elements. The FOURTH item in the list is retrieved and output. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094 */ documentgetelementsbytagnamevalue: function(test) { var success; var doc; var nameList; var nameNode; var firstChild; var childValue; doc = staff.staff(); nameList = doc.getElementsByTagName("name"); nameNode = nameList.item(3); firstChild = nameNode.firstChild; childValue = firstChild.nodeValue; test.equal(childValue, 'Jeny Oconnor', 'documentGetElementsByTagNameValueAssert'); test.done(); }, /** * The "getImplementation()" method returns the DOMImplementation object that handles this document. Retrieve the entire DOM document and invoke its "getImplementation()" method. It should return a DOMImplementation whose "hasFeature("XML","1.0") method returns the boolean value "true". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1B793EBA */ documentgetimplementation: function(test) { var success; var doc; var docImpl; var state; doc = staff.staff(); docImpl = doc.implementation; state = docImpl.hasFeature("XML","1.0"); test.ok(state, 'documentGetImplementationAssert'); test.done(); }, /** * The "getDocumentElement()" method provides direct access to the child node that is the root element of the document. Retrieve the entire DOM document and invoke its "getDocumentElement()" method. It should return an Element node whose NodeName is "staff" (or "svg"). * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-87CD092 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 */ documentgetrootnode: function(test) { var success; var doc; var root; var rootName; doc = staff.staff(); root = doc.documentElement; rootName = root.nodeName; test.equal(rootName, 'svg', 'svgRootNode'); test.done(); }, /** * The "createAttribute(tagName)" method raises an INVALID_CHARACTER_ERR DOMException if the specified tagName contains an invalid character. Retrieve the entire DOM document and invoke its "createAttribute(tagName)" method with the tagName equal to the string "invalid^Name". Due to the invalid character the desired EXCEPTION should be raised. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1084891198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ documentinvalidcharacterexceptioncreateattribute: function(test) { var success; var doc; var createdAttr; doc = staff.staff(); { success = false; try { createdAttr = doc.createAttribute("invalid'Name"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 5); } test.ok(success, 'throw_INVALID_CHARACTER_ERR'); } test.done(); }, /** * The "createElement(tagName)" method raises an INVALID_CHARACTER_ERR DOMException if the specified tagName contains an invalid character. Retrieve the entire DOM document and invoke its "createElement(tagName)" method with the tagName equal to the string "invalid^Name". Due to the invalid character the desired EXCEPTION should be raised. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-2141741547')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ documentinvalidcharacterexceptioncreateelement: function(test) { var success; var doc; var badElement; doc = staff.staff(); { success = false; try { badElement = doc.createElement("invalid^Name"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 5); } test.ok(success, 'throw_INVALID_CHARACTER_ERR'); } test.done(); }, /** * The "createEntityReference(tagName)" method raises an INVALID_CHARACTER_ERR DOMException if the specified tagName contains an invalid character. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-392B75AE')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ documentinvalidcharacterexceptioncreateentref: function(test) { var success; var doc; var badEntityRef; doc = hc_staff.hc_staff(); success = false; try { badEntityRef = doc.createEntityReference("invalid^Name"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 5); } test.ok(success, 'throw_INVALID_CHARACTER_ERR'); test.done(); }, /** * Creating an entity reference with an empty name should cause an INVALID_CHARACTER_ERR. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-392B75AE')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 */ documentinvalidcharacterexceptioncreateentref1: function(test) { var success; var doc; var badEntityRef; doc = hc_staff.hc_staff(); success = false; try { badEntityRef = doc.createEntityReference(""); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 5); } test.ok(success, 'throw_INVALID_CHARACTER_ERR'); test.done(); }, /** * The "createProcessingInstruction(target,data) method raises an INVALID_CHARACTER_ERR DOMException if the specified tagName contains an invalid character. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-135944439')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ documentinvalidcharacterexceptioncreatepi: function(test) { var success; var doc; var badPI; doc = hc_staff.hc_staff(); success = false; try { badPI = doc.createProcessingInstruction("invalid^Name","data"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 5); } test.ok(success, 'throw_INVALID_CHARACTER_ERR'); test.done(); }, /** * Creating a processing instruction with an empty target should cause an INVALID_CHARACTER_ERR. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-135944439')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525 */ documentinvalidcharacterexceptioncreatepi1: function(test) { var success; var doc; var badPI; doc = hc_staff.hc_staff(); success = false; try { badPI = doc.createProcessingInstruction("","data"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 5); } test.ok(success, 'throw_INVALID_CHARACTER_ERR'); test.done(); }, /** * The "getName()" method contains the name of the DTD. Retrieve the Document Type for this document and examine the string returned by the "getName()" method. It should be set to "staff". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1844763134 */ documenttypegetdoctype: function(test) { var success; var doc; var docType; var name; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); name = docType.name; test.equal(name, 'svg', 'doctypeName'); test.done(); }, /** * The "getEntities()" method is a NamedNodeMap that contains the general entities for this document. Retrieve the Document Type for this document and create a NamedNodeMap of all its entities. The entire map is traversed and the names of the entities are retrieved. There should be 5 entities. Duplicates should be ignored. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630 */ documenttypegetentities: function(test) { var success; var doc; var docType; var entityList; var name; expectedResult = new Array(); expectedResult[0] = "ent1"; expectedResult[1] = "ent2"; expectedResult[2] = "ent3"; expectedResult[3] = "ent4"; expectedResult[4] = "ent5"; expectedResultSVG = new Array(); expectedResultSVG[0] = "ent1"; expectedResultSVG[1] = "ent2"; expectedResultSVG[2] = "ent3"; expectedResultSVG[3] = "ent4"; expectedResultSVG[4] = "ent5"; expectedResultSVG[5] = "svgunit"; expectedResultSVG[6] = "svgtest"; var nameList = new Array(); var entity; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); entityList = docType.entities; test.notEqual(entityList, null, 'entitiesNotNull'); for(var indexN1007B = 0;indexN1007B < entityList.length; indexN1007B++) { entity = entityList.item(indexN1007B); name = entity.nodeName; nameList[nameList.length] = name; } test.deepEqual(nameList, expectedResultSVG, 'entityNamesSVG'); test.done(); }, /** * Duplicate entities are to be discarded. Retrieve the Document Type for this document and create a NamedNodeMap of all its entities. The entity named "ent1" is defined twice and therefore that last occurrance should be discarded. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630 */ documenttypegetentitieslength: function(test) { var success; var doc; var docType; var entityList; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); entityList = docType.entities; test.notEqual(entityList, null, 'entitiesNotNull'); test.equal(entityList.length, 7, 'entitySizeSVG'); test.done(); }, /** * Every node in the map returned by the "getEntities()" method implements the Entity interface. Retrieve the Document Type for this document and create a NamedNodeMap of all its entities. Traverse the entire list and examine the NodeType of each node in the list. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630 */ documenttypegetentitiestype: function(test) { var success; var doc; var docType; var entityList; var entity; var entityType; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); entityList = docType.entities; test.notEqual(entityList, null, 'entitiesNotNull'); for(var indexN10049 = 0;indexN10049 < entityList.length; indexN10049++) { entity = entityList.item(indexN10049); entityType = entity.nodeType; test.equal(entityType, 6, 'documenttypeGetEntitiesTypeAssert'); } test.done(); }, /** * The "getNotations()" method creates a NamedNodeMap that contains all the notations declared in the DTD. Retrieve the Document Type for this document and create a NamedNodeMap object of all the notations. There should be two items in the list (notation1 and notation2). * @author NIST * @author Mary Brady * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF */ documenttypegetnotations: function(test) { var success; var doc; var docType; var notationList; var notation; var notationName; var actual = new Array(); expected = new Array(); expected[0] = "notation1"; expected[1] = "notation2"; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); notationList = docType.notations; test.notEqual(notationList, null, 'notationsNotNull'); for(var indexN1005B = 0;indexN1005B < notationList.length; indexN1005B++) { notation = notationList.item(indexN1005B); notationName = notation.nodeName; actual[actual.length] = notationName; } test.deepEqual(actual, expected, 'names'); test.done(); }, /** * Every node in the map returned by the "getNotations()" method implements the Notation interface. Retrieve the Document Type for this document and create a NamedNodeMap object of all the notations. Traverse the entire list and examine the NodeType of each node. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF */ documenttypegetnotationstype: function(test) { var success; var doc; var docType; var notationList; var notation; var notationType; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); notationList = docType.notations; test.notEqual(notationList, null, 'notationsNotNull'); for(var indexN10049 = 0;indexN10049 < notationList.length; indexN10049++) { notation = notationList.item(indexN10049); notationType = notation.nodeType; test.equal(notationType, 12, 'documenttypeGetNotationsTypeAssert'); } test.done(); }, /** * hasFeature("XML", "") should return true for implementations that can read staff files. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14 */ domimplementationfeaturenoversion: function(test) { var success; var doc; var domImpl; var state; doc = staff.staff(); domImpl = doc.implementation; state = domImpl.hasFeature("XML",""); test.ok(state, 'hasXMLEmpty'); test.done(); }, /** * hasFeature("XML", null) should return true for implementations that can read staff documents. * @author NIST * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14 */ domimplementationfeaturenull: function(test) { var success; var doc; var domImpl; var state; var nullVersion = null; doc = staff.staff(); domImpl = doc.implementation; state = domImpl.hasFeature("XML",nullVersion); test.ok(state, 'hasXMLnull'); test.done(); }, /** * hasFeature("xml", "1.0") should return true for implementations that can read staff documents. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7 */ domimplementationfeaturexml: function(test) { var success; var doc; var domImpl; var state; doc = staff.staff(); domImpl = doc.implementation; state = domImpl.hasFeature("xml","1.0"); test.ok(state, 'hasXML1'); test.done(); }, /** * The "setAttribute(name,value)" method adds a new attribute to the Element Retrieve the last child of the last employee, then add an attribute to it by invoking the "setAttribute(name,value)" method. It should create a "name" attribute with an assigned value equal to "value". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 */ elementaddnewattribute: function(test) { var success; var doc; var elementList; var testEmployee; var attrValue; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(4); testEmployee.setAttribute("district","dallas"); attrValue = testEmployee.getAttribute("district"); test.equal(attrValue, 'dallas', 'elementAddNewAttributeAssert'); test.done(); }, /** * Elements may have attributes associated with them. Retrieve the first attribute from the last child of the first employee and invoke the "getSpecified()" method. This test is only intended to show that Elements can actually have attributes. This test uses the "getNamedItem(name)" method from the NamedNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 */ elementassociatedattribute: function(test) { var success; var doc; var elementList; var testEmployee; var attributes; var domesticAttr; var specified; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(0); attributes = testEmployee.attributes; domesticAttr = attributes.getNamedItem("domestic"); specified = domesticAttr.specified; test.ok(specified, 'domesticSpecified'); test.done(); }, /** * The "setAttribute(name,value)" method adds a new attribute to the Element. If the "name" is already present, then its value should be changed to the new one that is in the "value" parameter. Retrieve the last child of the fourth employee, then add an attribute to it by invoking the "setAttribute(name,value)" method. Since the name of the used attribute("street") is already present in this element, then its value should be changed to the new one of the "value" parameter. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 */ elementchangeattributevalue: function(test) { var success; var doc; var elementList; var testEmployee; var attrValue; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(3); testEmployee.setAttribute("street","Neither"); attrValue = testEmployee.getAttribute("street"); test.equal(attrValue, 'Neither', 'elementChangeAttributeValueAssert'); test.done(); }, /** * The "setAttributeNode(newAttr)" method adds a new attribute to the Element. Retrieve first address element and add a new attribute node to it by invoking its "setAttributeNode(newAttr)" method. This test makes use of the "createAttribute(name)" method from the Document interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 */ elementcreatenewattribute: function(test) { var success; var doc; var elementList; var testAddress; var newAttribute; var oldAttr; var districtAttr; var attrVal; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testAddress = elementList.item(0); newAttribute = doc.createAttribute("district"); oldAttr = testAddress.setAttributeNode(newAttribute); test.equal(oldAttr, null, 'old_attr_doesnt_exist'); districtAttr = testAddress.getAttributeNode("district"); test.notEqual(districtAttr, null, 'new_district_accessible'); attrVal = testAddress.getAttribute("district"); test.equal(attrVal, '', 'attr_value'); test.done(); }, /** * The "getAttributeNode(name)" method retrieves an attribute node by name. Retrieve the attribute "domestic" from the last child of the first employee. Since the method returns an Attr object, the "name" can be examined to ensure the proper attribute was retrieved. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8 */ elementgetattributenode: function(test) { var success; var doc; var elementList; var testEmployee; var domesticAttr; var name; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(0); domesticAttr = testEmployee.getAttributeNode("domestic"); name = domesticAttr.nodeName; test.equal(name, 'domestic', 'elementGetAttributeNodeAssert'); test.done(); }, /** * The "getAttributeNode(name)" method retrieves an attribute node by name. It should return null if the "name" attribute does not exist. Retrieve the last child of the first employee and attempt to retrieve a non-existing attribute. The method should return "null". The non-existing attribute to be used is "invalidAttribute". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8 */ elementgetattributenodenull: function(test) { var success; var doc; var elementList; var testEmployee; var domesticAttr; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(0); domesticAttr = testEmployee.getAttributeNode("invalidAttribute"); test.equal(domesticAttr, null, 'elementGetAttributeNodeNullAssert'); test.done(); }, /** * The "getAttribute(name)" method returns an empty string if no value was assigned to an attribute and no default value was given in the DTD file. Retrieve the last child of the last employee, then invoke "getAttribute(name)" method, where "name" is an attribute without a specified or DTD default value. The "getAttribute(name)" method should return the empty string. This method makes use of the "createAttribute(newAttr)" method from the Document interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9 */ elementgetelementempty: function(test) { var success; var doc; var newAttribute; var elementList; var testEmployee; var domesticAttr; var attrValue; doc = staff.staff(); newAttribute = doc.createAttribute("district"); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(3); domesticAttr = testEmployee.setAttributeNode(newAttribute); attrValue = testEmployee.getAttribute("district"); test.equal(attrValue, '', 'elementGetElementEmptyAssert'); test.done(); }, /** * The "getElementsByTagName(name)" method returns a list of all descendant Elements with the given tag name. Test for an empty list. Create a NodeList of all the descendant elements using the string "noMatch" as the tagName. The method should return a NodeList whose length is "0" since there are not any descendant elements that match the given tag name. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D */ elementgetelementsbytagname: function(test) { var success; var doc; var elementList; doc = staff.staff(); elementList = doc.getElementsByTagName("employee"); test.equal(elementList.length, 5, 'elementGetElementsByTagNameAssert'); test.done(); }, /** * Element.getElementsByTagName("employee") should return a NodeList whose length is "5" in the order the children were encountered. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D */ elementgetelementsbytagnameaccessnodelist: function(test) { var success; var doc; var elementList; var testEmployee; var child; var childName; var childValue; var childType; doc = staff.staff(); elementList = doc.getElementsByTagName("employee"); testEmployee = elementList.item(3); child = testEmployee.firstChild; childType = child.nodeType; if( (3 == childType) ) { child = child.nextSibling; } childName = child.nodeName; test.equal(childName, 'employeeId', 'nodename'); child = child.firstChild; childValue = child.nodeValue; test.equal(childValue, 'EMP0004', 'emp0004'); test.done(); }, /** * The "getElementsByTagName(name)" method returns a list of all descendant Elements with the given tag name. Create a NodeList of all the descendant elements using the string "employee" as the tagName. The method should return a NodeList whose length is "5". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D */ elementgetelementsbytagnamenomatch: function(test) { var success; var doc; var elementList; doc = staff.staff(); elementList = doc.getElementsByTagName("noMatch"); test.equal(elementList.length, 0, 'elementGetElementsByTagNameNoMatchNoMatchAssert'); test.done(); }, /** * The "getElementsByTagName(name)" method may use the special value "*" to match all tags in the element tree. Create a NodeList of all the descendant elements of the last employee by using the special value "*". The method should return all the descendant children(6) in the order the children were encountered. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D */ elementgetelementsbytagnamespecialvalue: function(test) { var success; var doc; var elementList; var lastEmployee; var lastempList; var child; var childName; var result = new Array(); expectedResult = new Array(); expectedResult[0] = "employeeId"; expectedResult[1] = "name"; expectedResult[2] = "position"; expectedResult[3] = "salary"; expectedResult[4] = "gender"; expectedResult[5] = "address"; doc = staff.staff(); elementList = doc.getElementsByTagName("employee"); lastEmployee = elementList.item(4); lastempList = lastEmployee.getElementsByTagName("*"); for(var indexN1006A = 0;indexN1006A < lastempList.length; indexN1006A++) { child = lastempList.item(indexN1006A); childName = child.nodeName; result[result.length] = childName; } test.deepEqual(result, expectedResult, 'tagNames'); test.done(); }, /** * The "getTagName()" method returns the tagName of an element. Invoke the "getTagName()" method one the root node. The value returned should be "staff". * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251 */ elementgettagname: function(test) { var success; var doc; var root; var tagname; doc = staff.staff(); root = doc.documentElement; tagname = root.tagName; test.equal(tagname, 'svg', 'svgTagName'); test.done(); }, /** * The "setAttributeNode(newAttr)" method raises an "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr" is already an attribute of another element. Retrieve the last child of the second employee and append a newly created element. The "createAttribute(name)" and "setAttributeNode(newAttr)" methods are invoked to create and add a new attribute to the newly created Element. The "setAttributeNode(newAttr)" method is once again called to add the new attribute causing an exception to be raised since the attribute is already an attribute of another element. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) */ elementinuseattributeerr: function(test) { var success; var doc; var newAttribute; var addressElementList; var testAddress; var newElement; var appendedChild; var setAttr1; var setAttr2; doc = staff.staff(); addressElementList = doc.getElementsByTagName("address"); testAddress = addressElementList.item(1); newElement = doc.createElement("newElement"); appendedChild = testAddress.appendChild(newElement); newAttribute = doc.createAttribute("newAttribute"); setAttr1 = newElement.setAttributeNode(newAttribute); { success = false; try { setAttr2 = testAddress.setAttributeNode(newAttribute); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 10); } test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR'); } test.done(); }, /** * The "setAttribute(name,value)" method raises an "INVALID_CHARACTER_ERR DOMException if the specified name contains an invalid character. Retrieve the last child of the first employee and call its "setAttribute(name,value)" method with "name" containing an invalid character. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR']) * @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#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ elementinvalidcharacterexception: function(test) { var success; var doc; var elementList; var testAddress; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testAddress = elementList.item(0); { success = false; try { testAddress.setAttribute("invalid'Name","value"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 5); } test.ok(success, 'throw_INVALID_CHARACTER_ERR'); } test.done(); }, /** * The "normalize()" method puts all the nodes in the full depth of the sub-tree underneath this element into a "normal" form. Retrieve the third employee and access its second child. This child contains a block of text that is spread across multiple lines. The content of the "name" child should be parsed and treated as a single Text node. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083 */ elementnormalize: function(test) { var success; var doc; var root; var elementList; var testName; var firstChild; var childValue; doc = staff.staff(); root = doc.documentElement; root.normalize(); elementList = root.getElementsByTagName("name"); testName = elementList.item(2); firstChild = testName.firstChild; childValue = firstChild.nodeValue; test.equal(childValue, 'Roger\n Jones', 'elementNormalizeAssert'); test.done(); }, /** * The "removeAttributeNode(oldAttr)" method raises a NOT_FOUND_ERR DOMException if the "oldAttr" attribute is not an attribute of the element. Retrieve the last employee and attempt to remove a non existing attribute node. This should cause the intended exception to be raised. This test makes use of the "createAttribute(name)" method from the Document interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D589198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ elementnotfounderr: function(test) { var success; var doc; var oldAttribute; var addressElementList; var testAddress; var attrAddress; doc = staff.staff(); addressElementList = doc.getElementsByTagName("address"); testAddress = addressElementList.item(4); oldAttribute = doc.createAttribute("oldAttribute"); { success = false; try { attrAddress = testAddress.removeAttributeNode(oldAttribute); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 8); } test.ok(success, 'throw_NOT_FOUND_ERR'); } test.done(); }, /** * The "removeAttribute(name)" removes an attribute by name. If the attribute has a default value, it is immediately replaced. Retrieve the attribute named "street" from the last child of the fourth employee, then remove the "street" attribute by invoking the "removeAttribute(name)" method. The "street" attribute has a default value defined in the DTD file, that value should immediately replace the old value. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html */ elementremoveattribute: function(test) { var success; var doc; var elementList; var testEmployee; var attrValue; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(3); testEmployee.removeAttribute("street"); attrValue = testEmployee.getAttribute("street"); test.equal(attrValue, 'Yes', 'streetYes'); test.done(); }, /** * The "removeAttributeNode(oldAttr)" method removes the specified attribute. Retrieve the last child of the third employee, add a new "district" node to it and then try to remove it. To verify that the node was removed use the "getNamedItem(name)" method from the NamedNodeMap interface. It also uses the "getAttributes()" method from the Node interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 */ elementremoveattributeaftercreate: function(test) { var success; var doc; var elementList; var testEmployee; var newAttribute; var attributes; var districtAttr; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(2); newAttribute = doc.createAttribute("district"); districtAttr = testEmployee.setAttributeNode(newAttribute); districtAttr = testEmployee.removeAttributeNode(newAttribute); attributes = testEmployee.attributes; districtAttr = attributes.getNamedItem("district"); test.equal(districtAttr, null, 'elementRemoveAttributeAfterCreateAssert'); test.done(); }, /** * The "removeAttributeNode(oldAttr)" method returns the node that was removed. Retrieve the last child of the third employee and remove its "street" Attr node. The method should return the old attribute node. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 */ elementremoveattributenode: function(test) { var success; var doc; var elementList; var testEmployee; var streetAttr; var removedAttr; var removedValue; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(2); streetAttr = testEmployee.getAttributeNode("street"); removedAttr = testEmployee.removeAttributeNode(streetAttr); removedValue = removedAttr.value; test.equal(removedValue, 'No', 'elementRemoveAttributeNodeAssert'); test.done(); }, /** * The "removeAttributeNode(oldAttr)" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Try to remove the "domestic" attribute from the entity reference by executing the "removeAttributeNode(oldAttr)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D589198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 */ elementremoveattributenodenomodificationallowederr: function(test) { var success; var doc; var genderList; var gender; var genList; var gen; var nodeType; var gList; var genElement; var attrList; var attrNode; var removedAttr; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); genList = gender.childNodes; gen = genList.item(0); test.notEqual(gen, null, 'genNotNull'); nodeType = gen.nodeType; if( (1 == nodeType) ) { gen = doc.createEntityReference("ent4"); test.notEqual(gen, null, 'createdEntRefNotNull'); } gList = gen.childNodes; genElement = gList.item(0); test.notEqual(genElement, null, 'genElementNotNull'); attrList = genElement.attributes; attrNode = attrList.getNamedItem("domestic"); { success = false; try { removedAttr = genElement.removeAttributeNode(attrNode); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "removeAttributeNode(oldAttr)" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Create an entity reference and add it to the children of the THIRD "gender" element. Try to remove the "domestic" attribute from the entity reference by executing the "removeAttributeNode(oldAttr)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D589198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenodenomodificationallowederr.xml */ elementremoveattributenodenomodificationallowederrEE: function(test) { var success; var doc; var genderList; var gender; var entRef; var entElement; var attrList; var attrNode; var nodeType; var removedAttr; var appendedChild; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = doc.createEntityReference("ent4"); test.notEqual(entRef, null, 'createdEntRefNotNull'); appendedChild = gender.appendChild(entRef); entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); attrList = entElement.attributes; attrNode = attrList.getNamedItem("domestic"); test.notEqual(attrNode, null, 'attrNodeNotNull'); { success = false; try { removedAttr = entElement.removeAttributeNode(attrNode); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "removeAttribute(name)" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Try to remove the "domestic" attribute from the entity reference by executing the "removeAttribute(name)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6D6AC0F9')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 */ elementremoveattributenomodificationallowederr: function(test) { var success; var doc; var genderList; var gender; var genList; var gen; var gList; var nodeType; var genElement; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); genList = gender.childNodes; gen = genList.item(0); test.notEqual(gen, null, 'genNotNull'); nodeType = gen.nodeType; if( (1 == nodeType) ) { gen = doc.createEntityReference("ent4"); test.notEqual(gen, null, 'createdEntRefNotNull'); } gList = gen.childNodes; genElement = gList.item(0); test.notEqual(genElement, null, 'genElementNotNull'); { success = false; try { genElement.removeAttribute("domestic"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "removeAttribute(name)" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Create an reference the entity ent4 and add it to the THIRD "gender" element. Try to remove the "domestic" attribute from the entity reference by executing the "removeAttribute(name)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6D6AC0F9')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9 * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenomodificationallowederr.xml */ elementremoveattributenomodificationallowederrEE: function(test) { var success; var doc; var genderList; var gender; var entRef; var entElement; var appendedChild; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = doc.createEntityReference("ent4"); test.notEqual(entRef, null, 'createdEntRefNotNull'); appendedChild = gender.appendChild(entRef); entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); { success = false; try { entElement.removeAttribute("domestic"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "removeAttributeNode(oldAttr)" method removes the specified attribute node and restores any default values. Retrieve the last child of the third employeed and remove its "street" Attr node. Since this node has a default value defined in the DTD file, that default should immediately be the new value. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198 * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html */ elementremoveattributerestoredefaultvalue: function(test) { var success; var doc; var elementList; var testEmployee; var streetAttr; var attribute; var removedAttr; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(2); streetAttr = testEmployee.getAttributeNode("street"); removedAttr = testEmployee.removeAttributeNode(streetAttr); attribute = testEmployee.getAttribute("street"); test.equal(attribute, 'Yes', 'streetYes'); test.done(); }, /** * This test calls setAttributeNode to replace an attribute with itself. Since the node is not an attribute of another Element, it would be inappropriate to throw an INUSE_ATTRIBUTE_ERR. This test was derived from elementinuserattributeerr which inadvertanly made this test. * @author Curt Arnold * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 */ elementreplaceattributewithself: function(test) { var success; var doc; var elementList; var testEmployee; var streetAttr; var replacedAttr; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(2); streetAttr = testEmployee.getAttributeNode("street"); replacedAttr = testEmployee.setAttributeNode(streetAttr); test.equal(replacedAttr, streetAttr, 'replacedAttr'); test.done(); }, /** * The "setAttributeNode(newAttr)" method adds a new attribute to the Element. If the "newAttr" Attr node is already present in this element, it should replace the existing one. Retrieve the last child of the third employee and add a new attribute node by invoking the "setAttributeNode(new Attr)" method. The new attribute node to be added is "street", which is already present in this element. The method should replace the existing Attr node with the new one. This test uses the "createAttribute(name)" method from the Document interface. * @author NIST * @author Mary Brady */ elementreplaceexistingattribute: function(test) { var success; var doc; var elementList; var testEmployee; var newAttribute; var name; var setAttr; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(2); newAttribute = doc.createAttribute("street"); setAttr = testEmployee.setAttributeNode(newAttribute); name = testEmployee.getAttribute("street"); test.equal(name, '', 'elementReplaceExistingAttributeAssert'); test.done(); }, /** * If the "setAttributeNode(newAttr)" method replaces an existing Attr node with the same name, then it should return the previously existing Attr node. Retrieve the last child of the third employee and add a new attribute node. The new attribute node is "street", which is already present in this Element. The method should return the existing Attr node(old "street" Attr). This test uses the "createAttribute(name)" method from the Document interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 */ elementreplaceexistingattributegevalue: function(test) { var success; var doc; var elementList; var testEmployee; var newAttribute; var streetAttr; var value; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(2); newAttribute = doc.createAttribute("street"); streetAttr = testEmployee.setAttributeNode(newAttribute); value = streetAttr.value; test.equal(value, 'No', 'streetNo'); test.done(); }, /** * The "getAttributes()" method(Node Interface) may be used to retrieve the set of all attributes of an element. Create a list of all the attributes of the last child of the first employee by using the "getAttributes()" method. Examine the length of the attribute list. This test uses the "getLength()" method from the NameNodeMap interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096 * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html */ elementretrieveallattributes: function(test) { var success; var doc; var addressList; var testAddress; var attributes; doc = staff.staff(); addressList = doc.getElementsByTagName("address"); testAddress = addressList.item(0); attributes = testAddress.attributes; test.equal(attributes.length, 2, 'elementRetrieveAllAttributesAssert'); test.done(); }, /** * The "getAttribute(name)" method returns an attribute value by name. Retrieve the second address element, then invoke the 'getAttribute("street")' method. This should return the value of the attribute("No"). * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9 */ elementretrieveattrvalue: function(test) { var success; var doc; var elementList; var testAddress; var attrValue; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testAddress = elementList.item(2); attrValue = testAddress.getAttribute("street"); test.equal(attrValue, 'No', 'attrValue'); test.done(); }, /** * The "getElementsByTagName()" method returns a NodeList of all descendant elements with a given tagName. Invoke the "getElementsByTagName()" method and create a NodeList of "position" elements. Retrieve the second "position" element in the list and return the NodeName. * @author NIST * @author Mary Brady * @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-104682815 */ elementretrievetagname: function(test) { var success; var doc; var elementList; var testEmployee; var name; doc = staff.staff(); elementList = doc.getElementsByTagName("position"); testEmployee = elementList.item(1); name = testEmployee.nodeName; test.equal(name, 'position', 'nodename'); name = testEmployee.tagName; test.equal(name, 'position', 'tagname'); test.done(); }, /** * The "setAttributeNode(newAttr)" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Try to remove the "domestic" attribute from the entity reference by executing the "setAttributeNode(newAttr)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 */ elementsetattributenodenomodificationallowederr: function(test) { var success; var doc; var genderList; var gender; var entRef; var entElement; var newAttr; var nodeType; var badAttr; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = gender.firstChild; test.notEqual(entRef, null, 'entRefNotNull'); nodeType = entRef.nodeType; if( (1 == nodeType) ) { entRef = doc.createEntityReference("ent4"); test.notEqual(entRef, null, 'createdEntRefNotNull'); } entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); newAttr = doc.createAttribute("newAttr"); { success = false; try { badAttr = entElement.setAttributeNode(newAttr); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "setAttributeNode(newAttr)" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Create an entity reference and add to the THIRD "gender" element. The elements content is an entity reference. Try to remove the "domestic" attribute from the entity reference by executing the "setAttributeNode(newAttr)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenodenomodificationallowederr.xml */ elementsetattributenodenomodificationallowederrEE: function(test) { var success; var doc; var genderList; var gender; var entRef; var entElement; var newAttr; var badAttr; var appendedChild; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = doc.createEntityReference("ent4"); test.notEqual(entRef, null, 'createdEntRefNotNull'); appendedChild = gender.appendChild(entRef); entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); newAttr = doc.createAttribute("newAttr"); { success = false; try { badAttr = entElement.setAttributeNode(newAttr); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "setAttributeNode(newAttr)" method returns the null value if no previously existing Attr node with the same name was replaced. Retrieve the last child of the third employee and add a new attribute to it. The new attribute node added is "district", which is not part of this Element. The method should return the null value. This test uses the "createAttribute(name)" method from the Document interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 */ elementsetattributenodenull: function(test) { var success; var doc; var elementList; var testEmployee; var newAttribute; var districtAttr; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); testEmployee = elementList.item(2); newAttribute = doc.createAttribute("district"); districtAttr = testEmployee.setAttributeNode(newAttribute); test.equal(districtAttr, null, 'elementSetAttributeNodeNullAssert'); test.done(); }, /** * The "setAttribute(name,value)" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Try to remove the "domestic" attribute from the entity reference by executing the "setAttribute(name,value)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @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#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 */ elementsetattributenomodificationallowederr: function(test) { var success; var doc; var genderList; var gender; var entRef; var entElement; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = gender.firstChild; test.notEqual(entRef, null, 'entRefNotNull'); entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); { success = false; try { entElement.setAttribute("newAttr","newValue"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "setAttribute(name,value)" method for an attribute causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Add an ent4 reference to the children of the THIRD "gender" element. Try to remove the "domestic" attribute from the entity reference by executing the "setAttribute(name,value)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @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#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082 * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenomodificationallowederr.xml */ elementsetattributenomodificationallowederrEE: function(test) { var success; var doc; var genderList; var gender; var entRef; var entElement; var appendedChild; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = doc.createEntityReference("ent4"); appendedChild = gender.appendChild(entRef); entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); { success = false; try { entElement.setAttribute("newAttr","newValue"); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "setAttributeNode(newAttr)" method raises an "WRONG_DOCUMENT_ERR DOMException if the "newAttr" was created from a different document than the one that created this document. Retrieve the last employee and attempt to set a new attribute node for its "employee" element. The new attribute was created from a document other than the one that created this element, therefore a WRONG_DOCUMENT_ERR DOMException should be raised. This test uses the "createAttribute(newAttr)" method from the Document interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ elementwrongdocumenterr: function(test) { var success; var doc1; var doc2; var newAttribute; var addressElementList; var testAddress; var attrAddress; var doc1Ref = null; if (typeof(this.doc1) != 'undefined') { doc1Ref = this.doc1; } doc1 = staff.staff(); var doc2Ref = null; if (typeof(this.doc2) != 'undefined') { doc2Ref = this.doc2; } doc2 = staff.staff(); newAttribute = doc2.createAttribute("newAttribute"); addressElementList = doc1.getElementsByTagName("address"); testAddress = addressElementList.item(4); { success = false; try { attrAddress = testAddress.setAttributeNode(newAttribute); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 4); } test.ok(success, 'throw_WRONG_DOCUMENT_ERR'); } test.done(); }, /** * The nodeName attribute that is inherited from Node contains the name of the entity. Retrieve the entity named "ent1" and access its name by invoking the "getNodeName()" method inherited from the Node interface. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095 */ entitygetentityname: function(test) { var success; var doc; var docType; var entityList; var entityNode; var entityName; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); entityList = docType.entities; test.notEqual(entityList, null, 'entitiesNotNull'); entityNode = entityList.getNamedItem("ent1"); entityName = entityNode.nodeName; test.equal(entityName, 'ent1', 'entityGetEntityNameAssert'); test.done(); }, /** * The "getPublicId()" method of an Entity node contains the public identifier associated with the entity, if one was specified. Retrieve the entity named "ent5" and access its public identifier. The string "entityURI" should be returned. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7303025 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6ABAEB38 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7C29F3E */ entitygetpublicid: function(test) { var doc = staff.staff(); test.notEqual(doc.doctype, null, 'docTypeNotNull'); test.notEqual(doc.doctype.entities, null, 'entitiesNotNull'); var entityNode = doc.doctype.entities.getNamedItem("ent5"); test.equal(entityNode.publicId, 'entityURI', 'publicId'); test.equal(entityNode.systemId, 'entityFile'); test.equal(entityNode.notationName, 'notation1', 'notation'); test.done(); }, /** * The "getPublicId()" method of an Entity node contains the public identifier associated with the entity, if one was not specified a null value should be returned. Retrieve the entity named "ent1" and access its public identifier. Since a public identifier was not specified for this entity, the "getPublicId()" method should return null. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7303025 */ entitygetpublicidnull: function(test) { var success; var doc; var docType; var entityList; var entityNode; var publicId; doc = staff.staff(); docType = doc.doctype; test.notEqual(docType, null, 'docTypeNotNull'); entityList = docType.entities; test.notEqual(entityList, null, 'entitiesNotNull'); entityNode = entityList.getNamedItem("ent1"); publicId = entityNode.publicId; test.equal(publicId, null, 'entityGetPublicIdNullAssert'); 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 success; var doc; var acronymList; var testNode; var attributes; var titleAttr; var value; var newChild; var retval; var lastChild; doc = hc_staff.hc_staff(); acronymList = doc.getElementsByTagName("acronym"); testNode = acronymList.item(3); attributes = testNode.attributes; titleAttr = attributes.getNamedItem("title"); newChild = doc.createElement("terday"); { success = false; try { retval = 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 CDATASection to an attribute which should result in a HIERARCHY_REQUEST_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_attrappendchild4: 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.createCDATASection("terday"); success = false; try { retval = titleAttr.appendChild(textNode); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 3); } test.ok(success, 'throw_HIERARCHY_REQUEST_ERR'); 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 success; var doc; var acronymList; var testNode; var attributes; var titleAttr; var value; var textNode; var retval; var lastChild; var otherDoc; doc = hc_staff.hc_staff(); var otherDocRef = null; if (typeof(this.otherDoc) != 'undefined') { otherDocRef = this.otherDoc; } otherDoc = hc_staff.hc_staff(); acronymList = doc.getElementsByTagName("acronym"); testNode = acronymList.item(3); attributes = testNode.attributes; titleAttr = attributes.getNamedItem("title"); textNode = otherDoc.createTextNode("terday"); { success = false; try { retval = 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 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; var count = 0 for(var i=0;i length (19 > 15). * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF */ hc_characterdatasubstringexceedsvalue: function(test) { var success; var doc; var elementList; var nameNode; var child; var substring; doc = hc_staff.hc_staff(); elementList = doc.getElementsByTagName("strong"); nameNode = elementList.item(0); child = nameNode.firstChild; substring = child.substringData(9,10); test.equal(substring, 'Martin', 'characterdataSubStringExceedsValueAssert'); test.done(); }, /** * The "substringData(offset,count)" method returns the specified string. Retrieve the character data from the second child of the first employee and access part of the data by using the substringData(offset,count) method. The method should return the specified substring starting at position "offset" and extract "count" characters. The method should return the string "Margaret". * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF */ hc_characterdatasubstringvalue: function(test) { var success; var doc; var elementList; var nameNode; var child; var substring; doc = hc_staff.hc_staff(); elementList = doc.getElementsByTagName("strong"); nameNode = elementList.item(0); child = nameNode.firstChild; substring = child.substringData(0,8); test.equal(substring, 'Margaret', 'characterdataSubStringValueAssert'); test.done(); }, /** * A comment is all the characters between the starting '' Retrieve the nodes of the DOM document. Search for a comment node and the content is its value. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328 * @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-F68D080 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558 * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=509 */ hc_commentgetcomment: function(test) { var doc = hc_staff.hc_staff(); var elementList = doc.childNodes; test.expect(3); // the three tests in the for loop should run only once for(var i=0;i". Retrieve the ProcessingInstruction node located immediately after the prolog. Create a nodelist of the child nodes of this document. Invoke the "getData()" method on the first child in the list. This should return the content of the ProcessingInstruction. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 */ processinginstructiongetdata: function(test) { var success; var doc; var childNodes; var piNode; var data; doc = staff.staff(); childNodes = doc.childNodes; piNode = childNodes.item(0); data = piNode.data; test.equal(data, 'PIDATA', 'processinginstructionGetTargetAssert'); test.done(); }, /** * The "getTarget()" method returns the target of the processing instruction. It is the first token following the markup that begins the processing instruction. Retrieve the ProcessingInstruction node located immediately after the prolog. Create a nodelist of the child nodes of this document. Invoke the "getTarget()" method on the first child in the list. This should return the target of the ProcessingInstruction. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1478689192 */ processinginstructiongettarget: function(test) { var success; var doc; var childNodes; var piNode; var target; doc = staff.staff(); childNodes = doc.childNodes; piNode = childNodes.item(0); target = piNode.target; test.equal(target, 'TEST-STYLE', 'processinginstructionGetTargetAssert'); test.done(); }, /** * The "setData(data)" method for a processing instruction causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Try to remove the "domestic" attribute from the entity reference by executing the "setData(data)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-837822393')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 */ processinginstructionsetdatanomodificationallowederr: function(test) { var success; var doc; var genderList; var gender; var entRef; var piNode; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = gender.firstChild; test.notEqual(entRef, null, 'entRefNotNull'); piNode = entRef.lastChild; test.notEqual(piNode, null, 'piNodeNotNull'); { success = false; try { piNode.data = "newData"; } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "setData(data)" method for a processing instruction causes the DOMException NO_MODIFICATION_ALLOWED_ERR to be raised if the node is readonly. Create an ent4 entity reference and add to document of the THIRD "gender" element. The elements content is an entity reference. Try to remove the "domestic" attribute from the entity reference by executing the "setData(data)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-837822393')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393 * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0053.html * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructionsetdatanomodificationallowederr.xml */ processinginstructionsetdatanomodificationallowederrEE: function(test) { var success; var doc; var genderList; var gender; var entRef; var piNode; var appendedChild; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = doc.createEntityReference("ent4"); appendedChild = gender.appendChild(entRef); entRef = gender.lastChild; test.notEqual(entRef, null, 'entRefNotNull'); piNode = entRef.lastChild; test.notEqual(piNode, null, 'piNodeNotNull'); { success = false; try { piNode.data = "newData"; } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * The "splitText(offset)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is negative. Retrieve the textual data from the second child of the third employee and invoke the "splitText(offset)" method. The desired exception should be raised since the offset is a negative number. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) */ textindexsizeerrnegativeoffset: function(test) { var success; var doc; var elementList; var nameNode; var textNode; var splitNode; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(2); textNode = nameNode.firstChild; { success = false; try { splitNode = textNode.splitText(-69); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throws_INDEX_SIZE_ERR'); } test.done(); }, /** * The "splitText(offset)" method raises an INDEX_SIZE_ERR DOMException if the specified offset is greater than the number of characters in the Text node. Retrieve the textual data from the second child of the third employee and invoke the "splitText(offset)" method. The desired exception should be raised since the offset is a greater than the number of characters in the Text node. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR']) * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249 */ textindexsizeerroffsetoutofbounds: function(test) { var success; var doc; var elementList; var nameNode; var textNode; var splitNode; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(2); textNode = nameNode.firstChild; { success = false; try { splitNode = textNode.splitText(300); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 1); } test.ok(success, 'throw_INDEX_SIZE_ERR'); } test.done(); }, /** * Retrieve the textual data from the last child of the second employee. That node is composed of two EntityReference nodes and two Text nodes. After the content node is parsed, the "address" Element should contain four children with each one of the EntityReferences containing one child. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614 */ textparseintolistofelements: function(test) { var success; var doc; var elementList; var addressNode; var childList; var child; var length; var value; var grandChild; var result = new Array(); expectedNormal = new Array(); expectedNormal[0] = "1900 Dallas Road"; expectedNormal[1] = " Dallas, "; expectedNormal[2] = "Texas"; expectedNormal[3] = "\n 98554"; expectedExpanded = new Array(); expectedExpanded[0] = "1900 Dallas Road Dallas, Texas\n 98554"; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); addressNode = elementList.item(1); childList = addressNode.childNodes; length = childList.length; for(var indexN1007F = 0;indexN1007F < childList.length; indexN1007F++) { child = childList.item(indexN1007F); value = child.nodeValue; if( (value == null) ) { grandChild = child.firstChild; test.notEqual(grandChild, null, 'grandChildNotNull'); value = grandChild.nodeValue; result[result.length] = value; } else { result[result.length] = value; } } if( (4 == length) ) { test.deepEqual(result, expectedNormal, 'assertEqNormal'); } else { test.deepEqual(result, expectedExpanded, 'assertEqCoalescing'); } test.done(); }, /** * The "splitText(offset)" method returns the new Text node. Retrieve the textual data from the last child of the first employee and invoke the "splitText(offset)" method. The method should return the new Text node. The offset value used for this test is 30. The "getNodeValue()" method is called to check that the new node now contains the characters at and after position 30. (Starting count at 0) * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D */ textsplittextfour: function(test) { var success; var doc; var elementList; var addressNode; var textNode; var splitNode; var value; doc = staff.staff(); elementList = doc.getElementsByTagName("address"); addressNode = elementList.item(0); textNode = addressNode.firstChild; splitNode = textNode.splitText(30); value = splitNode.nodeValue; test.equal(value, '98551', 'textSplitTextFourAssert'); test.done(); }, /** * The "splitText(offset)" method raises a NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly. Obtain the children of the THIRD "gender" element. The elements content is an entity reference. Get the element content of the FIRST Text Node of the entity reference and execute the "splitText(offset)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D */ textsplittextnomodificationallowederr: function(test) { var success; var doc; var genderList; var gender; var entRef; var entElement; var entElementText; var splitNode; var nodeType; doc = staff.staff(); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = gender.firstChild; test.notEqual(entRef, null, 'entRefNotNull'); nodeType = entRef.nodeType; if( (1 == nodeType) ) { entRef = doc.createEntityReference("ent4"); test.notEqual(entRef, null, 'createdEntRefNotNull'); } entElement = entRef.firstChild; test.notEqual(entElement, null, 'entElementNotNull'); entElementText = entElement.firstChild; test.notEqual(entElementText, null, 'entElementTextNotNull'); { success = false; try { splitNode = entElementText.splitText(2); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); } test.done(); }, /** * Create an ent3 reference and execute the "splitText(offset)" method. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. * @author Curt Arnold * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR']) * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextnomodificationallowederr.xml */ textsplittextnomodificationallowederrEE: function(test) { var success; var doc; var entRef; var entText; var splitNode; doc = staff.staff(); entRef = doc.createEntityReference("ent3"); test.notEqual(entRef, null, 'createdEntRefNotNull'); entText = entRef.firstChild; test.notEqual(entText, null, 'entTextNotNull'); success = false; try { splitNode = entText.splitText(2); } catch(ex) { success = (typeof(ex.code) != 'undefined' && ex.code == 7); } test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR'); test.done(); }, /** * The "splitText(offset)" method breaks the Text node into two Text nodes at the specified offset keeping each node as siblings in the tree. Retrieve the textual data from the second child of the third employee and invoke the "splitText(offset)" method. The method splits the Text node into two new sibling Text nodes keeping both of them in the tree. This test checks the "nextSibling()" method of the original node to ensure that the two nodes are indeed siblings. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D */ textsplittextone: function(test) { var success; var doc; var elementList; var nameNode; var textNode; var splitNode; var secondPart; var value; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(2); textNode = nameNode.firstChild; splitNode = textNode.splitText(7); secondPart = textNode.nextSibling; value = secondPart.nodeValue; test.equal(value, 'Jones', 'textSplitTextOneAssert'); test.done(); }, /** * After the "splitText(offset)" method breaks the Text node into two Text nodes, the new Text node contains all the content at and after the offset point. Retrieve the textual data from the second child of the third employee and invoke the "splitText(offset)" method. The new Text node should contain all the content at and after the offset point. The "getNodeValue()" method is called to check that the new node now contains the characters at and after position seven. (Starting count at 0) * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D */ textsplittextthree: function(test) { var success; var doc; var elementList; var nameNode; var textNode; var splitNode; var value; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(2); textNode = nameNode.firstChild; splitNode = textNode.splitText(6); value = splitNode.nodeValue; test.equal(value, ' Jones', 'textSplitTextThreeAssert'); test.done(); }, /** * After the "splitText(offset)" method breaks the Text node into two Text nodes, the original node contains all the content up to the offset point. Retrieve the textual data from the second child of the third employee and invoke the "splitText(offset)" method. The original Text node should contain all the content up to the offset point. The "getNodeValue()" method is called to check that the original node now contains the first five characters. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D */ textsplittexttwo: function(test) { var success; var doc; var elementList; var nameNode; var textNode; var splitNode; var value; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(2); textNode = nameNode.firstChild; splitNode = textNode.splitText(5); value = textNode.nodeValue; test.equal(value, 'Roger', 'textSplitTextTwoAssert'); test.done(); }, /** * If there is not any markup inside an Element or Attr node content, then the text is contained in a single object implementing the Text interface that is the only child of the element. Retrieve the textual data from the second child of the third employee. That Text node contains a block of multiple text lines without markup, so they should be treated as a single Text node. The "getNodeValue()" method should contain the combination of the two lines. * @author NIST * @author Mary Brady * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080 */ textwithnomarkup: function(test) { var success; var doc; var elementList; var nameNode; var nodeV; var value; doc = staff.staff(); elementList = doc.getElementsByTagName("name"); nameNode = elementList.item(2); nodeV = nameNode.firstChild; value = nodeV.nodeValue; test.equal(value, 'Roger\n Jones', 'textNodeValue'); test.done(); } };