| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script> | |
| 8 description('Various tests for the section element.'); | |
| 9 | |
| 10 var testParent = document.createElement('div'); | |
| 11 document.body.appendChild(testParent); | |
| 12 | |
| 13 debug('<section> closes <p>:'); | |
| 14 testParent.innerHTML = '<p>Test that <section id="section1">a section element</s
ection> closes <p>.</p>'; | |
| 15 var section1 = document.getElementById('section1'); | |
| 16 shouldBeFalse('section1.parentNode.nodeName == "p"'); | |
| 17 | |
| 18 debug('<p> does not close <section>:'); | |
| 19 testParent.innerHTML = '<section>Test that <p id="p1">a p element</p> does not c
lose a section element.</section>'; | |
| 20 var p1 = document.getElementById('p1'); | |
| 21 shouldBe('p1.parentNode.nodeName', '"SECTION"'); | |
| 22 | |
| 23 debug('<section> can be nested inside <section>:'); | |
| 24 testParent.innerHTML = '<section id="section2">Test that <section id="section3">
a section element</section> can be nested inside another.</section>'; | |
| 25 var section3 = document.getElementById('section3'); | |
| 26 shouldBe('section3.parentNode.id', '"section2"'); | |
| 27 | |
| 28 debug('Residual style:'); | |
| 29 testParent.innerHTML = '<b><section id="section4">This text should be bold.</sec
tion> <span id="span1">This is also bold.</span></b>'; | |
| 30 function getWeight(id) { | |
| 31 return document.defaultView.getComputedStyle(document.getElementById(id), nu
ll).getPropertyValue('font-weight'); | |
| 32 } | |
| 33 shouldBe('getWeight("section4")', '"bold"'); | |
| 34 shouldBe('getWeight("span1")', '"bold"'); | |
| 35 document.body.removeChild(testParent); | |
| 36 | |
| 37 debug('FormatBlock:'); | |
| 38 var editable = document.createElement('div'); | |
| 39 editable.innerHTML = '[<span id="span2">The text will be a child of <section>
.</span>]'; | |
| 40 document.body.appendChild(editable); | |
| 41 editable.contentEditable = true; | |
| 42 var selection = window.getSelection(); | |
| 43 selection.selectAllChildren(editable); | |
| 44 document.execCommand('FormatBlock', false, 'section'); | |
| 45 selection.removeAllRanges(); | |
| 46 shouldBe('document.getElementById("span2").parentNode.nodeName', '"SECTION"'); | |
| 47 document.body.removeChild(editable); | |
| 48 | |
| 49 </script> | |
| 50 </body> | |
| 51 </html> | |
| OLD | NEW |