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

Side by Side Diff: LayoutTests/fast/dom/ChildNode/before.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_before(nodeName) {
7 var child;
8 var innerHTML;
9 if (nodeName == 'Comment') {
10 child = document.createComment('test');
11 innerHTML = '<!--test-->';
12 } else if (nodeName == 'Element') {
13 child = document.createElement('test');
14 innerHTML = '<test></test>';
15 } else {
16 child = document.createTextNode('test');
17 innerHTML = 'test';
18 }
19
20 test(function() {
21 var parent = document.createElement('div');
22 parent.appendChild(child);
23 child.before();
24 assert_equals(parent.innerHTML, innerHTML);
25 }, nodeName + '.before() without any argument.');
26
27 test(function() {
28 var parent = document.createElement('div');
29 parent.appendChild(child);
30 child.before(null);
31 var expected = 'null' + innerHTML;
32 assert_equals(parent.innerHTML, expected);
33 }, nodeName + '.before() with null as an argument.');
philipj_slow 2015/07/03 21:52:05 The comments for after.html mostly apply here as w
Paritosh Kumar 2015/07/06 09:02:27 Done.
34
35 test(function() {
36 var parent = document.createElement('div');
37 parent.appendChild(child);
38 child.before('text');
39 var expected = 'text' + innerHTML;
40 assert_equals(parent.innerHTML, expected);
41 }, nodeName + '.before() with only text as an argument.');
42
43 test(function() {
44 var parent = document.createElement('div');
45 var x = document.createElement('x');
46 parent.appendChild(child);
47 child.before(x);
48 var expected = '<x></x>' + innerHTML;
49 assert_equals(parent.innerHTML, expected);
50 }, nodeName + '.before() with only one element as an argument.');
51
52 test(function() {
53 var parent = document.createElement('div');
54 var x = document.createElement('x');
55 parent.appendChild(child);
56 child.before(x, 'text');
57 var expected = '<x></x>text' + innerHTML;
58 assert_equals(parent.innerHTML, expected);
59 }, nodeName + '.before() with one element and text as arguments.');
60
61 test(function() {
62 var parent = document.createElement('div');
63 var x = document.createElement('x');
64 var y = document.createElement('y');
65 var z = document.createElement('z');
66 parent.appendChild(y);
67 parent.appendChild(child);
68 parent.appendChild(x);
69 child.before(x, y, z);
70 var expected = '<x></x><y></y><z></z>' + innerHTML;
71 assert_equals(parent.innerHTML, expected);
72 }, nodeName + '.before() with all sibling of child as arguments.');
73
74 test(function() {
75 var parent = document.createElement('div');
76 var x = document.createElement('x');
77 parent.appendChild(x);
78 parent.appendChild(document.createTextNode('text'));
79 var y = document.createElement('y');
80 parent.appendChild(y);
81 parent.appendChild(child);
82 child.before(x, 'text');
83 var expected = 'text<y></y><x></x>text' + innerHTML;
84 assert_equals(parent.innerHTML, expected);
85 }, nodeName + '.before() with one sibling of child and text as arguments.');
86
87 test(function() {
88 var x = document.createElement('x');
89 var y = document.createElement('y');
90 x.before(y);
91 assert_equals(x.previousSibling, null);
92 }, nodeName + '.before() on a child without any parent.');
93 }
94
95 test_before('Comment');
96 test_before('Element');
97 test_before('Text');
98
99 </script>
100 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698