test_option_text.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!doctype html>
  2. <meta charset=utf-8>
  3. <title>HTMLOptionElement.text</title>
  4. <link rel=author title=Ms2ger href="mailto:Ms2ger@gmail.com">
  5. <link rel=help href="http://www.whatwg.org/html/#dom-option-text">
  6. <script src="/resources/testharness.js"></script>
  7. <script src="/resources/testharnessreport.js"></script>
  8. <div id=log></div>
  9. <script>
  10. test(function() {
  11. var option = document.createElement("option");
  12. option.appendChild(document.createElement("font"))
  13. .appendChild(document.createTextNode(" font "));
  14. assert_equals(option.text, "font");
  15. }, "option.text should recurse");
  16. test(function() {
  17. var option = document.createElement("option");
  18. option.appendChild(document.createTextNode(" before "));
  19. option.appendChild(document.createElement("script"))
  20. .appendChild(document.createTextNode(" script "));
  21. option.appendChild(document.createTextNode(" after "));
  22. assert_equals(option.text, "before after");
  23. }, "option.text should not recurse into HTML script elements");
  24. test(function() {
  25. var option = document.createElement("option");
  26. option.appendChild(document.createTextNode(" before "));
  27. option.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "script"))
  28. .appendChild(document.createTextNode(" script "));
  29. option.appendChild(document.createTextNode(" after "));
  30. assert_equals(option.text, "before after");
  31. }, "option.text should not recurse into SVG script elements");
  32. test(function() {
  33. var option = document.createElement("option");
  34. option.appendChild(document.createTextNode(" before "));
  35. option.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "script"))
  36. .appendChild(document.createTextNode(" script "));
  37. option.appendChild(document.createTextNode(" after "));
  38. assert_equals(option.text, "before script after");
  39. }, "option.text should recurse into MathML script elements");
  40. test(function() {
  41. var option = document.createElement("option");
  42. option.appendChild(document.createTextNode(" before "));
  43. option.appendChild(document.createElementNS(null, "script"))
  44. .appendChild(document.createTextNode(" script "));
  45. option.appendChild(document.createTextNode(" after "));
  46. assert_equals(option.text, "before script after");
  47. }, "option.text should recurse into null script elements");
  48. test(function() {
  49. var option = document.createElement("option");
  50. var span = option.appendChild(document.createElement("span"));
  51. span.appendChild(document.createTextNode(" Some "));
  52. span.appendChild(document.createElement("script"))
  53. .appendChild(document.createTextNode(" script "));
  54. option.appendChild(document.createTextNode(" Text "));
  55. assert_equals(option.text, "Some Text");
  56. }, "option.text should work if a child of the option ends with a script");
  57. </script>