tkent@chromium.org | 410b391 | 2009-12-28 13:48:53 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 | <html> |
| 3 | <head> |
mark.lam@apple.com | 0f8554a | 2013-09-07 23:56:14 +0000 | [diff] [blame] | 4 | <script src="../../resources/js-test-pre.js"></script> |
tkent@chromium.org | 410b391 | 2009-12-28 13:48:53 +0000 | [diff] [blame] | 5 | </head> |
| 6 | <body> |
ap@apple.com | 92352d0 | 2017-05-24 22:53:00 +0000 | [diff] [blame] | 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 close 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.</article> <span id="span1">This is also bold.</span></b>'; |
| 30 | function getWeight(id) { |
| 31 | return document.defaultView.getComputedStyle(document.getElementById(id), null).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.collapse(null); |
| 46 | shouldBe('document.getElementById("span2").parentNode.nodeName', '"ARTICLE"'); |
| 47 | document.body.removeChild(editable); |
| 48 | |
| 49 | </script> |
mark.lam@apple.com | 0f8554a | 2013-09-07 23:56:14 +0000 | [diff] [blame] | 50 | <script src="../../resources/js-test-post.js"></script> |
tkent@chromium.org | 410b391 | 2009-12-28 13:48:53 +0000 | [diff] [blame] | 51 | </body> |
| 52 | </html> |