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

Side by Side Diff: LayoutTests/fast/dom/ChildNode/replace-with.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_replaceWith(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.replaceWith();
24 assert_equals(parent.innerHTML, '');
25 }, nodeName + '.replaceWith() without any argument.');
26
27 test(function() {
28 var parent = document.createElement('div');
29 parent.appendChild(child);
30 child.replaceWith(null);
31 assert_equals(parent.innerHTML, 'null');
32 }, nodeName + '.replaceWith() with null as an argument.');
33
34 test(function() {
35 var parent = document.createElement('div');
36 parent.appendChild(child);
37 child.replaceWith(undefined);
38 assert_equals(parent.innerHTML, 'undefined');
39 }, nodeName + '.replaceWith() with undefined as an argument.');
40
41 test(function() {
42 var parent = document.createElement('div');
43 parent.appendChild(child);
44 child.replaceWith('text');
45 assert_equals(parent.innerHTML, 'text');
46 }, nodeName + '.replaceWith() with only text as an argument.');
47
48 test(function() {
49 var parent = document.createElement('div');
50 var x = document.createElement('x');
51 parent.appendChild(child);
52 child.replaceWith(x);
53 assert_equals(parent.innerHTML, '<x></x>');
54 }, nodeName + '.replaceWith() with only one element as an argument.');
55
56 test(function() {
57 var parent = document.createElement('div');
58 var x = document.createElement('x');
59 var y = document.createElement('y');
60 var z = document.createElement('z');
61 parent.appendChild(y);
62 parent.appendChild(child);
63 parent.appendChild(x);
64 child.replaceWith(x, y, z);
65 assert_equals(parent.innerHTML, '<x></x><y></y><z></z>');
66 }, nodeName + '.replaceWith() with sibling of child as arguments.');
67
68 test(function() {
69 var parent = document.createElement('div');
70 var x = document.createElement('x');
71 parent.appendChild(child);
72 parent.appendChild(x);
73 parent.appendChild(document.createTextNode('text'));
74 child.replaceWith(x, 'text');
75 assert_equals(parent.innerHTML,'<x></x>texttext');
76 }, nodeName + '.replaceWith() with one sibling of child and text as argument s.');
77
78 test(function() {
79 var parent = document.createElement('div');
80 var x = document.createElement('x');
81 parent.appendChild(child);
82 var innerHTML = parent.innerHTML;
83 parent.appendChild(x);
84 parent.appendChild(document.createTextNode('text'));
85 child.replaceWith(x, child);
86 assert_equals(parent.innerHTML,'<x></x>' + innerHTML + 'text');
87 }, nodeName + '.replaceWith() with one sibling of child and child itself as arguments.');
88
89 test(function() {
90 var parent = document.createElement('div');
91 var x = document.createElement('x');
92 parent.appendChild(child);
93 child.replaceWith(x, 'text');
94 assert_equals(parent.innerHTML, '<x></x>text');
95 }, nodeName + '.replaceWith() with one element and text as arguments.');
96 }
97
98 test_replaceWith('Comment');
99 test_replaceWith('Element');
100 test_replaceWith('Text');
101
102 </script>
103 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698