Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / w3c / web-platform-tests / html-templates / additions-to-the-steps-to-clone-a-node / template-clone-children.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>HTML Templates: Clone template node: All the children of template content are copied if 'copy children flag' set to true</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="Clone template node: all the children of template content are copied if 'copy children flag' set to true">
7 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#node-clone-additions">
8 <script src="../../../../resources/testharness.js"></script>
9 <script src="../../../../resources/testharnessreport.js"></script>
10 <script src='../testcommon.js'></script>
11 <link rel="stylesheet" href="../../../../resources/testharness.css">
12 </head>
13 <body>
14 <div id="log"></div>
15 <script type="text/javascript">
16
17 test(function () {
18     var doc = newHTMLDocument();
19     doc.body.innerHTML = '<template id="tmpl1">' +
20         '<div id="div1">This is div inside template</div>' +
21         '<div id="div2">This is another div inside template</div>' +
22         '</template>';
23
24     var template = doc.querySelector('#tmpl1');
25     var copy = template.cloneNode(true);
26
27     assert_not_equals(copy.content, undefined, 'Template clone content attribute should not be undefined');
28     assert_not_equals(copy.content, null, 'Template clone content attribute should not be null');
29
30     assert_equals(copy.content.childNodes.length, 2,
31             'Wrong number of template content\'s copy child nodes');
32     assert_not_equals(copy.content.querySelector('#div1'), null,
33             'Template child node should be copied');
34     assert_not_equals(copy.content.querySelector('#div2'), null,
35             'Template child node should be copied');
36
37 }, 'Clone template node. Test call to cloneNode(true)');
38
39
40
41 test(function () {
42     var doc = newHTMLDocument();
43     doc.body.innerHTML = '<template id="tmpl1">' +
44         '<div id="div1">This is div inside template</div>' +
45         '<div id="div2">This is another div inside template</div>' +
46         '</template>';
47
48     var template = doc.querySelector('#tmpl1');
49     var copy = template.cloneNode();
50
51     assert_not_equals(copy.content, undefined, 'Template clone content attribute should not be undefined');
52     assert_not_equals(copy.content, null, 'Template clone content attribute should not be null');
53
54     assert_equals(copy.content.childNodes.length, 0,
55             'Wrong number of template content\'s copy child nodes');
56
57 }, 'Clone template node. Test call to cloneNode() with the default parameter '
58     + '(false by default)');
59
60
61
62 test(function () {
63     var doc = newHTMLDocument();
64     doc.body.innerHTML = '<template id="tmpl1">' +
65         '<div id="div1">This is div inside template</div>' +
66         '<div id="div2">This is another div inside template</div>' +
67         '</template>';
68
69     var template = doc.querySelector('#tmpl1');
70     var copy = template.cloneNode(false);
71
72     assert_not_equals(copy.content, undefined, 'Template clone content attribute is undefined');
73     assert_not_equals(copy.content, null, 'Template clone content attribute is null');
74
75     assert_equals(copy.content.childNodes.length, 0,
76             'Wrong number of template content\'s copy child nodes');
77
78 }, 'Clone template node. Test call to cloneNode(false)');
79
80
81 </script>
82 </body>
83 </html>