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

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, 6 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('text');
38 assert_equals(parent.innerHTML, 'text');
39 }, nodeName + '.replaceWith() with only text as an argument.');
40
41 test(function() {
42 var parent = document.createElement('div');
43 var x = document.createElement('x');
44 parent.appendChild(child);
45 child.replaceWith(x);
46 assert_equals(parent.innerHTML, '<x></x>');
47 }, nodeName + '.replaceWith() with only one element as an argument.');
48
49 test(function() {
50 var parent = document.createElement('div');
51 var x = document.createElement('x');
52 var y = document.createElement('y');
53 parent.appendChild(y);
54 parent.appendChild(child);
55 parent.appendChild(x);
56 child.replaceWith(x, y, 'text');
57 assert_equals(parent.innerHTML, '<x></x><y></y>text');
58 }, nodeName + '.replaceWith() with argument containing sibling of childNode and text as arguments.');
59
60 test(function() {
61 var parent = document.createElement('div');
62 var x = document.createElement('x');
63 parent.appendChild(child);
64 child.replaceWith(x, 'text');
65 assert_equals(parent.innerHTML, '<x></x>text');
66 }, nodeName + '.replaceWith() with one element and text as arguments.');
67 }
68
69 test_replaceWith('Comment');
70 test_replaceWith('Element');
71 test_replaceWith('Text');
72
73 </script>
74 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698