Node-nodeValue.html (2402B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>Node.nodeValue</title> 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-node-nodevalue"> 5 <script src=/resources/testharness.js></script> 6 <script src=/resources/testharnessreport.js></script> 7 <div id=log></div> 8 <script> 9 test(function() { 10 var the_text = document.createTextNode("A span!"); 11 assert_equals(the_text.nodeValue, "A span!"); 12 assert_equals(the_text.data, "A span!"); 13 the_text.nodeValue = "test again"; 14 assert_equals(the_text.nodeValue, "test again"); 15 assert_equals(the_text.data, "test again"); 16 the_text.nodeValue = null; 17 assert_equals(the_text.nodeValue, ""); 18 assert_equals(the_text.data, ""); 19 }, "Text.nodeValue"); 20 21 test(function() { 22 var the_comment = document.createComment("A comment!"); 23 assert_equals(the_comment.nodeValue, "A comment!"); 24 assert_equals(the_comment.data, "A comment!"); 25 the_comment.nodeValue = "test again"; 26 assert_equals(the_comment.nodeValue, "test again"); 27 assert_equals(the_comment.data, "test again"); 28 the_comment.nodeValue = null; 29 assert_equals(the_comment.nodeValue, ""); 30 assert_equals(the_comment.data, ""); 31 }, "Comment.nodeValue"); 32 33 test(function() { 34 var the_pi = document.createProcessingInstruction("pi", "A PI!"); 35 assert_equals(the_pi.nodeValue, "A PI!"); 36 assert_equals(the_pi.data, "A PI!"); 37 the_pi.nodeValue = "test again"; 38 assert_equals(the_pi.nodeValue, "test again"); 39 assert_equals(the_pi.data, "test again"); 40 the_pi.nodeValue = null; 41 assert_equals(the_pi.nodeValue, ""); 42 assert_equals(the_pi.data, ""); 43 }, "ProcessingInstruction.nodeValue"); 44 45 test(function() { 46 var the_link = document.createElement("a"); 47 assert_equals(the_link.nodeValue, null); 48 the_link.nodeValue = "foo"; 49 assert_equals(the_link.nodeValue, null); 50 }, "Element.nodeValue"); 51 52 test(function() { 53 assert_equals(document.nodeValue, null); 54 document.nodeValue = "foo"; 55 assert_equals(document.nodeValue, null); 56 }, "Document.nodeValue"); 57 58 test(function() { 59 var the_frag = document.createDocumentFragment(); 60 assert_equals(the_frag.nodeValue, null); 61 the_frag.nodeValue = "foo"; 62 assert_equals(the_frag.nodeValue, null); 63 }, "DocumentFragment.nodeValue"); 64 65 test(function() { 66 var the_doctype = document.doctype; 67 assert_equals(the_doctype.nodeValue, null); 68 the_doctype.nodeValue = "foo"; 69 assert_equals(the_doctype.nodeValue, null); 70 }, "DocumentType.nodeValue"); 71 </script>