description('Various tests for the article element.');
var testParent = document.createElement('div');
document.body.appendChild(testParent);
debug('<article> closes <p>:');
testParent.innerHTML = '
Test that an article element closes <p>.
';
var article1 = document.getElementById('article1');
shouldBeFalse('article1.parentNode.nodeName == "p"');
debug('<p> does not close <article>:');
testParent.innerHTML = 'Test that a p element
does not close an article element.';
var p1 = document.getElementById('p1');
shouldBe('p1.parentNode.nodeName', '"ARTICLE"');
debug('<article> can be nested inside <article>:');
testParent.innerHTML = 'Test that an article element can be nested inside another.';
var article3 = document.getElementById('article3');
shouldBe('article3.parentNode.id', '"article2"');
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("article4")', '"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 <article>.]';
document.body.appendChild(editable);
editable.contentEditable = true;
var selection = window.getSelection();
selection.selectAllChildren(editable);
document.execCommand('FormatBlock', false, 'article');
selection.removeAllRanges();
shouldBe('document.getElementById("span2").parentNode.nodeName', '"ARTICLE"');
document.body.removeChild(editable);