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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/ChildNode/after.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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/ChildNode/before.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <meta charset=utf-8> 2 <script src="../../../resources/testharness.js"></script>
3 <title>ChildNode.after</title> 3 <script src="../../../resources/testharnessreport.js"></script>
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-childnode-after">
5 <script src="../../../../resources/testharness.js"></script>
6 <script src="../../../../resources/testharnessreport.js"></script>
7 <script> 4 <script>
8 5
9 function test_after(child, nodeName, innerHTML) { 6 test(function () {
7 var child = document.createElement('p');
8 assert_true('after' in child);
9 var after = 'mine';
10 var getAttribute = 'mine';
11 with (child) {
12 assert_true(after === 'mine');
13 assert_false(getAttribute === 'mine');
14 }
15 assert_true('Symbol' in window);
16 var unscopables = Object.getPrototypeOf(child)[Symbol.unscopables];
17 assert_true(unscopables.after);
18 }, 'ChildNode.after() unscopeable');
19
20 function test_after(nodeName) {
21 var child;
22 var innerHTML;
23 if (nodeName == 'Comment') {
24 child = document.createComment('test');
25 innerHTML = '<!--test-->';
26 } else if (nodeName == 'Element') {
27 child = document.createElement('test');
28 innerHTML = '<test></test>';
29 } else {
30 child = document.createTextNode('test');
31 innerHTML = 'test';
32 }
10 33
11 test(function() { 34 test(function() {
12 var parent = document.createElement('div'); 35 var parent = document.createElement('div');
13 parent.appendChild(child); 36 parent.appendChild(child);
14 child.after(); 37 child.after();
15 assert_equals(parent.innerHTML, innerHTML); 38 assert_equals(parent.innerHTML, innerHTML);
16 }, nodeName + '.after() without any argument.'); 39 }, nodeName + '.after() without any argument.');
17 40
18 test(function() { 41 test(function() {
19 var parent = document.createElement('div'); 42 var parent = document.createElement('div');
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 89
67 test(function() { 90 test(function() {
68 var parent = document.createElement('div'); 91 var parent = document.createElement('div');
69 parent.appendChild(child); 92 parent.appendChild(child);
70 child.after('text', child); 93 child.after('text', child);
71 var expected = 'text' + innerHTML; 94 var expected = 'text' + innerHTML;
72 assert_equals(parent.innerHTML, expected); 95 assert_equals(parent.innerHTML, expected);
73 }, nodeName + '.after() with context object itself as the argument.'); 96 }, nodeName + '.after() with context object itself as the argument.');
74 97
75 test(function() { 98 test(function() {
76 var parent = document.createElement('div')
77 var x = document.createElement('x');
78 parent.appendChild(x);
79 parent.appendChild(child);
80 child.after(child, x);
81 var expected = innerHTML + '<x></x>';
82 assert_equals(parent.innerHTML, expected);
83 }, nodeName + '.after() with context object itself and node as the arguments , switching positions.');
84
85 test(function() {
86 var parent = document.createElement('div'); 99 var parent = document.createElement('div');
87 var x = document.createElement('x'); 100 var x = document.createElement('x');
88 var y = document.createElement('y'); 101 var y = document.createElement('y');
89 var z = document.createElement('z'); 102 var z = document.createElement('z');
90 parent.appendChild(y); 103 parent.appendChild(y);
91 parent.appendChild(child); 104 parent.appendChild(child);
92 parent.appendChild(x); 105 parent.appendChild(x);
93 child.after(x, y, z); 106 child.after(x, y, z);
94 var expected = innerHTML + '<x></x><y></y><z></z>'; 107 var expected = innerHTML + '<x></x><y></y><z></z>';
95 assert_equals(parent.innerHTML, expected); 108 assert_equals(parent.innerHTML, expected);
96 }, nodeName + '.after() with all siblings of child as arguments.'); 109 }, nodeName + '.after() with all siblings of child as arguments.');
97 110
98 test(function() { 111 test(function() {
99 var parent = document.createElement('div')
100 var x = document.createElement('x');
101 var y = document.createElement('y');
102 var z = document.createElement('z');
103 parent.appendChild(child);
104 parent.appendChild(x);
105 parent.appendChild(y);
106 parent.appendChild(z);
107 child.after(x, y);
108 var expected = innerHTML + '<x></x><y></y><z></z>';
109 assert_equals(parent.innerHTML, expected);
110 }, nodeName + '.before() with some siblings of child as arguments; no change s in tree; viable sibling is first child.');
111
112 test(function() {
113 var parent = document.createElement('div')
114 var v = document.createElement('v');
115 var x = document.createElement('x');
116 var y = document.createElement('y');
117 var z = document.createElement('z');
118 parent.appendChild(child);
119 parent.appendChild(v);
120 parent.appendChild(x);
121 parent.appendChild(y);
122 parent.appendChild(z);
123 child.after(v, x);
124 var expected = innerHTML + '<v></v><x></x><y></y><z></z>';
125 assert_equals(parent.innerHTML, expected);
126 }, nodeName + '.after() with some siblings of child as arguments; no changes in tree.');
127
128 test(function() {
129 var parent = document.createElement('div'); 112 var parent = document.createElement('div');
130 var x = document.createElement('x'); 113 var x = document.createElement('x');
131 var y = document.createElement('y'); 114 var y = document.createElement('y');
132 parent.appendChild(child); 115 parent.appendChild(child);
133 parent.appendChild(x); 116 parent.appendChild(x);
134 parent.appendChild(y); 117 parent.appendChild(y);
135 child.after(y, x); 118 child.after(y, x);
136 var expected = innerHTML + '<y></y><x></x>'; 119 var expected = innerHTML + '<y></y><x></x>';
137 assert_equals(parent.innerHTML, expected); 120 assert_equals(parent.innerHTML, expected);
138 }, nodeName + '.after() when pre-insert behaves like append.'); 121 }, nodeName + '.after() when pre-insert behaves like append.');
(...skipping 12 matching lines...) Expand all
151 }, nodeName + '.after() with one sibling of child and text as arguments.'); 134 }, nodeName + '.after() with one sibling of child and text as arguments.');
152 135
153 test(function() { 136 test(function() {
154 var x = document.createElement('x'); 137 var x = document.createElement('x');
155 var y = document.createElement('y'); 138 var y = document.createElement('y');
156 x.after(y); 139 x.after(y);
157 assert_equals(x.nextSibling, null); 140 assert_equals(x.nextSibling, null);
158 }, nodeName + '.after() on a child without any parent.'); 141 }, nodeName + '.after() on a child without any parent.');
159 } 142 }
160 143
161 test_after(document.createComment('test'), 'Comment', '<!--test-->'); 144 test_after('Comment');
162 test_after(document.createElement('test'), 'Element', '<test></test>'); 145 test_after('Element');
163 test_after(document.createTextNode('test'), 'Text', 'test'); 146 test_after('Text');
164 147
165 </script> 148 </script>
166 </html> 149 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/ChildNode/before.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698