description('Various tests for the main element.'); var testParent = document.createElement('div'); document.body.appendChild(testParent); debug('<main> closes <p>:'); testParent.innerHTML = '

Test that

an main element
closes <p>.

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

a p element

does not close an main element.
'; var p1 = document.getElementById('p1'); shouldBe('p1.parentNode.nodeName', '"MAIN"'); debug('<main> can be nested inside <main>:'); testParent.innerHTML = '
Test that
an main element
can be nested inside another.
'; var main3 = document.getElementById('main3'); shouldBe('main3.parentNode.id', '"main2"'); debug('Residual style:'); testParent.innerHTML = '
This text should be bold.
This is also bold.
'; function getWeight(id) { return document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue('font-weight'); } shouldBe('getWeight("main4")', '"bold"'); shouldBe('getWeight("span1")', '"bold"'); document.body.removeChild(testParent); debug('FormatBlock:'); var editable = document.createElement('div'); editable.innerHTML = '[The text will be a child of <main>.]'; document.body.appendChild(editable); editable.contentEditable = true; var selection = window.getSelection(); selection.selectAllChildren(editable); document.execCommand('FormatBlock', false, 'main'); selection.removeAllRanges(); shouldBe('document.getElementById("span2").parentNode.nodeName', '"MAIN"'); document.body.removeChild(editable);