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

Unified Diff: LayoutTests/fast/dom/ChildNode/before.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/before.html
diff --git a/LayoutTests/fast/dom/ChildNode/before.html b/LayoutTests/fast/dom/ChildNode/before.html
new file mode 100644
index 0000000000000000000000000000000000000000..f28017cb04872c77a66226a06a6484db80949258
--- /dev/null
+++ b/LayoutTests/fast/dom/ChildNode/before.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+
+function test_before(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.before();
+ expected = innerHTML;
+ assert_equals(parent.innerHTML, expected);
+ }, nodeName + '.before() without any argument.');
+
+ test(function() {
+ var parent = node.cloneNode();
+ parent.appendChild(child);
+ child.before(null);
+ expected = 'null' + innerHTML;
+ assert_equals(parent.innerHTML, expected);
+ }, nodeName + '.before() with null as an argument.');
+
+ test(function() {
+ var parent = node.cloneNode();
+ parent.appendChild(child);
+ child.before('text');
+ expected = 'text' + innerHTML;
+ assert_equals(parent.innerHTML, expected);
+ }, nodeName + '.before() with only text as an argument.');
+
+ test(function() {
+ var parent = node.cloneNode();
+ var x = document.createElement('x');
+ parent.appendChild(child);
+ child.before(x);
+ expected = '<x></x>' + innerHTML;
+ assert_equals(parent.innerHTML, expected);
+ }, nodeName + '.before() with only one element as an argument.');
+
+ test(function() {
+ var parent = node.cloneNode();
+ var x = document.createElement('x');
+ parent.appendChild(child);
+ child.before(x, 'text');
+ expected = '<x></x>text' + innerHTML;
+ assert_equals(parent.innerHTML, expected);
+ }, nodeName + '.before() with one element and text as arguments.');
+}
+
+test_before(document.createElement('div'), 'Comment');
+test_before(document.createElement('div'), 'Element');
+test_before(document.createElement('div'), 'Text');
+
+</script>
+</html>

Powered by Google App Engine
This is Rietveld 408576698