test_bug797113.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!doctype html>
  2. <meta charset=utf-8>
  3. <title>Test for bug 780993</title>
  4. <script src=/resources/testharness.js></script>
  5. <script src=/resources/testharnessreport.js></script>
  6. <div id=log></div>
  7. <script>
  8. test(function() {
  9. var select = document.createElement("select");
  10. var option = document.createElement("option");
  11. select.appendChild(option);
  12. assert_equals(select.options[0], option);
  13. select.options[0] = null;
  14. assert_equals(option.parentNode, null);
  15. assert_equals(select.options[0], undefined);
  16. }, "Should be able to set select.options[n] to null.");
  17. test(function() {
  18. var select = document.createElement("select");
  19. var option = document.createElement("option");
  20. var option2 = document.createElement("option");
  21. select.appendChild(option);
  22. assert_equals(select.options[0], option);
  23. select.options[0] = option2;
  24. assert_equals(option.parentNode, null);
  25. assert_equals(option2.parentNode, select);
  26. assert_equals(select.options[0], option2);
  27. }, "Should be able to set select.options[n] to an option element");
  28. test(function() {
  29. var select = document.createElement("select");
  30. var option = document.createElement("option");
  31. select.appendChild(option);
  32. assert_equals(select.options[0], option);
  33. assert_throws(null, function() {
  34. select.options[0] = 42;
  35. });
  36. assert_equals(option.parentNode, select);
  37. assert_equals(select.options[0], option);
  38. }, "Should not be able to set select.options[n] to a primitive.");
  39. </script>