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

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..0f2f12d5f2e682bdc4e30d4eed1aab1eb8d9028e
--- /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 = "";
philipj_slow 2015/06/15 10:06:58 Hmm, I think you can just fold the expected bit in
+ assert_equals(parent.innerHTML, expected);
+ }, nodeName + '.replaceWith() without any argument.');
philipj_slow 2015/06/15 10:06:58 Also need to test child.replaceWith(something) whe
+
+ 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 one element and text as arguments.');
+}
+
+test_replaceWith(document.createElement('div'), 'Comment');
+test_replaceWith(document.createElement('div'), 'Element');
+test_replaceWith(document.createElement('div'), 'Text');
+
+</script>
+</html>

Powered by Google App Engine
This is Rietveld 408576698