| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/article-element.js"></script> | 7 <script> |
| 8 description('Various tests for the article element.'); |
| 9 |
| 10 var testParent = document.createElement('div'); |
| 11 document.body.appendChild(testParent); |
| 12 |
| 13 debug('<article> closes <p>:'); |
| 14 testParent.innerHTML = '<p>Test that <article id="article1">an article element</
article> closes <p>.</p>'; |
| 15 var article1 = document.getElementById('article1'); |
| 16 shouldBeFalse('article1.parentNode.nodeName == "p"'); |
| 17 |
| 18 debug('<p> does not close <article>:'); |
| 19 testParent.innerHTML = '<article>Test that <p id="p1">a p element</p> does not c
lose an article element.</article>'; |
| 20 var p1 = document.getElementById('p1'); |
| 21 shouldBe('p1.parentNode.nodeName', '"ARTICLE"'); |
| 22 |
| 23 debug('<article> can be nested inside <article>:'); |
| 24 testParent.innerHTML = '<article id="article2">Test that <article id="article3">
an article element</article> can be nested inside another.</article>'; |
| 25 var article3 = document.getElementById('article3'); |
| 26 shouldBe('article3.parentNode.id', '"article2"'); |
| 27 |
| 28 debug('Residual style:'); |
| 29 testParent.innerHTML = '<b><article id="article4">This text should be bold.</art
icle> <span id="span1">This is also bold.</span></b>'; |
| 30 function getWeight(id) { |
| 31 return document.defaultView.getComputedStyle(document.getElementById(id), nu
ll).getPropertyValue('font-weight'); |
| 32 } |
| 33 shouldBe('getWeight("article4")', '"bold"'); |
| 34 shouldBe('getWeight("span1")', '"bold"'); |
| 35 document.body.removeChild(testParent); |
| 36 |
| 37 debug('FormatBlock:'); |
| 38 var editable = document.createElement('div'); |
| 39 editable.innerHTML = '[<span id="span2">The text will be a child of <article>
.</span>]'; |
| 40 document.body.appendChild(editable); |
| 41 editable.contentEditable = true; |
| 42 var selection = window.getSelection(); |
| 43 selection.selectAllChildren(editable); |
| 44 document.execCommand('FormatBlock', false, 'article'); |
| 45 selection.removeAllRanges(); |
| 46 shouldBe('document.getElementById("span2").parentNode.nodeName', '"ARTICLE"'); |
| 47 document.body.removeChild(editable); |
| 48 |
| 49 </script> |
| 8 </body> | 50 </body> |
| 9 </html> | 51 </html> |
| OLD | NEW |