option-text-setter.html (1364B)
1 <!doctype html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <form> 5 <select> 6 <option value='foo'>bar</option> 7 </select> 8 </form> 9 <script> 10 test(() => { 11 var option = document.querySelector('option'); 12 var textChild = option.firstChild; 13 assert_equals(textChild.nodeValue, "bar", "Verify that text child node's value equals the option value."); 14 assert_true(textChild.isConnected, 'Verify that text child node is in the document.'); 15 option.text = "baz"; 16 assert_equals(textChild.nodeValue, "bar", 'Verify that the text child node does not have an updated value.'); 17 assert_false(textChild.isConnected, 'Verify that the text child node is not in the document.'); 18 assert_not_equals(textChild, option.firstChild, 'Verify that text child node was replaced by a different text child node.'); 19 assert_equals(option.firstChild.nodeValue, "baz", 'Verify that the new text child node does equal the updated value.'); 20 assert_equals(option.text, "baz", 'Verify that option text getter returns the updated value.'); 21 option.text = ""; 22 assert_equals(option.firstChild, null, 'Verify that after setting to empty string there are no child text nodes.'); 23 }, 'Verify that using HTMLOptionElement.text setter does not update the existing text child node.'); 24 </script>