summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/start-tag-body.html
blob: 738c86106a90c8af32257d0c8901374c1c7bd46f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<head>
<title>HTML Templates: In body insertion mode: Template contains a start tag whose tag name is body</title>
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<meta name="assert" content="If the stack of open elements has a template element in html scope then ignore <body> the token. (fragment or template contents case)">
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#in-body-addition">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/resources/common.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">


test(function () {
    var doc = newHTMLDocument();

    doc.body.innerHTML = '<template id="tmpl"><body></template>';

    var template = doc.querySelector('#tmpl');

    assert_equals(template.content.childNodes.length, 0, 'Element must be ignored');

}, 'In body insertion mode: Template contains a start tag whose tag name is body.'
    + 'Test <body> tag only');



test(function () {
    var doc = newHTMLDocument();

    doc.body.innerHTML = '<template id="tmpl"><body>Body text content</body></template>';

    var template = doc.querySelector('#tmpl');

    assert_equals(template.content.querySelector('body'), null,
            '<body> element must be ignored');
    assert_equals(template.content.childNodes.length, 1, 'Text shouldn\'t be ignored');
    assert_equals(template.content.firstChild.nodeType, Node.TEXT_NODE,
            'Text shouldn\'t be ignored');

}, 'In body insertion mode: Template contains a start tag whose tag name is body. '
    + 'Test <body> tag containing some text');



test(function () {
    var doc = newHTMLDocument();

    doc.body.innerHTML = '<template id="tmpl"><body>'
        + '<div id="div1">DIV 1</div>'
        + '<div id="div2">DIV 2</div>'
        + '</body></template>';

    var template = doc.querySelector('#tmpl');

    assert_equals(template.content.querySelector('body'), null,
            '<body> element must be ignored');
    assert_equals(template.content.childNodes.length, 2,
            'Only body tag should be ignored');
    assert_not_equals(template.content.querySelector('#div1'), null,
            'Children of <body tag shouldn\'t be ignored');
    assert_not_equals(template.content.querySelector('#div2'), null,
            'Children of <body tag shouldn\'t be ignored');

}, 'In body insertion mode: Template contains a start tag whose tag name is body. '
    + 'Test <body> tag containing some other elements');



test(function () {
    var doc = newHTMLDocument();

    doc.body.innerHTML = '<template id="tmpl1"><template id="tmpl2"><body>'
        + '<div id="div1">DIV 1</div>'
        + '<div id="div2">DIV 2</div>'
        + '</body></template></template>';

    var template = doc.querySelector('#tmpl1').content.querySelector('#tmpl2');

    assert_equals(template.content.querySelector('body'), null,
            '<body> element must be ignored');
    assert_equals(template.content.childNodes.length, 2,
            'Only body tag should be ignored');
    assert_not_equals(template.content.querySelector('#div1'), null,
            'Children of <body tag shouldn\'t be ignored');
    assert_not_equals(template.content.querySelector('#div2'), null,
            'Children of <body tag shouldn\'t be ignored');

}, 'In body insertion mode: Template contains a start tag whose tag name is body. '
    + 'Test nested template tag containing <body> tag with some other elements');

</script>
</body>
</html>