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