| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <script> |
| description('Various tests for the main element.'); |
| |
| var testParent = document.createElement('div'); |
| document.body.appendChild(testParent); |
| |
| debug('<main> closes <p>:'); |
| testParent.innerHTML = '<p>Test that <main id="main1">an main element</main> closes <p>.</p>'; |
| var main1 = document.getElementById('main1'); |
| shouldBeFalse('main1.parentNode.nodeName == "p"'); |
| |
| debug('<p> does not close <main>:'); |
| testParent.innerHTML = '<main>Test that <p id="p1">a p element</p> does not close an main element.</main>'; |
| var p1 = document.getElementById('p1'); |
| shouldBe('p1.parentNode.nodeName', '"MAIN"'); |
| |
| debug('<main> can be nested inside <main>:'); |
| testParent.innerHTML = '<main id="main2">Test that <main id="main3">an main element</main> can be nested inside another.</main>'; |
| var main3 = document.getElementById('main3'); |
| shouldBe('main3.parentNode.id', '"main2"'); |
| |
| debug('Residual style:'); |
| testParent.innerHTML = '<b><main id="main4">This text should be bold.</main> <span id="span1">This is also bold.</span></b>'; |
| function getWeight(id) { |
| return document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue('font-weight'); |
| } |
| shouldBe('getWeight("main4")', '"700"'); |
| shouldBe('getWeight("span1")', '"700"'); |
| document.body.removeChild(testParent); |
| |
| debug('FormatBlock:'); |
| var editable = document.createElement('div'); |
| editable.innerHTML = '[<span id="span2">The text will be a child of <main>.</span>]'; |
| document.body.appendChild(editable); |
| editable.contentEditable = true; |
| var selection = window.getSelection(); |
| selection.selectAllChildren(editable); |
| document.execCommand('FormatBlock', false, 'main'); |
| selection.collapse(null); |
| shouldBe('document.getElementById("span2").parentNode.nodeName', '"MAIN"'); |
| document.body.removeChild(editable); |
| |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |