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

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('text');
28 assert_equals(parent.childNodes.length, 1);
29 assert_equals(parent.childNodes[0].textContent, 'text');
30 }
31 }, nodeName + '.append() with only text as an argument, on a parent having n o child.');
32
33 test(function() {
34 var parent = node.cloneNode();
35 var x = document.createElement('x');
36 parent.append(x);
37 assert_equals(parent.childNodes.length, 1);
38 assert_array_equals(parent.childNodes, [x]);
39 }, nodeName + '.append() with only one element as an argument, on a parent h aving no child.');
40
41 test(function() {
42 if (nodeName != 'Document') {
43 var parent = node.cloneNode();
44 var child = document.createElement('test');
45 parent.appendChild(child);
46 parent.append(null);
47 assert_equals(parent.childNodes.length, 2);
48 assert_equals(parent.childNodes[0], child);
49 assert_equals(parent.childNodes[1].textContent, 'null');
50 }
51 }, nodeName + '.append() with null as an argument, on a parent having a chil d.');
52
53 test(function() {
54 if (nodeName != 'Document') {
55 var parent = node.cloneNode();
56 var x = document.createElement('x');
57 var child = document.createElement('test');
58 parent.appendChild(child);
59 parent.append(x, 'text');
60 assert_equals(parent.childNodes.length, 3);
61 assert_equals(parent.childNodes[0], child);
62 assert_equals(parent.childNodes[1], x);
63 assert_equals(parent.childNodes[2].textContent, 'text');
64 }
65 }, nodeName + '.append() with one element and text as argument, on a parent having a child.');
66 }
67
68 test_append(document.createElement('div'), 'Element');
69 test_append(document, 'Document');
philipj_slow 2015/07/03 21:52:05 If you pass in document.implementation.createDocum
Paritosh Kumar 2015/07/06 09:02:27 I tried this way, but these tests are still failin
philipj_slow 2015/07/06 12:02:40 I see, on Document you can only append a single El
70 test_append(document.createDocumentFragment(), 'DocumentFrgment');
71 </script>
72 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698