//**************************************************************************
//
//
//                       National Institute Of Standards and Technology
//                                    DTS Version 1.0
//         
//                                HTMLCollection Interface
//**************************************************************************

function HTMLCollection()
{
   var tests = new Array (HTML0001HC(),HTML0002HC(),HTML0003HC(),HTML0004HC(),HTML0005HC(),HTML0006HC(),HTML0007HC(),HTML0008HC(),HTML0009HC(),HTML0010HC(),HTML0011HC(),HTML0012HC());
   return tests;
}

//------------------------ test case HTML-0001HC ------------------------
//
// Testing feature - An individual node may be accessed by either ordinal 
//                   index, node's name or id attributes (test invocation
//                   by ordinal index); 
//
// Testing approach - Retrieve the first TABLE element of the testing
//                    document and create an HTMLCollection by invoking
//                    its "rows" attribute.  The item located at ordinal
//                    index 0 is further retrieved and its "rowIndex"
//                    attribute examined.
//
// Semantic Requirements: 1
//
// Last modification date - July 30, 1999
//
// Written by: Carmelo Montanez
//------------------------------------------------------------------------

 function HTML0001HC()
 {
   var computedValue = "";
   var expectedValue = 0;
   var results = "";
   var testNode = "";
   var collection = "";
   var row = "";

    results = new testResults("HTML0001HC");
    results.description = "An individual node in the HTMLCollection "+
                          "accessed via an ordinal index.";
//
// Retrieve targeted data.
//
      testNode = new HTMLNodeObject(TABLE,FIRST);
//
// and create an HTMLCollection by invoking the "rows" attribute,
// then retrieve the item at index 0. 
//
      collection = testNode.node.rows;
      row = collection(0);
      computedValue = row.rowIndex;
//
// Write out results 
//
      resetHTMLData();
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}

//------------------------ End test case HTML-0001HC -------------------------
//
//-------------------------- test case HTML-0002HC ---------------------------
//
// Testing feature - An individual node may be accessed by either ordinal
//                   index, node's name or id attributes (test invocation
//                   by node's name);
//
// Testing approach - Retrieve the first FORM element of the testing
//                    document and create an HTMLCollection by invoking
//                    its "element" attribute.  The first SELECT element 
//                    is further retrieved by using the element's name 
//                    ("select1").
//
// Semantic Requirements: 1 
//
// Last modification date - September 28, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0002HC()
 {
   var computedValue = "";
   var expectedValue = "SELECT";
   var results = "";
   var testNode = "";
   var collection = "";
   var row = "";

    results = new testResults("HTML0002HC");
    results.description = "An individual node in the HTMLCollection "+
                          "accessed via the node's name.";
//
// Retrieve targeted data.
//
      testNode = new HTMLNodeObject(FORM,FIRST);
//
// and create an HTMLCollection by invoking the "elements" attribute,
// then retrieve the item named "select1".
//
      collection = testNode.node.elements;
      computedValue = collection("select1").nodeName;
//
// Write out results
//
      results.expected = expectedValue; 
      results.actual = computedValue;

    return results;
}

//------------------------ End test case HTML-0002HC -------------------------
//
//-------------------------- test case HTML-0003HC ---------------------------
//
// Testing feature - An individual node may be accessed by either ordinal
//                   index, node's name or id attributes (test invocation
//                   by node's "id" attribute);
//
// Testing approach - Retrieve the first FORM element of the testing
//                    document and create an HTMLCollection by invoking
//                    its "elements" attribute.  The first SELECT element 
//                    retrieved by using its "id" attribute ("selectId").
//
// Semantic Requirements: 1
//
// Last modification date - September 28, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0003HC()
 {
   var computedValue = "";
   var expectedValue = "SELECT";
   var results = "";
   var testNode = "";
   var collection = "";
   var row = "";

    results = new testResults("HTML0003HC");
    results.description = "An individual node in the HTMLCollection "+
                          "accessed via the nodes \"id\".";
//
// Retrieve targeted data.
//
      testNode = new HTMLNodeObject(FORM,FIRST);
//
// and create an HTMLCollection by invoking the "elements" attribute,
// then retrieve the item with id="selectId".
//
      collection = testNode.node.elements;
      computedValue = collection("selectId").nodeName;
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}

//------------------------ End test case HTML-0003HC -------------------------
//
//-------------------------- test case HTML-0004HC ---------------------------
//
// Testing feature - HTMLCollections are "live", they are automatically 
//                   updated when the underlying doucument is changed.
//
// Testing approach - Create an HTMLCollection object by invoking the
//                    "rows" attribute of the first TABLE element and
//                    examine the length of the object, then add a new
//                    row to the table and re-examine the length
//                    of the collection object.   
//
// Semantic Requirements: 2 
//
// Last modification date - August 2, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0004HC()
 {
   var computedValue = "";
   var expectedValue = "7 8";
   var results = "";
   var testNode = "";
   var collection = "";
   var collectionLength = "";

    results = new testResults("HTML0004HC");
    results.description = "HTMLCollection objects are live,"+
                          "changes in the underlying document are "+
                          "automatically reflected.";
//
// Retrieve targeted data.
//
      testNode = new HTMLNodeObject(TABLE,FIRST);
//
// and access retrieve the number of rows in the table .
//
      collection = testNode.node.rows;
      collectionLength = collection.length;
      computedValue = collectionLength+" ";
//
// Add another row to the table and get the new number of rows. 
//
      testNode.node.insertRow(4);
      collectionLength = collection.length; 
      computedValue += collectionLength;
//
// Write out results
//
      resetHTMLData();
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}

//------------------------ End test case HTML-0004HC -------------------------
//
//-------------------------- test case HTML-0005HC ---------------------------
//
// Testing feature - The "length" attribute specifies the length or
//                   size of the list.
//
// Testing approach - Create an HTMLCollection object by accessing the
//                    "rows" attribute of the first TABLE element, then
//                    invoke the "length" attribute on the resulting
//                    HTMLCollection object.
//
// Semantic Requirements: 3 
//
// Last modification date - August 2, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0005HC()
 {
   var computedValue = "";
   var expectedValue = 7;
   var results = "";
   var testNode = "";
   var collection = "";
   var collectionLength = "";

    results = new testResults("HTML0005HC");
    results.description = "the \"length\" attribute specifies "+
                          "size of the list";
//
// Retrieve the targeted data.
//
      testNode = new HTMLNodeObject(TABLE,FIRST);
      collection = testNode.node.rows;
//
// and get its "length" attribute.
//
      computedValue = collection.length;
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}
//------------------------ End test case HTML-0005HC -------------------------
//
//-------------------------- test case HTML-0006HC ---------------------------
//
// Testing feature - The "item(index)" method retrieves an item specified
//                   by ordinal index (test for index = 0). 
//
// Testing approach - Create an HTMLCollection object by accessing the
//                    "rows" attribute of the first TABLE element, then
//                    invoke the "item(index)" on the resulting
//                    HTMLCollection object with index = 0.  The rowIndex
//                    attribute of the item is then examined. 
//
// Semantic Requirements: 4 
//
// Last modification date - August 2, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0006HC()
 {
   var computedValue = "";
   var expectedValue = 0;
   var results = "";
   var testNode = "";
   var collection = "";
   var firstRow = "";

    results = new testResults("HTML0006HC");
    results.description = "the \"item(index)\" method retrieves "+
                          "an item specified by ordinal index "+
                          "(index = 0)";
//
// Retrieve the targeted data.
//
      testNode = new HTMLNodeObject(TABLE,FIRST);
      collection = testNode.node.rows;
//
// invoke its "item(index)" method with index = 0.
//
      firstRow = collection.item(FIRST);
      computedValue = firstRow.rowIndex;
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}
//------------------------ End test case HTML-0006HC -------------------------
//
//
//-------------------------- test case HTML-0006HC ---------------------------
//
// Testing feature - The "item(index)" method retrieves an item specified
//                   by ordinal index (test for index = 6).
//
// Testing approach - Create an HTMLCollection object by accessing the
//                    "rows" attribute of the first TABLE element, then
//                    invoke the "item(index)" on the resulting
//                    HTMLCollection object with index = 6.  The rowIndex
//                    attribute of the item is then examined.
//
// Semantic Requirements: 4
//
// Last modification date - August 2, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0007HC()
 {
   var computedValue = "";
   var expectedValue = 6;
   var results = "";
   var testNode = "";
   var collection = "";
   var firstRow = "";

    results = new testResults("HTML0007HC");
    results.description = "the \"item(index)\" method retrieves "+
                          "an item specified by ordinal index "+
                          "(index = 6)";
//
// Retrieve the targeted data.
//
      testNode = new HTMLNodeObject(TABLE,FIRST);
      collection = testNode.node.rows;
//
// invoke its "item(index)" method with index = 0.
//
      firstRow = collection.item(SEVENTH);
      computedValue = firstRow.rowIndex;
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}
//------------------------ End test case HTML-0007HC -------------------------
//
//-------------------------- test case HTML-0008HC ---------------------------
//
// Testing feature - Nodes in an HTMLCollection object are numbered in tree 
//                   order (depth-first traversal order). 
//
// Testing approach - Create an HTMLCollection object by accessing the
//                    "rows" attribute of the first TABLE element, then
//                    access its third item by ordinal index.  The resulting
//                    "rowIndex" of the returned row object should be equal
//                    to 2.
//
// Semantic Requirements: 5 
//
// Last modification date - August 2, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0008HC()
 {
   var computedValue = "";
   var expectedValue = 2;
   var results = "";
   var testNode = "";
   var collection = "";
   var firstRow = "";

    results = new testResults("HTML0008HC");
    results.description = "Nodes in an HTMLCollection object "+
                          "are numbered in tree order (depth-first "+
                          "traversal order)";
//
// Retrieve the targeted data.
//
      testNode = new HTMLNodeObject(TABLE,FIRST);
      collection = testNode.node.rows;
//
// invoke its "item(index)" method with index = 0.
//
      firstRow = collection.item(THIRD);
      computedValue = firstRow.rowIndex;
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}
//------------------------ End test case HTML-0008HC -------------------------
//
//-------------------------- test case HTML-0009HC ---------------------------
//
// Testing feature - The "item(index)" method returns null if the index is
//                   out of range. 
//
// Testing approach - Create an HTMLCollection object by accessing the
//                    "rows" attribute of the first TABLE element, then
//                    invoke the "item(index)" method with index = 7.  
//                    This index is out of range and therefore the 
//                    method should return a null value.
//
// Semantic Requirements: 6 
//
// Last modification date - August 2, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0009HC()
 {
   var computedValue = "";
   var expectedValue = null;
   var results = "";
   var testNode = "";
   var collection = "";

    results = new testResults("HTML0009HC");
    results.description = "The \"item(index)\" method returns "+
                          "null if the index is out of range.";
//
// Retrieve the targeted data.
//
      testNode = new HTMLNodeObject(TABLE,FIRST);
      collection = testNode.node.rows;
//
// invoke its "item(index)" method with index = 7.
//
      computedValue = collection.item(EIGHT);
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}
//------------------------ End test case HTML-0009HC -------------------------
//
//-------------------------- test case HTML-0010HC ---------------------------
//
// Testing feature - The namedItem(name) method retrieves a node using 
//                   a name. It first searches for a node with a matching
//                   id attribute.
//
// Testing approach - Create an HTMLCollection object by accessing the
//                    "elements" attribute of the first FORM element, then
//                    invoke the "namedItem(name)" method with name =
//                    "selectId" on the returned object.  Since there
//                    is an element with the attribute set to that value,
//                    the method should return that node.
//
// Semantic Requirements: 7,8 
//
// Last modification date - September 28, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0010HC()
 {
   var computedValue = "";
   var expectedValue = SELECT;
   var results = "";
   var testNode = "";
   var collection = "";

    results = new testResults("HTML0010HC");
    results.description = "The \"namedItem(name)\" method retrieves "+
                          "a node by matching an id attribute.";
//
// Retrieve the targeted data.
//
        testNode = new HTMLNodeObject(FORM,FIRST);
        collection = testNode.node.elements;
//
// invoke its namedItem(name) method with name = "selectId". 
// Temporarily commented out due to IE5 non support
//      computedValue = collection.namedItem("selectId");
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}
//------------------------ End test case HTML-0010HC -------------------------
//
//-------------------------- test case HTML-0011HC ---------------------------
//
// Testing feature - The namedItem(name) method retrieves a node using
//                   a name. If no node with a matching id attribute is 
//                   found, then the method searches for a node with
//                   a matching name.
//
// Testing approach - Create an HTMLCollection object by accessing the
//                    "elements" attribute of the first FORM element, then
//                    invoke the "namedItem(name)" method with name = 
//                    "select1" on the returned object. 
//
// Semantic Requirements: 7, 9
//
// Last modification date - September 28, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0011HC()
 {
   var computedValue = "";
   var expectedValue = SELECT;
   var results = "";
   var testNode = "";
   var collection = "";

    results = new testResults("HTML0011HC");
    results.description = "The \"namedItem(name)\" method retrieves "+
                          "a node by matching the name.";
//
// Retrieve the targeted data.
//
      testNode = new HTMLNodeObject(FORM,FIRST);
      collection = testNode.node.elements;
//
// invoke its namedItem(name) method with name = "select1".
// Temporarily commented out due to IE5 non support.
//      computedValue = collection.namedItem("select1").nodeName;
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}
//------------------------ End test case HTML-0011HC -------------------------
//
//-------------------------- test case HTML-0012HC ---------------------------
//
// Testing feature - The namedItem(name) method returns null if no node
//                   is found with a matching name or id attribute.
//
// Testing approach - Create an HTMLCollection object by accessing the
//                    "elements" attribute of the first FORM element, then
//                    invoke the "namedItem(name)" method with name =
//                    "select4" on the returned object.  Since no element
//                    has the name attribute with that value, the method
//                    should return null.
//
// Semantic Requirements: 10 
//
// Last modification date - September 28, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function HTML0012HC()
 {
   var computedValue = "";
   var expectedValue = null;
   var results = "";
   var testNode = "";
   var collection = "";

    results = new testResults("HTML0012HC");
    results.description = "The \"namedItem(name)\" method returns "+
                          "null if no matching id attribute or name "+
                          "is found.";
//
// Retrieve the targeted data.
//
      testNode = new HTMLNodeObject(TABLE,FIRST)
      collection = testNode.node.elements;
//
// invoke its namedItem(name) method with name = "select4".  Must
// return null. 
// Temporarily commented out due to IE5 non support.
//
//      computedValue = collection.namedItem("select4");
//
// Write out results
//
      results.expected = expectedValue;
      results.actual = computedValue;

    return results;
}
//------------------------ End test case HTML-0012HC -------------------------