test_HTMLCollection10.html (7106B)
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 2 <html> 3 <head> 4 <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> 6 <title>http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLCollection10</title> 7 <link type="text/css" rel="stylesheet" href="/tests/SimpleTest/test.css"> 8 <script src="/tests/SimpleTest/SimpleTest.js" type="text/javascript"></script> 9 <script src="DOMTestCase.js" type="text/javascript"></script> 10 <script type="text/javascript"> 11 // expose test function names 12 function exposeTestFunctionNames() 13 { 14 return ['HTMLCollection10']; 15 } 16 17 var docsLoaded = -1000000; 18 var builder = null; 19 20 // 21 // This function is called by the testing framework before 22 // running the test suite. 23 // 24 // If there are no configuration exceptions, asynchronous 25 // document loading is started. Otherwise, the status 26 // is set to complete and the exception is immediately 27 // raised when entering the body of the test. 28 // 29 function setUpPage() { 30 setUpPageStatus = 'running'; 31 try { 32 // 33 // creates test document builder, may throw exception 34 // 35 builder = createConfiguredBuilder(); 36 37 docsLoaded = 0; 38 39 var docRef = null; 40 if (typeof(this.doc) != 'undefined') { 41 docRef = this.doc; 42 } 43 docsLoaded += preload(docRef, "doc", "collection"); 44 45 if (docsLoaded == 1) { 46 setUpPage = 'complete'; 47 } 48 } catch(ex) { 49 catchInitializationError(builder, ex); 50 setUpPage = 'complete'; 51 } 52 } 53 54 55 56 // 57 // This method is called on the completion of 58 // each asychronous load started in setUpTests. 59 // 60 // When every synchronous loaded document has completed, 61 // the page status is changed which allows the 62 // body of the test to be executed. 63 function loadComplete() { 64 if (++docsLoaded == 1) { 65 setUpPageStatus = 'complete'; 66 runJSUnitTests(); 67 SimpleTest.finish(); 68 } 69 } 70 71 72 /** 73 * 74 The namedItem(name) method retrieves a node using a name. It first 75 searches for a node with a matching id attribute. If it doesn't find 76 one, it then searches for a Node with a matching name attribute, but only 77 on those elements that are allowed a name attribute. 78 79 Retrieve the first FORM element and create a HTMLCollection by invoking 80 the elements attribute. The first SELECT element is further retrieved 81 using the elements name attribute since the id attribute doesn't match. 82 83 * @author NIST 84 * @author Rick Rivello 85 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-21069976 86 */ 87 function HTMLCollection10() { 88 var success; 89 if(checkInitialization(builder, "HTMLCollection10") != null) return; 90 var nodeList; 91 var testNode; 92 var formNode; 93 var formsnodeList; 94 var vname; 95 var doc; 96 97 var docRef = null; 98 if (typeof(this.doc) != 'undefined') { 99 docRef = this.doc; 100 } 101 doc = load(docRef, "doc", "collection"); 102 nodeList = doc.getElementsByTagName("form"); 103 assertSize("Asize",1,nodeList); 104 testNode = nodeList.item(0); 105 formsnodeList = testNode.elements; 106 107 formNode = formsnodeList.namedItem("select1"); 108 vname = formNode.nodeName; 109 110 assertEqualsAutoCase("element", "nameIndexLink","SELECT",vname); 111 112 } 113 114 </script> 115 </head> 116 <body> 117 <h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLCollection10</h2> 118 <p><test name='HTMLCollection10' schemaLocation='http://www.w3.org/2001/DOM-Test-Suite/Level-1 dom1.xsd'><br> <metadata><br> <title>HTMLCollection10</title> 119 <br> <creator>NIST</creator> 120 <br> <description> 121 The namedItem(name) method retrieves a node using a name. It first 122 searches for a node with a matching id attribute. If it doesn't find 123 one, it then searches for a Node with a matching name attribute, but only 124 on those elements that are allowed a name attribute. 125 126 Retrieve the first FORM element and create a HTMLCollection by invoking 127 the elements attribute. The first SELECT element is further retrieved 128 using the elements name attribute since the id attribute doesn't match. 129 </description> 130 <br> <contributor>Rick Rivello</contributor> 131 <br> <date qualifier='created'>2002-05-01</date> 132 <br> <subject resource='<a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-21069976">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-21069976</a>'/> 133 <br></metadata><br> <var name='nodeList' type='NodeList'/><br> <var name='testNode' type='Node'/><br> <var name='formNode' type='Node'/><br> <var name='formsnodeList' type='HTMLCollection'/><br> <var name='vname' type='DOMString'/><br> <var name='doc' type='Document'/><br> <load var='doc' href='collection' willBeModified='false'/><br> <getElementsByTagName interface='Document' obj='doc' var='nodeList' tagname='"form"'/><br> <assertSize collection='nodeList' size='1' <a id="Asize">id='Asize'</a>/><br> <item interface='NodeList' obj='nodeList' var='testNode' index='0'/><br> <elements interface='HTMLFormElement' obj='testNode' var='formsnodeList'/><br> <namedItem obj='formsnodeList' var='formNode' name='"select1"'/><br> <nodeName obj='formNode' var='vname'/><br> <assertEquals actual='vname' expected='"SELECT"' <a id="nameIndexLink">id='nameIndexLink'</a> ignoreCase='auto'/><br></test><br> 134 </p> 135 <p> 136 Copyright (c) 2001-2004 World Wide Web Consortium, 137 (Massachusetts Institute of Technology, Institut National de 138 Recherche en Informatique et en Automatique, Keio University). All 139 Rights Reserved. This program is distributed under the W3C's Software 140 Intellectual Property License. This program is distributed in the 141 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 142 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 143 PURPOSE. 144 </p> 145 <p>See W3C License <a href="http://www.w3.org/Consortium/Legal/">http://www.w3.org/Consortium/Legal/</a> 146 for more details.</p> 147 <iframe name="doc" src="files/collection.html"></iframe> 148 <br> 149 </body> 150 </html>