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

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

Issue 1934123002: Implement DOM methods: prepend, append, after, before and replaceWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync test expectations Created 4 years, 7 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <meta charset=utf-8> 2 <script src="../../../resources/testharness.js"></script>
3 <title>ParentNode.append</title> 3 <script src="../../../resources/testharnessreport.js"></script>
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-parentnode-append">
5 <script src="../../../../resources/testharness.js"></script>
6 <script src="../../../../resources/testharnessreport.js"></script>
7 <script> 4 <script>
8 5
6 test(function () {
7 var node = document.createElement('div');
8 assert_true('append' in node);
9 var append = 'mine';
10 var getAttribute = 'mine';
11 with (node) {
12 assert_true(append === 'mine');
13 assert_false(getAttribute === 'mine');
14 }
15 assert_true('Symbol' in window);
16 var unscopables = Object.getPrototypeOf(node)[Symbol.unscopables];
17 assert_true(unscopables.append);
18 }, 'ChildNode.append() unscopeable');
19
9 function test_append(node, nodeName) { 20 function test_append(node, nodeName) {
10 21
11 test(function() { 22 test(function() {
12 var parent = node.cloneNode(); 23 var parent = node.cloneNode();
13 parent.append(); 24 parent.append();
14 assert_array_equals(parent.childNodes, []); 25 assert_array_equals(parent.childNodes, []);
15 }, nodeName + '.append() without any argument, on a parent having no child.' ); 26 }, nodeName + '.append() without any argument, on a parent having no child.' );
16 27
17 test(function() { 28 test(function() {
18 var parent = node.cloneNode(); 29 var parent = node.cloneNode();
(...skipping 26 matching lines...) Expand all
45 parent.appendChild(child); 56 parent.appendChild(child);
46 parent.append(null); 57 parent.append(null);
47 assert_equals(parent.childNodes[0], child); 58 assert_equals(parent.childNodes[0], child);
48 assert_equals(parent.childNodes[1].textContent, 'null'); 59 assert_equals(parent.childNodes[1].textContent, 'null');
49 }, nodeName + '.append() with null as an argument, on a parent having a chil d.'); 60 }, nodeName + '.append() with null as an argument, on a parent having a chil d.');
50 61
51 test(function() { 62 test(function() {
52 var parent = node.cloneNode(); 63 var parent = node.cloneNode();
53 var x = document.createElement('x'); 64 var x = document.createElement('x');
54 var child = document.createElement('test'); 65 var child = document.createElement('test');
66 parent.appendChild(x);
67 parent.appendChild(child);
68 parent.append(child, x);
69 assert_array_equals(parent.childNodes, [child, x]);
70 }, nodeName + '.append() with all children as arguments, on a parent having two children.');
71
72 test(function() {
73 var parent = node.cloneNode();
74 var x = document.createElement('x');
75 var child = document.createElement('test');
55 parent.appendChild(child); 76 parent.appendChild(child);
56 parent.append(x, 'text'); 77 parent.append(x, 'text');
57 assert_equals(parent.childNodes[0], child); 78 assert_equals(parent.childNodes[0], child);
58 assert_equals(parent.childNodes[1], x); 79 assert_equals(parent.childNodes[1], x);
59 assert_equals(parent.childNodes[2].textContent, 'text'); 80 assert_equals(parent.childNodes[2].textContent, 'text');
60 }, nodeName + '.append() with one element and text as argument, on a parent having a child.'); 81 }, nodeName + '.append() with one element and text as argument, on a parent having a child.');
61 } 82 }
62 83
63 test_append(document.createElement('div'), 'Element'); 84 test_append(document.createElement('div'), 'Element');
64 test_append(document.createDocumentFragment(), 'DocumentFrgment'); 85 test_append(document.createDocumentFragment(), 'DocumentFrgment');
65 </script> 86 </script>
66 </html> 87 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698