Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / html / script-tests / article-element.js
1 description('Various tests for the article element.');
2
3 var testParent = document.createElement('div');
4 document.body.appendChild(testParent);
5
6 debug('<article> closes <p>:');
7 testParent.innerHTML = '<p>Test that <article id="article1">an article element</article> closes &lt;p>.</p>';
8 var article1 = document.getElementById('article1');
9 shouldBeFalse('article1.parentNode.nodeName == "p"');
10
11 debug('&lt;p> does not close &lt;article>:');
12 testParent.innerHTML = '<article>Test that <p id="p1">a p element</p> does not close an article element.</article>';
13 var p1 = document.getElementById('p1');
14 shouldBe('p1.parentNode.nodeName', '"ARTICLE"');
15
16 debug('&lt;article> can be nested inside &lt;article>:');
17 testParent.innerHTML = '<article id="article2">Test that <article id="article3">an article element</article> can be nested inside another.</article>';
18 var article3 = document.getElementById('article3');
19 shouldBe('article3.parentNode.id', '"article2"');
20
21 debug('Residual style:');
22 testParent.innerHTML = '<b><article id="article4">This text should be bold.</article> <span id="span1">This is also bold.</span></b>';
23 function getWeight(id) {
24     return document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue('font-weight');
25 }
26 shouldBe('getWeight("article4")', '"bold"');
27 shouldBe('getWeight("span1")', '"bold"');
28 document.body.removeChild(testParent);
29
30 debug('FormatBlock:');
31 var editable = document.createElement('div');
32 editable.innerHTML = '[<span id="span2">The text will be a child of &lt;article>.</span>]';
33 document.body.appendChild(editable);
34 editable.contentEditable = true;
35 var selection = window.getSelection();
36 selection.selectAllChildren(editable);
37 document.execCommand('FormatBlock', false, 'article');
38 selection.removeAllRanges();
39 shouldBe('document.getElementById("span2").parentNode.nodeName', '"ARTICLE"');
40 document.body.removeChild(editable);
41