//************************************************************************** // // // National Institute Of Standards and Technology // DTS Version 1.0 // // Attr Interface //************************************************************************** var i = 1; function Attr() { var tests = new Array (core0001A(), core0002A(), core0003A(),core0004A(), core0005A(), core0006A(), core0007A(), core0008A(), core0009A(), core0010A(), core0011A(), core0012A(), core0013A(), core0014A()); return tests; } //------------------------ test case core-0001A ------------------------ // // Testing feature - The parentNode attribute for an Attr object should // be null. // // Testing approach - Retrieve the attribute named "domestic" from the last // child of of the first employee and examine its // parentNode attribute. This test uses the // "getNamedItem(name)" method from the NamedNodeMap // interface. // // Semantic Requirements: 1 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0001A() { var computedValue = 0; var expectedValue = null; var testNode = ""; var domesticAttr = ""; results = new testResults("Core0001A"); results.description = "The ParentNode attribute should be null for" + " an Attr object."; // // Retrieve targeted data and examine parentNode attribute. // testNode = new nodeObject(FIRST,SIXTH); domesticAttr = testNode.attributes.getNamedItem("domestic"); computedValue = domesticAttr.parentNode; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0001A -------------------------- // //------------------------- test case core-0002A ---------------------------- // // // Written By: Carmelo Montanez // // Testing feature - The previousSibling attribute for an Attr object // should be null. // // Testing approach - Retrieve the attribute named "domestic" from the last // child of of the first employee and examine its // previousSibling attribute. This test uses the // "getNamedItem(name)" method from the NamedNodeMap // interface. // // Semantic Requirements: 1 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0002A() { var computedValue = ""; var expectedValue = null; var domesticAttr = ""; var testNode = ""; results = new testResults("Core0002A"); results.description = "The previousSibling attribute should be " + "null for an Attr object."; // // Retrieve the targeted data and examine its previousSibling attribute. // testNode = new nodeObject(FIRST,SIXTH); domesticAttr = testNode.attributes.getNamedItem("domestic"); computedValue = domesticAttr.previousSibling; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0002A -------------------------- // //------------------------- test case core-0003A ---------------------------- // Written By: Carmelo Montanez // // Testing feature - The nextSibling attribute for an Attr object should // be null. // // Testing approach - Retrieve the attribute named "domestic" from the // last child of of the first employee and examine // its nextSibling attribute. This test uses the // "getNamedItem(name)" method from the NamedNodeMap // interface. // // Semantic Requirements: 1 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0003A() { var computedValue = ""; var expectedValue = null; var domesticAttr = ""; var testNode = ""; results = new testResults("Core0003A"); results.description = "The nextSibling attribute should be null " + "for an Attr object."; // // Retrieve the targeted data and examine its nextSibling attribute. // testNode = new nodeObject(FIRST,SIXTH); domesticAttr = testNode.attributes.getNamedItem("domestic"); computedValue = domesticAttr.nextSibling; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0003A -------------------------- // //------------------------- test case core-0004A ---------------------------- // // Written By: Carmelo Montanez // // Testing feature - Attr objects may be associated with Element nodes // contained within a DocumentFragment. // // Testing approach - Create a new DocumentFragment object and add a newly // created Element node to it (with one attribute). Once // the element is added, its attribute should be available // as an attribute associated with an Element within a // DocumentFragment. // // Semantic Requirements: 2 // // Last modification date - April 8, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0004A() { var computedValue = ""; var expectedValue = "domestic"; var domesticAttr = ""; results = new testResults("Core0004A"); results.description = "Attr objects may be associated with Element " + "nodes contained within a DocumentFragment."; var docFragment = getDOMDocument().createDocumentFragment(); var newElement = createNode(ELEMENT_NODE,"element1"); // // The new DocumentFragment is empty upon creation. Set an attribute for // a newly created element and add the element to the documentFragment. // newElement.setAttribute("domestic","Yes"); docFragment.appendChild(newElement); // // Access the attributes of the only child of the documentFragment // domesticAttr = docFragment.firstChild.attributes(0) computedValue = domesticAttr.name; // // Write out results // results.expected = expectedValue; results.actual = computedValue; resetData(); return results; } //------------------------ End test case core-0004A -------------------------- // //-------------------------- test case core-0005A ---------------------------- // // Testing feature - If an Attr is explicitly assigned any value, then that // value is the attribute's effective value. // // Testing approach - Retrieve the attribute name "domestic" from the last // child of of the first employee element and examine its // assigned value. This test uses the // "getNamedItem(name)" method from the NamedNodeMap // interface. // // Semantic Requirements: 3 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0005A() { var computedValue = ""; var expectedValue = "Yes"; var domesticAttr = ""; var testNode = ""; results = new testResults("Core0005A"); results.description = "If an attribute is explicitly assigned any value, " + "then that value is the attribute's effective value."; // // Retrieve the targeted data and examine its assigned value. // testNode = new nodeObject(FIRST,SIXTH); domesticAttr = testNode.attributes.getNamedItem("domestic"); computedValue = domesticAttr.value; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0005A -------------------------- // //-------------------------- test case core-0006A ---------------------------- // // Testing feature - If there is no 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 Attribute's default value. // // Testing approach - 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 during // the declaration of the attribute in the DTD file. // This test uses the "getNamedItem(name)" method from // the NamedNodeMap interface. // // Semantic Requirements: 4 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0006A() { var computedValue = ""; var expectedValue = "Yes"; var streetAttr = ""; var testNode = ""; results = new testResults("Core0006A"); results.description = "If there is no 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 Attribute's " + "default value."; // // Retrieve the targeted data and examine its default value. // testNode = new nodeObject(FIRST,SIXTH); streetAttr = testNode.attributes.getNamedItem("street"); computedValue = streetAttr.value; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0006A -------------------------- // //-------------------------- test case core-0007A --------------------------- // // Testing feature - The "name" Attribute of an Attribute node. // // Testing approach - Retrieve the attribute named "street" from the // last child of the second employee and examine its "name" // attribute. This test uses the "getNamedItem(name)" // method from the NamedNodeMap interface. // // Semantic Requirements: 5 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0007A() { var computedValue = ""; var expectedValue = "street"; var streetAttr = ""; var testNode = ""; results = new testResults("Core0007A"); results.description = "The \"name\" attribute of an Attr object contains " + "the name of that attribute."; // // Retrieve the targeted data and capture its assigned name. // testNode = new nodeObject(SECOND,SIXTH); streetAttr = testNode.attributes.getNamedItem("street"); computedValue = streetAttr.name; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0007A -------------------------- // //-------------------------- test case core-0008A --------------------------- // // Testing feature - The "specified" attribute of an Attr node should be set // to true if the attribute was explicitly given a value. // // Testing approach - Retrieve the attribute named "doestic" from the last // child of the first employee and examine its "specified" // attribute. It should be set to true. This test // uses the "getNamedItem(name)" method from the // NamedNodeMap interface. // // Semantic Requirements: 6 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0008A() { var computedValue = 0; var expectedValue = true; var testNode = ""; var domesticAttr = ""; results = new testResults("Core0008A"); results.description = "The \"specified\" attribute for an Attr object " + "should be set to true if the attribute was " + "explictly given a value."; // // Retrieve the targeted data and capture its "specified" value. // testNode = new nodeObject(FIRST,SIXTH); domesticAttr = testNode.attributes.getNamedItem("domestic");; computedValue = domesticAttr.specified; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0008A -------------------------- // //-------------------------- test case core-0009A --------------------------- // // Testing feature - The "specified" attribute for an Attr node should be // set to false if the attribute was not explicitly given // a value. // // Testing approach - Retrieve the attribute named "street"(not explicity // given a value) from the last child of the first employee // and examine its "specified" attribute. It should be // set to false. This test uses the // "getNamedItem(name)" method from the NamedNodeMap // interface. // // Semantic Requirements: 6 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0009A() { var computedValue = 0; var expectedValue = false; var streetAttr = ""; var testNode = ""; results = new testResults("Core0009A"); results.description = "The \"specified\" attribute for an Attr node " + "should be set to false if the attribute was " + "not explictly given a value."; // // Retrieve the targeted data and capture its "specified" attribute. // testNode = new nodeObject(FIRST,SIXTH); streetAttr = testNode.attributes.getNamedItem("street"); computedValue = streetAttr.specified; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0009A -------------------------- // //-------------------------- test case core-0010A --------------------------- // // Testing feature - The "specified" attribute for an Attr node should be // automatically flipped to true if value of the attribute // is changed (even its ends up having a default DTD value) // // Testing approach - Retrieve the attribute named "street" from the last // child of the third employee and change its value to "Yes" // (which is its default DTD value). This should cause the // "specified" attribute to be flipped to true. This test // makes use of the "setAttribute(name,value )" method from // the Element interface and the "getNamedItem(name)" // method from the NamedNodeMap interface. // // Semantic Requirements: 7 // // Last modification date - February 19, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0010A() { var computedValue = ""; var expectedValue = true; var streetAttr = ""; var testNode = ""; results = new testResults("Core0010A"); results.description = "The \"specified\" attribute for an Attr node " + "should be flipped to true if the attribute value " + "is changed (even it changed to its default value)."; // // Retrieve the targeted data and set a new attribute for it, then // capture its "specified" attribute. // testNode = new nodeObject(THIRD,FIFTH); testNode.node.setAttribute("street","Yes"); streetAttr = testNode.attributes.getNamedItem("street"); computedValue = streetAttr.specified; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0010A -------------------------- // //-------------------------- test case core-0011A --------------------------- // // Testing feature - To respecify the attribute to its default value from the // DTD, the attribute must be deleted. The implementation // will then make a new attribute available with the // "specified" attribute set to false. // Testing approach - Retrieve the attribute named "street" from the last // child of the third employee and delete it. The // implementation hould then create a new attribute with // its default value and "specified" set to false. This // test uses the "removeAttribute(name)" from the Element // interface and the "getNamedItem(name)" method from the // NamedNodeMap interface. // // Semantic Requirements: 8 // // Last modification date - February 20, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0011A() { var computedValue = ""; var expectedValue = false; var streetAttr = ""; var testNode = ""; results = new testResults("Core0011A"); results.description = "Re-setting an attribute to its default value " + "requires that the attribute be deleted. The " + "implementation should create a new attribute " + "with its \"specified\" attribute set to false."; // // Retrieve the targeted data, remove the "street" attribute and capture // its specified attribute. // testNode = new nodeObject(THIRD,SIXTH); testNode.node.removeAttribute("street"); streetAttr = testNode.attributes.getNamedItem("street"); computedValue = streetAttr.specified; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0011A -------------------------- // //-------------------------- test case core-0012A --------------------------- // // Testing feature - Upon retrieval, the "value" of an attribute is returned // as a string with characters and general entity references // replaced with their values. // Testing approach - Retrieve the attribute named "street" from the last // child of the fourth employee and examine its value // attribute. This value should be "Yes" after the // EntityReference is replaced with its value. This // test uses the "getNamedItem(name)" method from // the NamedNodeMap interface. // // Semantic Requirements: 9 // // Last modification date - February 20, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0012A() { var computedValue = ""; var expectedValue = "Yes"; var streetAttr = ""; var testNode = ""; results = new testResults("Core0012A"); results.description = "Upon retrieval the \"value\" attribute of an Attr" + "object is returned as a string with any Entity " + "References replaced with their values."; // // Retrieve the targeted data. // testNode = new nodeObject(FOURTH,SIXTH); streetAttr = testNode.attributes.getNamedItem("street"); computedValue = streetAttr.value; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0012A -------------------------- // //-------------------------- test case core-0013A --------------------------- // // Testing feature - On setting, the "value" attribute of an Attr node // creates a Text node with the unparsed content of // the string. // Testing approach - Retrieve the attribute named "street" from the last // child 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. // // Semantic Requirements: 10 // // Last modification date - February 20, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0013A() { var computedValue = ""; var expectedValue = "Y%ent1;"; var streetAttr = ""; var testNode = ""; results = new testResults("Core0013A"); results.description = "On setting, the \"value\" attribute of an Attr " + "object creates a Text node with the unparsed " + "content of the string."; // // Retrieve the targeted data, assign a value to it and capture its // "value" attribute. // testNode = new nodeObject(FOURTH,SIXTH); streetAttr = testNode.attributes.getNamedItem("street"); streetAttr.value = "Y%ent1;"; computedValue = streetAttr.value; // // Write out results // results.expected = expectedValue; results.actual = computedValue; return results; } //------------------------ End test case core-0013A -------------------------- // //-------------------------- test case core-0014A --------------------------- // // Testing feature - Setting the "value" attribute raises a // NO_MODIFICATION_ALLOWED_ERR DOMException if the // node is readonly. // // Testing approach - Retrieve the first attribute of the Entity node named // "ent4" and attempt to change its value attribute. // Since the descendants of Entity nodes are readonly, the // desired exception should be raised. // // Semantic Requirements: 11 // // Last modification date - March 29, 1999 // // Written by: Carmelo Montanez //---------------------------------------------------------------------------- function core0014A() { var computedValue = 0; var testNode = ""; var readOnlyAttribute = ""; var expectedValue = NO_MODIFICATION_ALLOWED_ERR; results = new testResults("Core0014A"); results.description = "Setting the \"value\" attribute raises a " + "NO_MODIFICATION_ALLOWED_ERR DOMException if " + "the node is readonly."; // // Retrieve the targeted data. // testNode = getEntity("ent4"); readOnlyAttribute = testNode.firstChild.attributes(0); // // attempt to set a value on a readonly node should raise an exception. // try { readOnlyAttribute.value = "ABCD"; } catch(DOMException) { computedValue = DOMException.description; } results.expected = expectedValue; results.actual = computedValue; resetData(); return results; } //------------------------ End test case core-0014A --------------------------