dom/tests/mochitest/dom-level2-html/test_HTMLCollection04.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/dom-level2-html/test_HTMLCollection04.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,158 @@
     1.4 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
     1.5 +<html>
     1.6 +<head>
     1.7 +<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
     1.8 +<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
     1.9 +<title>http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLCollection04</title>
    1.10 +<link type="text/css" rel="stylesheet" href="/tests/SimpleTest/test.css">
    1.11 +<script src="/tests/SimpleTest/SimpleTest.js" type="text/javascript"></script>
    1.12 +<script src="DOMTestCase.js" type="text/javascript"></script>
    1.13 +<script type="text/javascript">
    1.14 +// expose test function names
    1.15 +function exposeTestFunctionNames()
    1.16 +{
    1.17 +return ['HTMLCollection04'];
    1.18 +}
    1.19 +
    1.20 +var docsLoaded = -1000000;
    1.21 +var builder = null;
    1.22 +
    1.23 +//
    1.24 +//   This function is called by the testing framework before
    1.25 +//      running the test suite.
    1.26 +//
    1.27 +//   If there are no configuration exceptions, asynchronous
    1.28 +//        document loading is started.  Otherwise, the status
    1.29 +//        is set to complete and the exception is immediately
    1.30 +//        raised when entering the body of the test.
    1.31 +//
    1.32 +function setUpPage() {
    1.33 +   setUpPageStatus = 'running';
    1.34 +   try {
    1.35 +     //
    1.36 +     //   creates test document builder, may throw exception
    1.37 +     //
    1.38 +     builder = createConfiguredBuilder();
    1.39 +
    1.40 +      docsLoaded = 0;
    1.41 +      
    1.42 +      var docRef = null;
    1.43 +      if (typeof(this.doc) != 'undefined') {
    1.44 +        docRef = this.doc;
    1.45 +      }
    1.46 +      docsLoaded += preload(docRef, "doc", "collection");
    1.47 +        
    1.48 +       if (docsLoaded == 1) {
    1.49 +          setUpPage = 'complete';
    1.50 +       }
    1.51 +    } catch(ex) {
    1.52 +    	catchInitializationError(builder, ex);
    1.53 +        setUpPage = 'complete';
    1.54 +    }
    1.55 +}
    1.56 +
    1.57 +
    1.58 +
    1.59 +//
    1.60 +//   This method is called on the completion of 
    1.61 +//      each asychronous load started in setUpTests.
    1.62 +//
    1.63 +//   When every synchronous loaded document has completed,
    1.64 +//      the page status is changed which allows the
    1.65 +//      body of the test to be executed.
    1.66 +function loadComplete() {
    1.67 +    if (++docsLoaded == 1) {
    1.68 +        setUpPageStatus = 'complete';
    1.69 +        runJSUnitTests();
    1.70 +        SimpleTest.finish();
    1.71 +    }
    1.72 +}
    1.73 +
    1.74 +
    1.75 +/**
    1.76 +* 
    1.77 +    HTMLCollections are live, they are automatically updated when the     
    1.78 +    underlying document is changed.
    1.79 +
    1.80 +    Create a HTMLCollection object by invoking the rows attribute of the    
    1.81 +    first TABLE element and examine its length, then add a new row and
    1.82 +    re-examine the length.
    1.83 +
    1.84 +* @author NIST
    1.85 +* @author Rick Rivello
    1.86 +* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-40057551
    1.87 +*/
    1.88 +function HTMLCollection04() {
    1.89 +   var success;
    1.90 +    if(checkInitialization(builder, "HTMLCollection04") != null) return;
    1.91 +    var nodeList;
    1.92 +      var testNode;
    1.93 +      var rowLength1;
    1.94 +      var rowLength2;
    1.95 +      var rowsnodeList;
    1.96 +      var newRow;
    1.97 +      var vrowindex;
    1.98 +      var doc;
    1.99 +      var result = new Array();
   1.100 +
   1.101 +      expectedResult = new Array();
   1.102 +      expectedResult[0] = 4;
   1.103 +      expectedResult[1] = 5;
   1.104 +
   1.105 +      
   1.106 +      var docRef = null;
   1.107 +      if (typeof(this.doc) != 'undefined') {
   1.108 +        docRef = this.doc;
   1.109 +      }
   1.110 +      doc = load(docRef, "doc", "collection");
   1.111 +      nodeList = doc.getElementsByTagName("table");
   1.112 +      assertSize("Asize",1,nodeList);
   1.113 +testNode = nodeList.item(0);
   1.114 +      rowsnodeList = testNode.rows;
   1.115 +
   1.116 +      rowLength1 = rowsnodeList.length;
   1.117 +
   1.118 +      result[result.length] = rowLength1;
   1.119 +newRow = testNode.insertRow(4);
   1.120 +      rowLength2 = rowsnodeList.length;
   1.121 +
   1.122 +      result[result.length] = rowLength2;
   1.123 +assertEqualsList("rowIndexLink",expectedResult,result);
   1.124 +       
   1.125 +}
   1.126 +
   1.127 +</script>
   1.128 +</head>
   1.129 +<body>
   1.130 +<h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLCollection04</h2>
   1.131 +<p>&lt;test name='HTMLCollection04' schemaLocation='http://www.w3.org/2001/DOM-Test-Suite/Level-1 dom1.xsd'&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;metadata&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;HTMLCollection04&lt;/title&gt;
   1.132 +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;creator&gt;NIST&lt;/creator&gt;
   1.133 +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;description&gt;
   1.134 +    HTMLCollections are live, they are automatically updated when the     
   1.135 +    underlying document is changed.
   1.136 +
   1.137 +    Create a HTMLCollection object by invoking the rows attribute of the    
   1.138 +    first TABLE element and examine its length, then add a new row and
   1.139 +    re-examine the length.
   1.140 +&lt;/description&gt;
   1.141 +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;contributor&gt;Rick Rivello&lt;/contributor&gt;
   1.142 +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;date qualifier='created'&gt;2002-05-01&lt;/date&gt;
   1.143 +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;subject resource='<a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-40057551">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-40057551</a>'/&gt;
   1.144 +<br>&lt;/metadata&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='nodeList' type='NodeList'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='testNode' type='Node'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='rowLength1' type='int'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='rowLength2' type='int'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='rowsnodeList' type='HTMLCollection'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='newRow' type='HTMLElement'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='vrowindex' type='int'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='doc' type='Document'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='result' type='List'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='expectedResult' type='List'&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;member/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;member/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/var&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;load var='doc' href='collection' willBeModified='true'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;getElementsByTagName interface='Document' obj='doc' var='nodeList' tagname='"table"'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;assertSize collection='nodeList' size='1' <a id="Asize">id='Asize'</a>/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item interface='NodeList' obj='nodeList' var='testNode' index='0'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;rows interface='HTMLTableElement' obj='testNode' var='rowsnodeList'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;length interface='HTMLCollection' obj='rowsnodeList' var='rowLength1'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;append collection='result' item='rowLength1'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;insertRow interface='HTMLTableElement' obj='testNode' var='newRow' index='4'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;length interface='HTMLCollection' obj='rowsnodeList' var='rowLength2'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;append collection='result' item='rowLength2'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;assertEquals actual='result' expected='expectedResult' <a id="rowIndexLink">id='rowIndexLink'</a> ignoreCase='false'/&gt;<br>&lt;/test&gt;<br>
   1.145 +</p>
   1.146 +<p>
   1.147 +			Copyright (c) 2001-2004 World Wide Web Consortium,
   1.148 +			(Massachusetts Institute of Technology, Institut National de
   1.149 +			Recherche en Informatique et en Automatique, Keio University). All
   1.150 +			Rights Reserved. This program is distributed under the W3C's Software
   1.151 +			Intellectual Property License. This program is distributed in the
   1.152 +			hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   1.153 +			the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   1.154 +			PURPOSE.
   1.155 +			</p>
   1.156 +<p>See W3C License <a href="http://www.w3.org/Consortium/Legal/">http://www.w3.org/Consortium/Legal/</a> 
   1.157 + for more details.</p>
   1.158 +<iframe name="doc" src="files/collection.html"></iframe>
   1.159 +<br>
   1.160 +</body>
   1.161 +</html>

mercurial