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

Unified 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 side-by-side diff with in-line comments
Download patch
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..2326f8b78d5235bfae7d4ff1a862902908cbf406
--- /dev/null
+++ b/LayoutTests/fast/dom/ChildNode/replace-with.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+
+test(function() {
+ var node = document.createComment('node');
+ assert_true('replaceWith' in node);
+ assert_equals(typeof node.replaceWith, 'function');
+ assert_equals(node.replaceWith.length, 0);
+}, 'Comment should support before()');
+
+test(function() {
+ var node = document.createElement('node');
+ assert_true('replaceWith' in node);
+ assert_equals(typeof node.replaceWith, 'function');
+ assert_equals(node.replaceWith.length, 0);
+}, 'Element should support before()');
+
+test(function() {
+ var node = document.createTextNode('node');
+ assert_true('replaceWith' in node);
+ assert_equals(typeof node.replaceWith, 'function');
+ assert_equals(node.replaceWith.length, 0);
+}, 'Text should support before()');
+
+test(function() {
+ var parent = document.createElement('div');
+ var test = document.createComment('test');
+ parent.appendChild(test);
+ var x = document.createComment('x');
+
+ assert_equals(test.parentNode, parent, 'Appended node should have a parent');
+ assert_array_equals(parent.childNodes, [test], 'ParentNode should have 1 child test');
+ test.replaceWith(x);
+ assert_array_equals(parent.childNodes, [x], 'ParentNode should have 1 child node');
+}, 'replaceWith() should work for Comment');
+
+test(function() {
+ var parent = document.createElement('div');
+ var test = document.createElement('test');
+ parent.appendChild(test);
+ var x = document.createElement('x');
+
+ assert_equals(test.parentNode, parent, 'Appended node should have a parent');
+ assert_array_equals(parent.childNodes, [test], 'ParentNode should have 1 child test');
+ test.replaceWith(x);
+ assert_array_equals(parent.childNodes, [x], 'ParentNode should have 1 child node');
+}, 'replaceWith() should work for Element');
+
+test(function() {
+ var parent = document.createElement('div');
+ var test = document.createTextNode('test');
+ parent.appendChild(test);
+ var x = document.createTextNode('x');
+
+ assert_equals(test.parentNode, parent, 'Appended node should have a parent');
+ assert_array_equals(parent.childNodes, [test], 'ParentNode should have 1 child test');
+ test.replaceWith(x);
+ assert_array_equals(parent.childNodes, [x], 'ParentNode should have 1 child node');
+}, 'replaceWith() should work for Text');
+
+</script>
+</html>

Powered by Google App Engine
This is Rietveld 408576698