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

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 var parent = node.cloneNode();
17 parent.prepend(null);
18 assert_equals(parent.childNodes.length, 1);
19 assert_equals(parent.childNodes[0].textContent, 'null');
20 }, nodeName + '.prepend() with null as an argument, on a parent having no ch ild.');
21
22 test(function() {
23 var parent = node.cloneNode();
24 parent.prepend(undefined);
25 assert_equals(parent.childNodes.length, 1);
26 assert_equals(parent.childNodes[0].textContent, 'undefined');
27 }, nodeName + '.prepend() with undefined as an argument, on a parent having no child.');
28
29 test(function() {
30 var parent = node.cloneNode();
31 parent.prepend('text');
32 assert_equals(parent.childNodes.length, 1);
33 assert_equals(parent.childNodes[0].textContent, 'text');
34 }, nodeName + '.prepend() with only text as an argument, on a parent having no child.');
35
36 test(function() {
37 var parent = node.cloneNode();
38 var x = document.createElement('x');
39 parent.prepend(x);
40 assert_equals(parent.childNodes.length, 1);
41 assert_array_equals(parent.childNodes, [x]);
42 }, nodeName + '.prepend() with only one element as an argument, on a parent having no child.');
43
44 test(function() {
45 var parent = node.cloneNode();
46 var child = document.createElement('test');
47 parent.appendChild(child);
48 parent.prepend(null);
49 assert_equals(parent.childNodes.length, 2);
50 assert_equals(parent.childNodes[0].textContent, 'null');
51 assert_equals(parent.childNodes[1], child);
52 }, nodeName + '.prepend() with null as an argument, on a parent having a chi ld.');
53
54 test(function() {
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 }, nodeName + '.prepend() with one element and text as argument, on a parent having a child.');
65 }
66
67 test_prepend(document.createElement('div'), 'Element');
68 test_prepend(document.createDocumentFragment(), 'DocumentFrgment');
69 </script>
70 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698