description('Various tests for the figcaption element.'); function getStyleValue(id, propertyName) { return document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue(propertyName); } var testParent = document.createElement('div'); document.body.appendChild(testParent); debug('<figcaption> default styling:'); testParent.innerHTML = '
element'; var emSize = getStyleValue("figcaption0","font-size"); shouldBe('getStyleValue("figcaption0","display")', '"block"'); debug('<figcaption> closes <p>:'); testParent.innerHTML = '

Test that

a figcaption element
closes <p>.

'; var figcaption1 = document.getElementById('figcaption1'); shouldBeFalse('figcaption1.parentNode.nodeName == "p"'); debug('<p> does not close <figcaption>:'); testParent.innerHTML = '
Test that

a p element

does not close a figcaption element.
'; var p1 = document.getElementById('p1'); shouldBe('p1.parentNode.nodeName', '"FIGCAPTION"'); debug('<figcaption> can be nested inside <figcaption> or <footer>:'); testParent.innerHTML = '
Test that
a figcaption element
can be nested inside another figcaption element.
'; var figcaption3 = document.getElementById('figcaption3'); shouldBe('figcaption3.parentNode.id', '"figcaption2"'); testParent.innerHTML = ''; var figcaption5 = document.getElementById('figcaption5'); shouldBe('figcaption5.parentNode.id', '"footer1"'); debug('Residual style:'); testParent.innerHTML = '
This text should be bold.
This is also bold.
'; shouldBe('getStyleValue("figcaption4","font-weight")', '"bold"'); shouldBe('getStyleValue("span1","font-weight")', '"bold"'); document.body.removeChild(testParent);