blob: 8c9b655838756b6d3c8418908b1485e9a90c0024 [file] [log] [blame]
tkent@chromium.org410b3912009-12-28 13:48:53 +00001<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html>
3<head>
mark.lam@apple.com0f8554a2013-09-07 23:56:14 +00004<script src="../../resources/js-test-pre.js"></script>
tkent@chromium.org410b3912009-12-28 13:48:53 +00005</head>
6<body>
ap@apple.com92352d02017-05-24 22:53:00 +00007<script>
8description('Various tests for the article element.');
9
10var testParent = document.createElement('div');
11document.body.appendChild(testParent);
12
13debug('&lt;article> closes &lt;p>:');
14testParent.innerHTML = '<p>Test that <article id="article1">an article element</article> closes &lt;p>.</p>';
15var article1 = document.getElementById('article1');
16shouldBeFalse('article1.parentNode.nodeName == "p"');
17
18debug('&lt;p> does not close &lt;article>:');
19testParent.innerHTML = '<article>Test that <p id="p1">a p element</p> does not close an article element.</article>';
20var p1 = document.getElementById('p1');
21shouldBe('p1.parentNode.nodeName', '"ARTICLE"');
22
23debug('&lt;article> can be nested inside &lt;article>:');
24testParent.innerHTML = '<article id="article2">Test that <article id="article3">an article element</article> can be nested inside another.</article>';
25var article3 = document.getElementById('article3');
26shouldBe('article3.parentNode.id', '"article2"');
27
28debug('Residual style:');
29testParent.innerHTML = '<b><article id="article4">This text should be bold.</article> <span id="span1">This is also bold.</span></b>';
30function getWeight(id) {
31 return document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue('font-weight');
32}
33shouldBe('getWeight("article4")', '"bold"');
34shouldBe('getWeight("span1")', '"bold"');
35document.body.removeChild(testParent);
36
37debug('FormatBlock:');
38var editable = document.createElement('div');
39editable.innerHTML = '[<span id="span2">The text will be a child of &lt;article>.</span>]';
40document.body.appendChild(editable);
41editable.contentEditable = true;
42var selection = window.getSelection();
43selection.selectAllChildren(editable);
44document.execCommand('FormatBlock', false, 'article');
45selection.collapse(null);
46shouldBe('document.getElementById("span2").parentNode.nodeName', '"ARTICLE"');
47document.body.removeChild(editable);
48
49</script>
mark.lam@apple.com0f8554a2013-09-07 23:56:14 +000050<script src="../../resources/js-test-post.js"></script>
tkent@chromium.org410b3912009-12-28 13:48:53 +000051</body>
52</html>