test_named_options.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=772869
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 772869</title>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. </head>
  12. <body>
  13. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=772869">Mozilla Bug 772869</a>
  14. <p id="display"></p>
  15. <div id="content" style="display: none">
  16. <select id="s">
  17. <option name="x"></option>
  18. <option name="y" id="z"></option>
  19. <option name="z" id="x"></option>
  20. <option id="w"></option>
  21. </select>
  22. </div>
  23. <pre id="test">
  24. <script type="application/javascript">
  25. /** Test for Bug 772869 **/
  26. var opt = $("s").options;
  27. opt.loopy = "something"
  28. var names = Object.getOwnPropertyNames(opt);
  29. is(names.length, 9, "Should have nine entries");
  30. is(names[0], "0", "Entry 1")
  31. is(names[1], "1", "Entry 2")
  32. is(names[2], "2", "Entry 3")
  33. is(names[3], "3", "Entry 4")
  34. is(names[4], "x", "Entry 5")
  35. is(names[5], "y", "Entry 6")
  36. is(names[6], "z", "Entry 7")
  37. is(names[7], "w", "Entry 8")
  38. is(names[8], "loopy", "Entry 9")
  39. var names2 = [];
  40. for (var name in opt) {
  41. names2.push(name);
  42. }
  43. is(names2.length, 11, "Should have eleven enumerated names");
  44. is(names2[0], "0", "Enum entry 1")
  45. is(names2[1], "1", "Enum entry 2")
  46. is(names2[2], "2", "Enum entry 3")
  47. is(names2[3], "3", "Enum entry 4")
  48. is(names2[4], "loopy", "Enum entry 5")
  49. is(names2[5], "add", "Enum entrry 6")
  50. is(names2[6], "remove", "Enum entry 7")
  51. is(names2[7], "length", "Enum entry 8")
  52. is(names2[8], "selectedIndex", "Enum entry 9")
  53. is(names2[9], "item", "Enum entry 10")
  54. is(names2[10], "namedItem", "Enum entry 11")
  55. </script>
  56. </pre>
  57. </body>
  58. </html>