| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/htmloutputelement-value.js"></script> | 7 <script> |
| 8 description('Tests for assigning the value attribute to output elements.'); |
| 9 |
| 10 var output; |
| 11 var childNode; |
| 12 |
| 13 debug('- Sets the defaultValue attribute with the value mode flag is in mode "de
falut".'); |
| 14 output = document.createElement('output'); |
| 15 output.defaultValue = "defaultValue"; |
| 16 shouldBeEqualToString('output.defaultValue', 'defaultValue'); |
| 17 shouldBeEqualToString('output.value', 'defaultValue'); |
| 18 shouldBeEqualToString('output.innerText', 'defaultValue'); |
| 19 shouldBeEqualToString('output.innerHTML', 'defaultValue'); |
| 20 |
| 21 debug('- Sets the value attribute. This will change the value mode flag from "de
fault" to "value".'); |
| 22 |
| 23 output.value = 'aValue'; |
| 24 shouldBeEqualToString('output.defaultValue', 'defaultValue'); |
| 25 shouldBeEqualToString('output.value', 'aValue'); |
| 26 shouldBeEqualToString('output.innerText', 'aValue'); |
| 27 shouldBeEqualToString('output.innerHTML', 'aValue'); |
| 28 |
| 29 debug('- Sets the defaultValue attribute with the value mode flag is in mode "va
lue".'); |
| 30 output.defaultValue = 'another defaultValue'; |
| 31 shouldBeEqualToString('output.defaultValue', 'another defaultValue'); |
| 32 shouldBeEqualToString('output.value', 'aValue'); |
| 33 shouldBeEqualToString('output.innerText', 'aValue'); |
| 34 shouldBeEqualToString('output.innerHTML', 'aValue'); |
| 35 |
| 36 debug('- Ensures that setting text to the value attribute works as setTextConten
t().'); |
| 37 output.value = '<strong>A <span style=\"color: red;\">strong</span> text</strong
>'; |
| 38 shouldBe('output.value', '\'<strong>A <span style="color: red;">strong</span> te
xt</strong>\''); |
| 39 shouldBe('output.innerText', '\'<strong>A <span style="color: red;">strong</span
> text</strong>\''); |
| 40 shouldBe('output.innerHTML', '\'<strong>A <span style="color: red;">
strong</span> text</strong>\''); |
| 41 |
| 42 debug('- Sets the innerText attribute with the value mode flag is in mode "defau
lt".'); |
| 43 output = document.createElement('output'); |
| 44 output.innerText = 'text'; |
| 45 shouldBeEqualToString('output.defaultValue', 'text'); |
| 46 shouldBeEqualToString('output.value', 'text'); |
| 47 shouldBeEqualToString('output.innerText', 'text'); |
| 48 shouldBeEqualToString('output.innerHTML', 'text'); |
| 49 |
| 50 output.innerText = '<strong>strong</strong> text'; |
| 51 shouldBeEqualToString('output.defaultValue', '<strong>strong</strong> text'); |
| 52 shouldBeEqualToString('output.value', '<strong>strong</strong> text'); |
| 53 shouldBeEqualToString('output.innerText', '<strong>strong</strong> text'); |
| 54 shouldBeEqualToString('output.innerHTML', '<strong>strong</strong> t
ext'); |
| 55 |
| 56 debug('- Sets the innerText attribute with the value mode flag is in mode "value
".'); |
| 57 output = document.createElement('output'); |
| 58 output.value = 'aValue'; |
| 59 output.defaultValue = 'defaultValue'; |
| 60 output.innerText = 'text'; |
| 61 shouldBeEqualToString('output.defaultValue', 'defaultValue'); |
| 62 shouldBeEqualToString('output.value', 'text'); |
| 63 shouldBeEqualToString('output.innerText', 'text'); |
| 64 shouldBeEqualToString('output.innerHTML', 'text'); |
| 65 |
| 66 debug('- Sets the innerHTML attribute with the value mode flag is in mode "defau
lt".'); |
| 67 output = document.createElement('output'); |
| 68 output.innerHTML = 'text'; |
| 69 shouldBeEqualToString('output.defaultValue', 'text'); |
| 70 shouldBeEqualToString('output.value', 'text'); |
| 71 shouldBeEqualToString('output.innerText', 'text'); |
| 72 shouldBeEqualToString('output.innerHTML', 'text'); |
| 73 |
| 74 output.innerHTML = '<strong>strong</strong> text'; |
| 75 shouldBeEqualToString('output.defaultValue', 'strong text'); |
| 76 shouldBeEqualToString('output.value', 'strong text'); |
| 77 shouldBeEqualToString('output.innerText', 'strong text'); |
| 78 shouldBeEqualToString('output.innerHTML', '<strong>strong</strong> text'); |
| 79 |
| 80 debug('- Sets the innerHTML attribute with the value mode flag is in mode "value
".'); |
| 81 output = document.createElement('output'); |
| 82 output.value = 'aValue'; |
| 83 output.defaultValue = 'defaultValue'; |
| 84 output.innerHTML = 'text'; |
| 85 shouldBeEqualToString('output.defaultValue', 'defaultValue'); |
| 86 shouldBeEqualToString('output.value', 'text'); |
| 87 shouldBeEqualToString('output.innerText', 'text'); |
| 88 shouldBeEqualToString('output.innerHTML', 'text'); |
| 89 |
| 90 output.innerHTML = '<strong>strong</strong> text'; |
| 91 shouldBeEqualToString('output.defaultValue', 'defaultValue'); |
| 92 shouldBeEqualToString('output.value', 'strong text'); |
| 93 shouldBeEqualToString('output.innerText', 'strong text'); |
| 94 shouldBeEqualToString('output.innerHTML', '<strong>strong</strong> text'); |
| 95 |
| 96 debug('- Appends a child node to the output element with the value mode flag is
in mode "default".'); |
| 97 output = document.createElement('output'); |
| 98 childNode = document.createElement('span'); |
| 99 childNode.innerText = 'childText'; |
| 100 output.appendChild(childNode); |
| 101 shouldBeEqualToString('output.defaultValue', 'childText'); |
| 102 shouldBeEqualToString('output.value', 'childText'); |
| 103 shouldBeEqualToString('output.innerText', 'childText'); |
| 104 shouldBeEqualToString('output.innerHTML', '<span>childText</span>'); |
| 105 debug('- Then removes the child node from the output element with the value mode
flag is in mode "default".'); |
| 106 output.removeChild(childNode); |
| 107 shouldBeEqualToString('output.defaultValue', ''); |
| 108 shouldBeEqualToString('output.value', ''); |
| 109 shouldBeEqualToString('output.innerText', ''); |
| 110 shouldBeEqualToString('output.innerHTML', ''); |
| 111 |
| 112 debug('- Appends a child node to the output element with the value mode flag is
in mode "value".'); |
| 113 output = document.createElement('output'); |
| 114 output.value = 'aValue'; |
| 115 output.defaultValue = 'defaultValue'; |
| 116 childNode = document.createElement('span'); |
| 117 childNode.innerText = ' and childText'; |
| 118 output.appendChild(childNode); |
| 119 shouldBeEqualToString('output.defaultValue', 'defaultValue'); |
| 120 shouldBeEqualToString('output.value', 'aValue and childText'); |
| 121 shouldBeEqualToString('output.innerText', 'aValue and childText'); |
| 122 shouldBeEqualToString('output.innerHTML', 'aValue<span> and childText</span>'); |
| 123 debug('- Then removes the child node from the output element with the value mode
flag is in mode "default".'); |
| 124 output.removeChild(childNode); |
| 125 shouldBeEqualToString('output.defaultValue', 'defaultValue'); |
| 126 shouldBeEqualToString('output.value', 'aValue'); |
| 127 shouldBeEqualToString('output.innerText', 'aValue'); |
| 128 shouldBeEqualToString('output.innerHTML', 'aValue'); |
| 129 </script> |
| 8 </body> | 130 </body> |
| 9 </html> | 131 </html> |
| OLD | NEW |