Index: LayoutTests/fast/dom/ChildNode/replace-with.html |
diff --git a/LayoutTests/fast/dom/ChildNode/replace-with.html b/LayoutTests/fast/dom/ChildNode/replace-with.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..43f32703dd2a89436fa462e1f5ae55fd56ad863d |
--- /dev/null |
+++ b/LayoutTests/fast/dom/ChildNode/replace-with.html |
@@ -0,0 +1,68 @@ |
+<!DOCTYPE html> |
+<script src="../../../resources/testharness.js"></script> |
+<script src="../../../resources/testharnessreport.js"></script> |
+<script> |
+ |
+function test_replaceWith(node, nodeName) { |
+ var child; |
+ var innerHtml; |
+ if (nodeName == 'Comment') { |
+ child = document.createComment('test'); |
+ innerHtml = '<!--test-->'; |
+ } else if (nodeName == 'Element') { |
+ child = document.createElement('test'); |
+ innerHtml = '<test></test>'; |
+ } else { |
+ child = document.createTextNode('test'); |
+ innerHtml = 'test'; |
+ } |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ parent.appendChild(child); |
+ child.replaceWith(); |
+ expected = ""; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.replaceWith() with empty argument.'); |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ parent.appendChild(child); |
+ child.replaceWith(null); |
+ expected = 'null'; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.replaceWith() with null as an argument.'); |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ parent.appendChild(child); |
+ child.replaceWith('text'); |
+ expected = 'text'; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.replaceWith() with only text as an argument.'); |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ var x = document.createElement('x'); |
+ parent.appendChild(child); |
+ child.replaceWith(x); |
+ expected = '<x></x>'; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.replaceWith() with only one element as an argument.'); |
+ |
+ test(function() { |
+ var parent = node.cloneNode(); |
+ var x = document.createElement('x'); |
+ parent.appendChild(child); |
+ child.replaceWith(x, 'text'); |
+ expected = '<x></x>text'; |
+ assert_equals(parent.innerHTML, expected); |
+ }, nodeName + '.replaceWith() with only one element and text as argument.'); |
+} |
+ |
+test_replaceWith(document.createElement('div'), 'Comment'); |
+test_replaceWith(document.createElement('div'), 'Element'); |
+test_replaceWith(document.createElement('div'), 'Text'); |
+ |
+</script> |
+</html> |