Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1010)

Side by Side Diff: LayoutTests/fast/dom/ParentNode/append.html

Issue 1085843002: Implement DOM: prepend, append, before, after & replaceWith (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <script>
5
6 function test_append(node, nodeName) {
7
8 test(function() {
9 var parent = node.cloneNode();
10 parent.append();
11 assert_equals(parent.childNodes.length, 0);
12 assert_array_equals(parent.childNodes, []);
13 }, nodeName + '.append() without any argument, on a parent having no child.' );
14
15 test(function() {
16 if (nodeName != 'Document') {
17 var parent = node.cloneNode();
18 parent.append(null);
19 assert_equals(parent.childNodes.length, 1);
20 assert_equals(parent.childNodes[0].textContent, 'null');
21 }
22 }, nodeName + '.append() with null as an argument, on a parent having no chi ld.');
23
24 test(function() {
25 if (nodeName != 'Document') {
26 var parent = node.cloneNode();
27 parent.append(undefined);
28 assert_equals(parent.childNodes.length, 1);
29 assert_equals(parent.childNodes[0].textContent, 'undefined');
30 }
31 }, nodeName + '.append() with undefined as an argument, on a parent having n o child.');
32
33 test(function() {
34 if (nodeName != 'Document') {
35 var parent = node.cloneNode();
36 parent.append('text');
37 assert_equals(parent.childNodes.length, 1);
38 assert_equals(parent.childNodes[0].textContent, 'text');
39 }
40 }, nodeName + '.append() with only text as an argument, on a parent having n o child.');
41
42 test(function() {
43 var parent = node.cloneNode();
44 var x = document.createElement('x');
45 parent.append(x);
46 assert_equals(parent.childNodes.length, 1);
47 assert_array_equals(parent.childNodes, [x]);
48 }, nodeName + '.append() with only one element as an argument, on a parent h aving no child.');
49
50 test(function() {
51 if (nodeName != 'Document') {
52 var parent = node.cloneNode();
53 var child = document.createElement('test');
54 parent.appendChild(child);
55 parent.append(null);
56 assert_equals(parent.childNodes.length, 2);
57 assert_equals(parent.childNodes[0], child);
58 assert_equals(parent.childNodes[1].textContent, 'null');
59 }
60 }, nodeName + '.append() with null as an argument, on a parent having a chil d.');
61
62 test(function() {
63 if (nodeName != 'Document') {
64 var parent = node.cloneNode();
65 var child = document.createElement('test');
66 parent.appendChild(child);
67 parent.append(undefined);
68 assert_equals(parent.childNodes.length, 2);
69 assert_equals(parent.childNodes[0], child);
70 assert_equals(parent.childNodes[1].textContent, 'undefined');
71 }
72 }, nodeName + '.append() with undefined as an argument, on a parent having a child.');
philipj_slow 2015/07/06 12:02:40 I don't think two tests for append(undefined) are
73
74 test(function() {
75 if (nodeName != 'Document') {
76 var parent = node.cloneNode();
77 var x = document.createElement('x');
78 var child = document.createElement('test');
79 parent.appendChild(child);
80 parent.append(x, 'text');
81 assert_equals(parent.childNodes.length, 3);
82 assert_equals(parent.childNodes[0], child);
83 assert_equals(parent.childNodes[1], x);
84 assert_equals(parent.childNodes[2].textContent, 'text');
85 }
86 }, nodeName + '.append() with one element and text as argument, on a parent having a child.');
87 }
88
89 test_append(document.createElement('div'), 'Element');
90 test_append(document.implementation.createDocument(null, null), 'Document');
91 test_append(document.createDocumentFragment(), 'DocumentFrgment');
92 </script>
93 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698