test_bug295561.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=295561
  5. -->
  6. <head>
  7. <title>Test for Bug 295561</title>
  8. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=295561">Mozilla Bug 295561</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. <table id="testTable">
  16. <thead>
  17. <tr id="headRow"><td></td></tr>
  18. </thead>
  19. <tfoot>
  20. <tr id="footRow"><td></td></tr>
  21. </tfoot>
  22. <tbody id="tBody" name="namedTBody">
  23. <tr id="trow" name="namedTRow">
  24. <td id="tcell" name="namedTCell"></td>
  25. <th id="tcellh" name="namedTH"></th>
  26. </tr>
  27. <tr><td></td></tr>
  28. </tbody>
  29. <tbody id="tBody2" name="namedTBody2">
  30. <tr id="trow2" name="namedTRow2">
  31. <td id="tcell2" name="namedTCell2"></td>
  32. <th id="tcellh2" name="namedTH2"></th>
  33. </tr>
  34. </table>
  35. </div>
  36. <pre id="test">
  37. <script class="testbody" type="text/javascript">
  38. function testItById(id, collection, collectionName) {
  39. is(collection[id], $(id),
  40. "Should be able to get by id '" + id + "' from " + collectionName +
  41. " collection using square brackets.")
  42. is(collection.namedItem(id), $(id),
  43. "Should be able to get by id '" + id + "' from " + collectionName +
  44. " collection using namedItem.")
  45. }
  46. function testItByName(name, id, collection, collectionName) {
  47. is(collection[name], $(id),
  48. "Should be able to get by name '" + name + "' from " + collectionName +
  49. " collection using square brackets.")
  50. is(collection.namedItem(name), $(id),
  51. "Should be able to get by name '" + name + "' from " + collectionName +
  52. " collection using namedItem.")
  53. }
  54. function testIt(name, id, collection, collectionName) {
  55. testItByName(name, id, collection, collectionName);
  56. testItById(id, collection, collectionName);
  57. }
  58. var table = $("testTable")
  59. testIt("namedTBody", "tBody", table.tBodies, "tBodies")
  60. testIt("namedTRow", "trow", table.rows, "table rows")
  61. testIt("namedTRow", "trow", $("tBody").rows, "tbody rows")
  62. testIt("namedTCell", "tcell", $("trow").cells, "cells")
  63. testIt("namedTH", "tcellh", $("trow").cells, "cells")
  64. testIt("namedTBody2", "tBody2", table.tBodies, "tBodies")
  65. testIt("namedTRow2", "trow2", table.rows, "table rows")
  66. testIt("namedTRow2", "trow2", $("tBody2").rows, "tbody rows")
  67. testIt("namedTCell2", "tcell2", $("trow2").cells, "cells")
  68. testIt("namedTH2", "tcellh2", $("trow2").cells, "cells")
  69. is(table.tBodies.length, 2, "Incorrect tBodies length");
  70. is(table.rows.length, 5, "Incorrect rows length");
  71. is(table.rows[0], $("headRow"), "THead row in wrong spot");
  72. is(table.rows[1], $("trow"), "First tbody row in wrong spot");
  73. is(table.rows[3], $("trow2"), "Second tbody row in wrong spot");
  74. is(table.rows[4], $("footRow"), "TFoot row in wrong spot");
  75. </script>
  76. </pre>
  77. </body>
  78. </html>