getter-tests.js (29907B)
1 testText("<div>abc", "abc", "Simplest possible test"); 2 3 /**** white-space:normal ****/ 4 5 testText("<div> abc", "abc", "Leading whitespace removed"); 6 testText("<div>abc ", "abc", "Trailing whitespace removed"); 7 testText("<div>abc def", "abc def", "Internal whitespace compressed"); 8 testText("<div>abc\ndef", "abc def", "\\n converted to space"); 9 testText("<div>abc\rdef", "abc def", "\\r converted to space"); 10 testText("<div>abc\tdef", "abc def", "\\t converted to space"); 11 testText("<div>abc <br>def", "abc\ndef", "Trailing whitespace before hard line break removed"); 12 testText("<div>abc<br> def", "abc\ndef", "Leading whitespace after hard line break removed"); 13 14 /**** <pre> ****/ 15 16 testText("<pre> abc", " abc", "Leading whitespace preserved"); 17 testText("<pre>abc ", "abc ", "Trailing whitespace preserved"); 18 testText("<pre>abc def", "abc def", "Internal whitespace preserved"); 19 testText("<pre>abc\ndef", "abc\ndef", "\\n preserved"); 20 testText("<pre>abc\rdef", "abc\ndef", "\\r converted to newline"); 21 testText("<pre>abc\tdef", "abc\tdef", "\\t preserved"); 22 testText("<div><pre>abc</pre><pre>def</pre>", "abc\ndef", "Two <pre> siblings"); 23 24 /**** <div style="white-space:pre"> ****/ 25 26 testText("<div style='white-space:pre'> abc", " abc", "Leading whitespace preserved"); 27 testText("<div style='white-space:pre'>abc ", "abc ", "Trailing whitespace preserved"); 28 testText("<div style='white-space:pre'>abc def", "abc def", "Internal whitespace preserved"); 29 testText("<div style='white-space:pre'>abc\ndef", "abc\ndef", "\\n preserved"); 30 testText("<div style='white-space:pre'>abc\rdef", "abc\ndef", "\\r converted to newline"); 31 testText("<div style='white-space:pre'>abc\tdef", "abc\tdef", "\\t preserved"); 32 33 /**** <span style="white-space:pre"> ****/ 34 35 testText("<span style='white-space:pre'> abc", " abc", "Leading whitespace preserved"); 36 testText("<span style='white-space:pre'>abc ", "abc ", "Trailing whitespace preserved"); 37 testText("<span style='white-space:pre'>abc def", "abc def", "Internal whitespace preserved"); 38 testText("<span style='white-space:pre'>abc\ndef", "abc\ndef", "\\n preserved"); 39 testText("<span style='white-space:pre'>abc\rdef", "abc\ndef", "\\r converted to newline"); 40 testText("<span style='white-space:pre'>abc\tdef", "abc\tdef", "\\t preserved"); 41 42 /**** <div style="white-space:pre-line"> ****/ 43 44 testText("<div style='white-space:pre-line'> abc", "abc", "Leading whitespace removed"); 45 testText("<div style='white-space:pre-line'>abc ", "abc", "Trailing whitespace removed"); 46 testText("<div style='white-space:pre-line'>abc def", "abc def", "Internal whitespace collapsed"); 47 testText("<div style='white-space:pre-line'>abc\ndef", "abc\ndef", "\\n preserved"); 48 testText("<div style='white-space:pre-line'>abc\rdef", "abc\ndef", "\\r converted to newline"); 49 testText("<div style='white-space:pre-line'>abc\tdef", "abc def", "\\t converted to space"); 50 51 /**** Collapsing whitespace across element boundaries ****/ 52 53 testText("<div><span>abc </span> def", "abc def", "Whitespace collapses across element boundaries"); 54 testText("<div><span>abc </span><span></span> def", "abc def", "Whitespace collapses across element boundaries"); 55 testText("<div><span>abc </span><span style='white-space:pre'></span> def", "abc def", "Whitespace collapses across element boundaries"); 56 testText("<div>abc <input> def", "abc def", "Whitespace around <input> should not be collapsed"); 57 testText("<div>abc <span style='display:inline-block'></span> def", "abc def", "Whitespace around inline-block should not be collapsed"); 58 testText("<div>abc <span style='display:inline-block'> def </span> ghi", "abc def ghi", "Trailing space at end of inline-block should be collapsed"); 59 testText("<div>abc <span style='display:inline-flex'></span> def", "abc def", "Whitespace around inline-flex should not be collapsed"); 60 testText("<div>abc <span style='display:inline-flex'> def </span> ghi", "abc def ghi", "Trailing space at end of inline-flex should be collapsed"); 61 testText("<div>abc <span style='display:inline-grid'></span> def", "abc def", "Whitespace around inline-grid should not be collapsed"); 62 testText("<div>abc <span style='display:inline-grid'> def </span> ghi", "abc def ghi", "Trailing space at end of grid-flex should be collapsed"); 63 testText("<div><input> <div>abc</div>", "abc", "Whitespace between <input> and block should be collapsed"); 64 testText("<div><span style='inline-block'></span> <div>abc</div>", "abc", "Whitespace between inline-block and block should be collapsed"); 65 testText("<div><span style='inline-flex'></span> <div>abc</div>", "abc", "Whitespace between inline-flex and block should be collapsed"); 66 testText("<div><span style='inline-grid'></span> <div>abc</div>", "abc", "Whitespace between inline-grid and block should be collapsed"); 67 testText("<div>abc <img> def", "abc def", "Whitespace around <img> should not be collapsed"); 68 testText("<div>abc <img width=1 height=1> def", "abc def", "Whitespace around <img> should not be collapsed"); 69 testText("<div><img> abc", " abc", "Leading whitesapce should not be collapsed"); 70 testText("<div>abc <img>", "abc ", "Trailing whitesapce should not be collapsed"); 71 testText("<div>abc <b></b> def", "abc def", "Whitespace around empty span should be collapsed"); 72 testText("<div>abc <b><i></i></b> def", "abc def", "Whitespace around empty spans should be collapsed"); 73 testText("<div><canvas></canvas> abc", " abc", "<canvas> should not collapse following space"); 74 testText("<div>abc <img style='display:block'> def", "abc\ndef", "Replaced element <img> with display:block should be treated as block-level"); 75 testText("<div>abc <canvas style='display:block'></canvas> def", "abc\ndef", "Replaced element <canvas> with display:block should be treated as block-level"); 76 77 /**** Soft line breaks ****/ 78 79 testText("<div style='width:0'>abc def", "abc def", "Soft line breaks ignored"); 80 testText("<div style='width:0'>abc-def", "abc-def", "Soft line break at hyphen ignored"); 81 testText("<div style='width:0'><span>abc</span> <span>def</span>", "abc def", "Whitespace text node preserved"); 82 83 /**** Soft line breaks when word-break:break-word is in effect ****/ 84 /* (based on Testcase #2 at https://bugzilla.mozilla.org/show_bug.cgi?id=1241631) */ 85 86 testText("<div style='width:1px; word-break:break-word'>Hello Kitty</div>", "Hello Kitty", "Soft breaks ignored in presence of word-break:break-word"); 87 testText("<div style='width:1px; word-break:break-word'><x>Hello</x> <x>Kitty</x></div>", "Hello Kitty", "Element boundaries ignored for soft break handling (1)"); 88 testText("<div style='width:1px; word-break:break-word'><x>Hello</x> <x> Kitty</x></div>", "Hello Kitty", "Whitespace collapses across element boundaries at soft break (1)"); 89 testText("<div style='width:1px; word-break:break-word'><x>Hello</x><x> Kitty</x></div>", "Hello Kitty", "Element boundaries ignored for soft break handling (2)"); 90 testText("<div style='width:1px; word-break:break-word'><x>Hello </x> <x>Kitty</x></div>", "Hello Kitty", "Whitespace collapses across element boundaries at soft break (2)"); 91 testText("<div style='width:1px; word-break:break-word'><x>Hello </x><x>Kitty</x></div>", "Hello Kitty", "Element boundaries ignored for soft break handling (3)"); 92 testText("<div style='width:1px; word-break:break-word'><x>Hello </x><x> Kitty</x></div>", "Hello Kitty", "Whitespace collapses across element boundaries at soft break (3)"); 93 testText("<div style='width:1px; word-break:break-word'><x>Hello </x> <x> Kitty</x></div>", "Hello Kitty", "Whitespace collapses across element boundaries at soft break (4)"); 94 testText("<div style='width:1px; word-break:break-word'><x>Hello</x> Kitty</div>", "Hello Kitty", "Element boundaries ignored for soft break handling (4)"); 95 testText("<div style='width:1px; word-break:break-word'><x>Hello </x>Kitty</div>", "Hello Kitty", "Element boundaries ignored for soft break handling (5)"); 96 testText("<div style='width:1px; word-break:break-word; text-transform:uppercase'>Hello Kitty</div>", "HELLO KITTY", "Soft breaks ignored, text-transform applied"); 97 testText("<div style='width:1px; word-break:break-word'>Hello<br> Kitty</div>", "Hello\nKitty", "<br> returned as newline, following space collapsed"); 98 testText("<div style='width:1px; word-break:break-word'>Hello <br>Kitty</div>", "Hello\nKitty", "<br> returned as newline, preceding space collapsed"); 99 testText("<div style='width:1px; word-break:break-word'><x>Hello </x> <br> <x> Kitty</x></div>", "Hello\nKitty", "<br> returned as newline, adjacent spaces collapsed across element boundaries"); 100 101 /**** first-line/first-letter ****/ 102 103 testText("<div class='first-line-uppercase'>abc", "ABC", "::first-line styles applied"); 104 testText("<div class='first-line-uppercase' style='width:0'>abc def", "ABC def", "::first-line styles applied"); 105 testText("<div class='first-letter-uppercase' style='width:0'>abc def", "Abc def", "::first-letter styles applied"); 106 testText("<div class='first-letter-float' style='width:0'>abc def", "abc def", "::first-letter float ignored"); 107 108 /**** ****/ 109 110 testText("<div> ", "\xA0", " preserved"); 111 112 /**** display:none ****/ 113 114 testText("<div style='display:none'>abc", "abc", "display:none container"); 115 testText("<div style='display:none'>abc def", "abc def", "No whitespace compression in display:none container"); 116 testText("<div style='display:none'> abc def ", " abc def ", "No removal of leading/trailing whitespace in display:none container"); 117 testText("<div>123<span style='display:none'>abc", "123", "display:none child not rendered"); 118 testText("<div style='display:none'><span id='target'>abc", "abc", "display:none container with non-display-none target child"); 119 testTextInSVG("<div id='target'>abc", "abc", "non-display-none child of svg"); 120 testTextInSVG("<div style='display:none' id='target'>abc", "abc", "display:none child of svg"); 121 testTextInSVG("<div style='display:none'><div id='target'>abc", "abc", "child of display:none child of svg"); 122 123 /**** display:contents ****/ 124 125 if (CSS.supports("display", "contents")) { 126 testText("<div style='display:contents'>abc", "abc", "display:contents container"); 127 testText("<div><div style='display:contents'>abc", "abc", "display:contents container"); 128 testText("<div>123<span style='display:contents'>abc", "123abc", "display:contents rendered"); 129 testText("<div style='display:contents'> ", "", "display:contents not processed via textContent"); 130 testText("<div><div style='display:contents'> ", "", "display:contents not processed via textContent"); 131 } 132 133 /**** visibility:hidden ****/ 134 135 testText("<div style='visibility:hidden'>abc", "", "visibility:hidden container"); 136 testText("<div>123<span style='visibility:hidden'>abc", "123", "visibility:hidden child not rendered"); 137 testText("<div style='visibility:hidden'>123<span style='visibility:visible'>abc", "abc", "visibility:visible child rendered"); 138 139 /**** visibility:collapse ****/ 140 141 testText("<table><tbody style='visibility:collapse'><tr><td>abc", "", "visibility:collapse row-group"); 142 testText("<table><tr style='visibility:collapse'><td>abc", "", "visibility:collapse row"); 143 testText("<table><tr><td style='visibility:collapse'>abc", "", "visibility:collapse cell"); 144 testText("<table><tbody style='visibility:collapse'><tr><td style='visibility:visible'>abc", "abc", 145 "visibility:collapse row-group with visible cell"); 146 testText("<table><tr style='visibility:collapse'><td style='visibility:visible'>abc", "abc", 147 "visibility:collapse row with visible cell"); 148 testText("<div style='display:flex'><span style='visibility:collapse'>1</span><span>2</span></div>", 149 "2", "visibility:collapse honored on flex item"); 150 testText("<div style='display:grid'><span style='visibility:collapse'>1</span><span>2</span></div>", 151 "2", "visibility:collapse honored on grid item"); 152 153 /**** opacity:0 ****/ 154 155 testText("<div style='opacity:0'>abc", "abc", "opacity:0 container"); 156 testText("<div style='opacity:0'>abc def", "abc def", "Whitespace compression in opacity:0 container"); 157 testText("<div style='opacity:0'> abc def ", "abc def", "Remove leading/trailing whitespace in opacity:0 container"); 158 testText("<div>123<span style='opacity:0'>abc", "123abc", "opacity:0 child rendered"); 159 160 /**** generated content ****/ 161 162 testText("<div class='before'>", "", "Generated content not included"); 163 testText("<div><div class='before'>", "", "Generated content on child not included"); 164 165 /**** innerText on replaced elements ****/ 166 167 testText("<button>abc", "abc", "<button> contents preserved"); 168 testText("<fieldset>abc", "abc", "<fieldset> contents preserved"); 169 testText("<fieldset><legend>abc", "abc", "<fieldset> <legend> contents preserved"); 170 testText("<input type='text' value='abc'>", "", "<input> contents ignored"); 171 testText("<textarea>abc", "", "<textarea> contents ignored"); 172 testText("<iframe>abc", "", "<iframe> contents ignored"); 173 testText("<iframe><div id='target'>abc", "", "<iframe> contents ignored"); 174 testText("<iframe src='data:text/html,abc'>", "","<iframe> subdocument ignored"); 175 testText("<audio style='display:block'>abc", "", "<audio> contents ignored"); 176 testText("<audio style='display:block'><source id='target' class='poke' style='display:block'>", "abc", "<audio> contents ok for element not being rendered"); 177 testText("<audio style='display:block'><source id='target' class='poke' style='display:none'>", "abc", "<audio> contents ok for element not being rendered"); 178 testText("<video>abc", "", "<video> contents ignored"); 179 testText("<video style='display:block'><source id='target' class='poke' style='display:block'>", "abc", "<video> contents ok for element not being rendered"); 180 testText("<video style='display:block'><source id='target' class='poke' style='display:none'>", "abc", "<video> contents ok for element not being rendered"); 181 testText("<canvas>abc", "", "<canvas> contents ignored"); 182 testText("<canvas><div id='target'>abc", "abc", "<canvas><div id='target'> contents ok for element not being rendered"); 183 testText("<img alt='abc'>", "", "<img> alt text ignored"); 184 testText("<img src='about:blank' class='poke'>", "", "<img> contents ignored"); 185 testText("<div><svg><text>abc</text></svg></div>", "abc", "<svg> text contents preserved"); 186 testText("<div><svg><defs><text>abc</text></defs></svg></div>", "", "<svg><defs> text contents ignored"); 187 testText("<div><svg><stop>abc</stop></svg></div>", "", "<svg> non-rendered text ignored"); 188 testText("<svg><foreignObject><span id='target'>abc</span></foreignObject></svg>", "abc", "<foreignObject> contents preserved"); 189 190 /**** <select>, <optgroup> & <option> ****/ 191 192 testText("<select size='1'><option>abc</option><option>def", "abc\ndef", "<select size='1'> contents of options preserved"); 193 testText("<select size='2'><option>abc</option><option>def", "abc\ndef", "<select size='2'> contents of options preserved"); 194 testText("<select size='1'><option id='target'>abc</option><option>def", "abc", "<select size='1'> contents of target option preserved"); 195 testText("<select size='2'><option id='target'>abc</option><option>def", "abc", "<select size='2'> contents of target option preserved"); 196 testText("<div>a<select></select>bc", "abc", "empty <select>"); 197 testText("<div>a<select><optgroup></select>bc", "a\nbc", "empty <optgroup> in <select>"); 198 testText("<div>a<select><option></select>bc", "a\nbc", "empty <option> in <select>"); 199 testText("<select class='poke'></select>", "", "<select> containing text node child"); 200 testText("<select><optgroup class='poke-optgroup'></select>", "", "<optgroup> containing <optgroup>"); 201 testText("<select><optgroup><option>abc</select>", "abc", "<optgroup> containing <option>"); 202 testText("<select><option class='poke-div'>123</select>", "123\nabc", "<div> in <option>"); 203 testText("<div>a<optgroup></optgroup>bc", "a\nbc", "empty <optgroup> in <div>"); 204 testText("<div>a<optgroup>123</optgroup>bc", "a\nbc", "<optgroup> in <div>"); 205 testText("<div>a<option></option>bc", "a\nbc", "empty <option> in <div>"); 206 testText("<div>a<option>123</option>bc", "a\n123\nbc", "<option> in <div>"); 207 testText("<select><option>one</option><div><optgroup label=optgroup><div><option><span>two", "one\ntwo"); 208 209 /**** innerText on replaced element children ****/ 210 211 testText("<div><button>abc", "abc", "<button> contents preserved"); 212 testText("<div><fieldset>abc", "abc", "<fieldset> contents preserved"); 213 testText("<div><fieldset><legend>abc", "abc", "<fieldset> <legend> contents preserved"); 214 testText("<div><input type='text' value='abc'>", "", "<input> contents ignored"); 215 testText("<div><textarea>abc", "", "<textarea> contents ignored"); 216 testText("<div><select size='1'><option>abc</option><option>def", "abc\ndef", "<select size='1'> contents of options preserved"); 217 testText("<div><select size='2'><option>abc</option><option>def", "abc\ndef", "<select size='2'> contents of options preserved"); 218 testText("<div><iframe>abc", "", "<iframe> contents ignored"); 219 testText("<div><iframe src='data:text/html,abc'>", ""," <iframe> subdocument ignored"); 220 testText("<div><audio>abc", "", "<audio> contents ignored"); 221 testText("<div><video>abc", "", "<video> contents ignored"); 222 testText("<div><canvas>abc", "", "<canvas> contents ignored"); 223 testText("<div><object>abc", "", "<object> contents ignored"); 224 testText("<div><img alt='abc'>", "", "<img> alt text ignored"); 225 226 /**** Lines around blocks ****/ 227 228 testText("<div>123<div>abc</div>def", "123\nabc\ndef", "Newline at block boundary"); 229 testText("<div>123<span style='display:block'>abc</span>def", "123\nabc\ndef", "Newline at display:block boundary"); 230 testText("<div>abc<div></div>def", "abc\ndef", "Empty block induces single line break"); 231 testText("<div>abc<div></div><div></div>def", "abc\ndef", "Consecutive empty blocks ignored"); 232 testText("<div><p>abc", "abc", "No blank lines around <p> alone"); 233 testText("<div><p>abc</p> ", "abc", "No blank lines around <p> followed by only collapsible whitespace"); 234 testText("<div> <p>abc</p>", "abc", "No blank lines around <p> preceded by only collapsible whitespace"); 235 testText("<div><p>abc<p>def", "abc\n\ndef", "Blank line between consecutive <p>s"); 236 testText("<div><p>abc</p> <p>def", "abc\n\ndef", "Blank line between consecutive <p>s separated only by collapsible whitespace"); 237 testText("<div><p>abc</p><div></div><p>def", "abc\n\ndef", "Blank line between consecutive <p>s separated only by empty block"); 238 testText("<div><p>abc</p><div>123</div><p>def", "abc\n\n123\n\ndef", "Blank lines between <p>s separated by non-empty block"); 239 testText("<div>abc<div><p>123</p></div>def", "abc\n\n123\n\ndef", "Blank lines around a <p> in its own block"); 240 testText("<div>abc<p>def", "abc\n\ndef", "Blank line before <p>"); 241 testText("<div><p>abc</p>def", "abc\n\ndef", "Blank line after <p>"); 242 testText("<div><p>abc<p></p><p></p><p>def", "abc\n\ndef", "One blank line between <p>s, ignoring empty <p>s"); 243 testText("<div style='visibility:hidden'><p><span style='visibility:visible'>abc</span></p>\n<div style='visibility:visible'>def</div>", 244 "abc\ndef", "Invisible <p> doesn't induce extra line breaks"); 245 testText("<div>abc<div style='margin:2em'>def", "abc\ndef", "No blank lines around <div> with margin"); 246 testText("<div>123<span style='display:inline-block'>abc</span>def", "123abcdef", "No newlines at display:inline-block boundary"); 247 testText("<div>123<span style='display:inline-block'> abc </span>def", "123abcdef", "Leading/trailing space removal at display:inline-block boundary"); 248 testText("<div>123<span style='display:inline-flex'> abc </span>def", "123abcdef", "Leading/trailing space removal at display:inline-flex boundary"); 249 testText("<div>123<span style='display:inline-grid'> abc </span>def", "123abcdef", "Leading/trailing space removal at display:inline-grid boundary"); 250 testText("<div>123<p style='margin:0px'>abc</p>def", "123\n\nabc\n\ndef", "Blank lines around <p> even without margin"); 251 testText("<div>123<h1>abc</h1>def", "123\nabc\ndef", "No blank lines around <h1>"); 252 testText("<div>123<h2>abc</h2>def", "123\nabc\ndef", "No blank lines around <h2>"); 253 testText("<div>123<h3>abc</h3>def", "123\nabc\ndef", "No blank lines around <h3>"); 254 testText("<div>123<h4>abc</h4>def", "123\nabc\ndef", "No blank lines around <h4>"); 255 testText("<div>123<h5>abc</h5>def", "123\nabc\ndef", "No blank lines around <h5>"); 256 testText("<div>123<h6>abc</h6>def", "123\nabc\ndef", "No blank lines around <h6>"); 257 testText("<div>123<p style='display:block'>abc", "123\n\nabc", "2 blank lines around <p> even when display:block"); 258 testText("<div>123<p style='display:inline-block'>abc", "123\n\nabc", "2 blank lines around <p> even when display:inline-block"); 259 260 /**** Spans ****/ 261 262 testText("<div>123<span>abc</span>def", "123abcdef", "<span> boundaries are irrelevant"); 263 testText("<div>123 <span>abc</span> def", "123 abc def", "<span> boundaries are irrelevant"); 264 testText("<div style='width:0'>123 <span>abc</span> def", "123 abc def", "<span> boundaries are irrelevant"); 265 testText("<div>123<em>abc</em>def", "123abcdef", "<em> gets no special treatment"); 266 testText("<div>123<b>abc</b>def", "123abcdef", "<b> gets no special treatment"); 267 testText("<div>123<i>abc</i>def", "123abcdef", "<i> gets no special treatment"); 268 testText("<div>123<strong>abc</strong>def", "123abcdef", "<strong> gets no special treatment"); 269 testText("<div>123<tt>abc</tt>def", "123abcdef", "<tt> gets no special treatment"); 270 testText("<div>123<code>abc</code>def", "123abcdef", "<code> gets no special treatment"); 271 272 /**** Soft hyphen ****/ 273 274 testText("<div>abc­def", "abc\xADdef", "soft hyphen preserved"); 275 testText("<div style='width:0'>abc­def", "abc\xADdef", "soft hyphen preserved"); 276 277 /**** Tables ****/ 278 279 testText("<div><table style='white-space:pre'> <td>abc</td> </table>", "abc", "Ignoring non-rendered table whitespace"); 280 testText("<div><table><tr><td>abc<td>def</table>", "abc\tdef", "Tab-separated table cells"); 281 testText("<div><table><tr><td>abc<td><td>def</table>", "abc\t\tdef", "Tab-separated table cells including empty cells"); 282 testText("<div><table><tr><td>abc<td><td></table>", "abc\t\t", "Tab-separated table cells including trailing empty cells"); 283 testText("<div><table><tr><td>abc<tr><td>def</table>", "abc\ndef", "Newline-separated table rows"); 284 testText("<div>abc<table><td>def</table>ghi", "abc\ndef\nghi", "Newlines around table"); 285 testText("<div><table style='border-collapse:collapse'><tr><td>abc<td>def</table>", "abc\tdef", 286 "Tab-separated table cells in a border-collapse table"); 287 testText("<div><table><tfoot>x</tfoot><tbody>y</tbody></table>", "xy", "tfoot not reordered"); 288 testText("<table><tfoot><tr><td>footer</tfoot><thead><tr><td style='visibility:collapse'>thead</thead><tbody><tr><td>tbody</tbody></table>", 289 "footer\n\ntbody", ""); 290 testText("<table><tr><td id=target>abc</td><td>def</td>", "abc", "No tab on table-cell itself"); 291 testText("<table><tr id=target><td>abc</td><td>def</td></tr><tr id=target><td>ghi</td><td>jkl</td></tr>", "abc\tdef", "No newline on table-row itself"); 292 293 /**** Table captions ****/ 294 295 testText("<div><table><tr><td>abc<caption>def</caption></table>", "abc\ndef", "Newline between cells and caption"); 296 297 /**** display:table ****/ 298 299 testText("<div><div class='table'><span class='cell'>abc</span>\n<span class='cell'>def</span></div>", 300 "abc\tdef", "Tab-separated table cells"); 301 testText("<div><div class='table'><span class='row'><span class='cell'>abc</span></span>\n<span class='row'><span class='cell'>def</span></span></div>", 302 "abc\ndef", "Newline-separated table rows"); 303 testText("<div>abc<div class='table'><span class='cell'>def</span></div>ghi", "abc\ndef\nghi", "Newlines around table"); 304 305 /**** display:inline-table ****/ 306 307 testText("<div><div class='itable'><span class='cell'>abc</span>\n<span class='cell'>def</span></div>", "abc\tdef", "Tab-separated table cells"); 308 testText("<div><div class='itable'><span class='row'><span class='cell'>abc</span></span>\n<span class='row'><span class='cell'>def</span></span></div>", 309 "abc\ndef", "Newline-separated table rows"); 310 testText("<div>abc<div class='itable'><span class='cell'>def</span></div>ghi", "abcdefghi", "No newlines around inline-table"); 311 testText("<div>abc<div class='itable'><span class='row'><span class='cell'>def</span></span>\n<span class='row'><span class='cell'>123</span></span></div>ghi", 312 "abcdef\n123ghi", "Single newline in two-row inline-table"); 313 314 /**** display:table-row/table-cell/table-caption ****/ 315 testText("<div style='display:table-row'>", "", "display:table-row on the element itself"); 316 testText("<div style='display:table-cell'>", "", "display:table-cell on the element itself"); 317 testText("<div style='display:table-caption'>", "", "display:table-caption on the element itself"); 318 319 /**** Lists ****/ 320 321 testText("<div><ol><li>abc", "abc", "<ol> list items get no special treatment"); 322 testText("<div><ul><li>abc", "abc", "<ul> list items get no special treatment"); 323 324 /**** Misc elements ****/ 325 326 testText("<div><script style='display:block'>abc", "abc", "display:block <script> is rendered"); 327 testText("<div><style style='display:block'>abc", "abc", "display:block <style> is rendered"); 328 testText("<div><noscript style='display:block'>abc", "", "display:block <noscript> is not rendered (it's not parsed!)"); 329 testText("<div><template style='display:block'>abc", "", 330 "display:block <template> contents are not rendered (the contents are in a different document)"); 331 testText("<div>abc<br>def", "abc\ndef", "<br> induces line break"); 332 testText("<div>abc<br>", "abc\n", "<br> induces line break even at end of block"); 333 testText("<div><br class='poke'>", "\n", "<br> content ignored"); 334 testText("<div>abc<hr>def", "abc\ndef", "<hr> induces line break"); 335 testText("<div>abc<hr><hr>def", "abc\ndef", "<hr><hr> induces just one line break"); 336 testText("<div>abc<hr><hr><hr>def", "abc\ndef", "<hr><hr><hr> induces just one line break"); 337 testText("<div><hr class='poke'>", "abc", "<hr> content rendered"); 338 testText("<div>abc<!--comment-->def", "abcdef", "comment ignored"); 339 testText("<br>", "", "<br>"); 340 testText("<p>", "", "empty <p>"); 341 testText("<div>", "", "empty <div>"); 342 testText("<div><details><summary>abc</summary>123", "abc", "unopened <details> ignored"); 343 testText("<div><details open><summary>abc</summary>123", "abc\n123", "opened <details> content shown"); 344 345 /**** text-transform ****/ 346 347 testText("<div><div style='text-transform:uppercase'>abc", "ABC", "text-transform is applied"); 348 testText("<div><div style='text-transform:uppercase'>Ma\xDF", "MASS", "text-transform handles es-zet"); 349 testText("<div><div lang='tr' style='text-transform:uppercase'>i \u0131", "\u0130 I", "text-transform handles Turkish casing"); 350 351 /**** block-in-inline ****/ 352 353 testText("<div>abc<span>123<div>456</div>789</span>def", "abc123\n456\n789def", "block-in-inline doesn't add unnecessary newlines"); 354 355 /**** floats ****/ 356 357 testText("<div>abc<div style='float:left'>123</div>def", "abc\n123\ndef", "floats induce a block boundary"); 358 testText("<div>abc<span style='float:left'>123</span>def", "abc\n123\ndef", "floats induce a block boundary"); 359 testText("<div style='float:left'>123", "123", "float on the element itself"); 360 361 /**** position ****/ 362 363 testText("<div>abc<div style='position:absolute'>123</div>def", "abc\n123\ndef", "position:absolute induces a block boundary"); 364 testText("<div>abc<span style='position:absolute'>123</span>def", "abc\n123\ndef", "position:absolute induces a block boundary"); 365 testText("<div style='position:absolute'>123", "123", "position:absolute on the element itself"); 366 testText("<div>abc<div style='position:relative'>123</div>def", "abc\n123\ndef", "position:relative has no effect"); 367 testText("<div>abc<span style='position:relative'>123</span>def", "abc123def", "position:relative has no effect"); 368 369 /**** text-overflow:ellipsis ****/ 370 371 testText("<div style='overflow:hidden'>abc", "abc", "overflow:hidden ignored"); 372 // XXX Chrome skips content with width:0 or height:0 and overflow:hidden; 373 // should we spec that? 374 testText("<div style='width:0; overflow:hidden'>abc", "abc", "overflow:hidden ignored even with zero width"); 375 testText("<div style='height:0; overflow:hidden'>abc", "abc", "overflow:hidden ignored even with zero height"); 376 testText("<div style='width:0; overflow:hidden; text-overflow:ellipsis'>abc", "abc", "text-overflow:ellipsis ignored"); 377 378 /**** Support on non-HTML elements ****/ 379 380 testText("<svg>abc", undefined, "innerText not supported on SVG elements"); 381 testText("<math>abc", undefined, "innerText not supported on MathML elements"); 382 383 /**** Ruby ****/ 384 385 testText("<div><ruby>abc<rt>def</rt></ruby>", "abcdef", "<rt> and no <rp>"); 386 testText("<div><ruby>abc<rp>(</rp><rt>def</rt><rp>)</rp></ruby>", "abcdef", "<rp>"); 387 testText("<div><rp>abc</rp>", "", "Lone <rp>"); 388 testText("<div><rp style='visibility:hidden'>abc</rp>", "", "visibility:hidden <rp>"); 389 testText("<div><rp style='display:block'>abc</rp>def", "abc\ndef", "display:block <rp>"); 390 testText("<div><rp style='display:block'> abc </rp>def", "abc\ndef", "display:block <rp> with whitespace"); 391 testText("<div><select class='poke-rp'></select>", "", "<rp> in a <select>"); 392 393 /**** Shadow DOM ****/ 394 395 if ("attachShadow" in document.body) { 396 testText("<div class='shadow'>", "", "Shadow DOM contents ignored"); 397 testText("<div><div class='shadow'>", "", "Shadow DOM contents ignored"); 398 } 399 400 /**** Flexbox ****/ 401 402 if (CSS.supports('display', 'flex')) { 403 testText("<div style='display:flex'><div style='order:1'>1</div><div>2</div></div>", 404 "1\n2", "CSS 'order' property ignored"); 405 testText("<div style='display:flex'><span>1</span><span>2</span></div>", 406 "1\n2", "Flex items blockified"); 407 } 408 409 /**** Grid ****/ 410 411 if (CSS.supports('display', 'grid')) { 412 testText("<div style='display:grid'><div style='order:1'>1</div><div>2</div></div>", 413 "1\n2", "CSS 'order' property ignored"); 414 testText("<div style='display:grid'><span>1</span><span>2</span></div>", 415 "1\n2", "Grid items blockified"); 416 }