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

Side by Side Diff: LayoutTests/fast/dom/ParentNode/prepend.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_prepend(node, nodeName) {
7
8 test(function() {
9 var parent = node.cloneNode();
10 parent.prepend();
11 assert_equals(parent.childNodes.length, 0);
12 assert_array_equals(parent.childNodes, []);
13 }, nodeName + '.prepend() without any argument, on a parent having no child. ');
14
15 test(function() {
16 if (nodeName != 'Document') {
17 var parent = node.cloneNode();
18 parent.prepend(null);
19 assert_equals(parent.childNodes.length, 1);
20 assert_equals(parent.childNodes[0].textContent, 'null');
21 }
22 }, nodeName + '.prepend() with null as an argument, on a parent having no ch ild.');
23
24 test(function() {
25 if (nodeName != 'Document') {
26 var parent = node.cloneNode();
27 parent.prepend('text');
28 assert_equals(parent.childNodes.length, 1);
29 assert_equals(parent.childNodes[0].textContent, 'text');
30 }
31 }, nodeName + '.prepend() with only text as an argument, on a parent having no child.');
32
33 test(function() {
34 var parent = node.cloneNode();
35 var x = document.createElement('x');
36 parent.prepend(x);
37 assert_equals(parent.childNodes.length, 1);
38 assert_array_equals(parent.childNodes, [x]);
39 }, nodeName + '.prepend() with only one element as an argument, on a parent having 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.prepend(null);
47 assert_equals(parent.childNodes.length, 2);
48 assert_equals(parent.childNodes[0].textContent, 'null');
49 assert_equals(parent.childNodes[1], child);
50 }
51 }, nodeName + '.prepend() with null as an argument, on a parent having a chi ld.');
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.prepend(x, 'text');
60 assert_equals(parent.childNodes.length, 3);
61 assert_equals(parent.childNodes[0], x);
62 assert_equals(parent.childNodes[1].textContent, 'text');
63 assert_equals(parent.childNodes[2], child);
64 }
65 }, nodeName + '.prepend() with one element and text as argument, on a parent having a child.');
66 }
67
68 test_prepend(document.createElement('div'), 'Element');
69 test_prepend(document, 'Document');
70 test_prepend(document.createDocumentFragment(), 'DocumentFrgment');
71 </script>
72 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698