| OLD | NEW |
| (Empty) |
| 1 description('Various tests for the hgroup element.'); | |
| 2 | |
| 3 var testParent = document.createElement('div'); | |
| 4 document.body.appendChild(testParent); | |
| 5 | |
| 6 debug('<hgroup> closes <p>:'); | |
| 7 testParent.innerHTML = '<p>Test that <hgroup id="hgroup1"><h1>a hgroup element</
h1></hgroup> closes <p>.</p>'; | |
| 8 var hgroup1 = document.getElementById('hgroup1'); | |
| 9 shouldBeFalse('hgroup1.parentNode.nodeName == "p"'); | |
| 10 | |
| 11 debug('<p> does not close <hgroup>:'); | |
| 12 testParent.innerHTML = '<hgroup>Test that <p id="p1">a p element</p> does not cl
ose a hgroup element.</hgroup>'; | |
| 13 var p1 = document.getElementById('p1'); | |
| 14 shouldBe('p1.parentNode.nodeName', '"HGROUP"'); | |
| 15 | |
| 16 // Note: hgroup *should* have only h1-h6 elements, but *can* have any elements. | |
| 17 debug('<hgroup> can be nested inside <hgroup>:'); | |
| 18 testParent.innerHTML = '<hgroup id="hgroup2">Test that <hgroup id="hgroup3">a hg
roup element</hgroup> can be nested inside another.</hgroup>'; | |
| 19 var hgroup3 = document.getElementById('hgroup3'); | |
| 20 shouldBe('hgroup3.parentNode.id', '"hgroup2"'); | |
| 21 | |
| 22 debug('Residual style:'); | |
| 23 testParent.innerHTML = '<b><hgroup id="hgroup4"><h2>This text should be bold.</h
2></hgroup> <span id="span1">This is also bold.</span></b>'; | |
| 24 function getWeight(id) { | |
| 25 return document.defaultView.getComputedStyle(document.getElementById(id), nu
ll).getPropertyValue('font-weight'); | |
| 26 } | |
| 27 shouldBe('getWeight("hgroup4")', '"bold"'); | |
| 28 shouldBe('getWeight("span1")', '"bold"'); | |
| 29 document.body.removeChild(testParent); | |
| 30 | |
| 31 debug('FormatBlock:'); | |
| 32 var editable = document.createElement('div'); | |
| 33 editable.innerHTML = '[<span id="span2">The text will be a child of <hgroup>.
</span>]'; | |
| 34 document.body.appendChild(editable); | |
| 35 editable.contentEditable = true; | |
| 36 var selection = window.getSelection(); | |
| 37 selection.selectAllChildren(editable); | |
| 38 document.execCommand('FormatBlock', false, 'hgroup'); | |
| 39 selection.removeAllRanges(); | |
| 40 shouldBe('document.getElementById("span2").parentNode.nodeName', '"HGROUP"'); | |
| 41 document.body.removeChild(editable); | |
| 42 | |
| OLD | NEW |