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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/HTMLTableElement29</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 ['HTMLTableElement29'];
    15 }
    17 var docsLoaded = -1000000;
    18 var builder = null;
    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();
    37       docsLoaded = 0;
    39       var docRef = null;
    40       if (typeof(this.doc) != 'undefined') {
    41         docRef = this.doc;
    42       }
    43       docsLoaded += preload(docRef, "doc", "table");
    45        if (docsLoaded == 1) {
    46           setUpPage = 'complete';
    47        }
    48     } catch(ex) {
    49     	catchInitializationError(builder, ex);
    50         setUpPage = 'complete';
    51     }
    52 }
    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 }
    72 /**
    73 * 
    74     The insertRow() method inserts a new empty table row. 
    76     Retrieve the second TABLE element and invoke the insertRow() method
    77     with an index of two. Currently the 2nd indexed row is in the TBODY
    78     section of the TABLE.  The number of rows in the TBODY section before
    79     insertion of the new row is two.  After the new row is inserted the number 
    80     of rows in the TBODY section is three.
    82 * @author NIST
    83 * @author Rick Rivello
    84 * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-39872903
    85 */
    86 function HTMLTableElement29() {
    87    var success;
    88     if(checkInitialization(builder, "HTMLTableElement29") != null) return;
    89     var nodeList;
    90       var tbodiesnodeList;
    91       var testNode;
    92       var bodyNode;
    93       var newRow;
    94       var rowsnodeList;
    95       var vsection1;
    96       var vsection2;
    97       var vrows;
    98       var doc;
   100       var docRef = null;
   101       if (typeof(this.doc) != 'undefined') {
   102         docRef = this.doc;
   103       }
   104       doc = load(docRef, "doc", "table");
   105       nodeList = doc.getElementsByTagName("table");
   106       assertSize("Asize",3,nodeList);
   107 testNode = nodeList.item(1);
   108       tbodiesnodeList = testNode.tBodies;
   110       bodyNode = tbodiesnodeList.item(0);
   111       rowsnodeList = bodyNode.rows;
   113       vrows = rowsnodeList.length;
   115       assertEquals("rowsLink1",2,vrows);
   116        newRow = testNode.insertRow(2);
   117       tbodiesnodeList = testNode.tBodies;
   119       bodyNode = tbodiesnodeList.item(0);
   120       rowsnodeList = bodyNode.rows;
   122       vrows = rowsnodeList.length;
   124       assertEquals("rowsLink2",3,vrows);
   126 }
   128 </script>
   129 </head>
   130 <body>
   131 <h2>Test http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLTableElement29</h2>
   132 <p>&lt;test name='HTMLTableElement29' 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;HTMLTableElement29&lt;/title&gt;
   133 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;creator&gt;NIST&lt;/creator&gt;
   134 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;description&gt;
   135     The insertRow() method inserts a new empty table row. 
   137     Retrieve the second TABLE element and invoke the insertRow() method
   138     with an index of two. Currently the 2nd indexed row is in the TBODY
   139     section of the TABLE.  The number of rows in the TBODY section before
   140     insertion of the new row is two.  After the new row is inserted the number 
   141     of rows in the TBODY section is three.
   142 &lt;/description&gt;
   143 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;contributor&gt;Rick Rivello&lt;/contributor&gt;
   144 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;date qualifier='created'&gt;2002-05-02&lt;/date&gt;
   145 <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-39872903">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-39872903</a>'/&gt;
   146 <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='tbodiesnodeList' type='HTMLCollection'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='testNode' type='Node'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='bodyNode' type='Node'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='newRow' type='HTMLElement'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='rowsnodeList' type='HTMLCollection'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='vsection1' type='HTMLTableSectionElement'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='vsection2' type='HTMLTableSectionElement'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='vrows' type='int'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;var name='doc' type='Document'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;load var='doc' href='table' 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='3' <a id="Asize">id='Asize'</a>/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item interface='NodeList' obj='nodeList' var='testNode' index='1'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tBodies interface='HTMLTableElement' obj='testNode' var='tbodiesnodeList'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item interface='HTMLCollection' obj='tbodiesnodeList' var='bodyNode' index='0'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;rows interface='HTMLTableSectionElement' obj='bodyNode' var='rowsnodeList'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;length interface='HTMLCollection' obj='rowsnodeList' var='vrows'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;assertEquals actual='vrows' expected='2' <a id="rowsLink1">id='rowsLink1'</a> ignoreCase='false'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;insertRow interface='HTMLTableElement' obj='testNode' var='newRow' index='2'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tBodies interface='HTMLTableElement' obj='testNode' var='tbodiesnodeList'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item interface='HTMLCollection' obj='tbodiesnodeList' var='bodyNode' index='0'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;rows interface='HTMLTableSectionElement' obj='bodyNode' var='rowsnodeList'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;length interface='HTMLCollection' obj='rowsnodeList' var='vrows'/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;assertEquals actual='vrows' expected='3' <a id="rowsLink2">id='rowsLink2'</a> ignoreCase='false'/&gt;<br>&lt;/test&gt;<br>
   147 </p>
   148 <p>
   149 			Copyright (c) 2001-2004 World Wide Web Consortium,
   150 			(Massachusetts Institute of Technology, Institut National de
   151 			Recherche en Informatique et en Automatique, Keio University). All
   152 			Rights Reserved. This program is distributed under the W3C's Software
   153 			Intellectual Property License. This program is distributed in the
   154 			hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   155 			the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   156 			PURPOSE.
   157 			</p>
   158 <p>See W3C License <a href="http://www.w3.org/Consortium/Legal/">http://www.w3.org/Consortium/Legal/</a> 
   159  for more details.</p>
   160 <iframe name="doc" src="files/table.html"></iframe>
   161 <br>
   162 </body>
   163 </html>

mercurial