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