Index: third_party/WebKit/LayoutTests/fast/dom/ChildNode/replace-with.html |
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-replaceWith.html b/third_party/WebKit/LayoutTests/fast/dom/ChildNode/replace-with.html |
similarity index 70% |
copy from third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-replaceWith.html |
copy to third_party/WebKit/LayoutTests/fast/dom/ChildNode/replace-with.html |
index b05a907ad67c031ad2f6b2b04276b569fb111212..87adf579771c594066cc0ae6a4c6762088265902 100644 |
--- a/third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/ChildNode-replaceWith.html |
+++ b/third_party/WebKit/LayoutTests/fast/dom/ChildNode/replace-with.html |
@@ -1,12 +1,35 @@ |
<!DOCTYPE html> |
-<meta charset=utf-8> |
-<title>ChildNode.replaceWith</title> |
-<link rel=help href="https://dom.spec.whatwg.org/#dom-childnode-replaceWith"> |
-<script src="../../../../resources/testharness.js"></script> |
-<script src="../../../../resources/testharnessreport.js"></script> |
+<script src="../../../resources/testharness.js"></script> |
+<script src="../../../resources/testharnessreport.js"></script> |
<script> |
-function test_replaceWith(child, nodeName, innerHTML) { |
+test(function () { |
+ var child = document.createElement('p'); |
+ assert_true('replaceWith' in child); |
+ var replaceWith = 'mine'; |
+ var getAttribute = 'mine'; |
+ with (child) { |
+ assert_true(replaceWith === 'mine'); |
+ assert_false(getAttribute === 'mine'); |
+ } |
+ assert_true('Symbol' in window); |
+ var unscopables = Object.getPrototypeOf(child)[Symbol.unscopables]; |
+ assert_true(unscopables.replaceWith); |
+}, 'ChildNode.replaceWith() unscopeable'); |
+ |
+function test_replaceWith(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 = document.createElement('div'); |
@@ -34,7 +57,7 @@ function test_replaceWith(child, nodeName, innerHTML) { |
parent.appendChild(child); |
child.replaceWith(''); |
assert_equals(parent.innerHTML, ''); |
- }, nodeName + '.replaceWith() with empty string as an argument.'); |
+ }, nodeName + '.replaceWith() with an empty string as an argument.'); |
test(function() { |
var parent = document.createElement('div'); |
@@ -70,17 +93,18 @@ function test_replaceWith(child, nodeName, innerHTML) { |
parent.appendChild(x); |
parent.appendChild(document.createTextNode('1')); |
child.replaceWith(x, '2'); |
- assert_equals(parent.innerHTML, '<x></x>21'); |
+ assert_equals(parent.innerHTML,'<x></x>21'); |
}, nodeName + '.replaceWith() with one sibling of child and text as arguments.'); |
test(function() { |
var parent = document.createElement('div'); |
var x = document.createElement('x'); |
parent.appendChild(child); |
+ var innerHTML = parent.innerHTML; |
parent.appendChild(x); |
parent.appendChild(document.createTextNode('text')); |
child.replaceWith(x, child); |
- assert_equals(parent.innerHTML, '<x></x>' + innerHTML + 'text'); |
+ assert_equals(parent.innerHTML,'<x></x>' + innerHTML + 'text'); |
}, nodeName + '.replaceWith() with one sibling of child and child itself as arguments.'); |
test(function() { |
@@ -99,12 +123,12 @@ function test_replaceWith(child, nodeName, innerHTML) { |
parent.appendChild(y); |
child.replaceWith(x, y); |
assert_equals(parent.innerHTML, '<x></x><y></y>'); |
- }, nodeName + '.replaceWith() on a parentless child with two elements as arguments.'); |
+ }, nodeName + '.replaceWith() on a parenless child with two elements as arguments.'); |
} |
-test_replaceWith(document.createComment('test'), 'Comment', '<!--test-->'); |
-test_replaceWith(document.createElement('test'), 'Element', '<test></test>'); |
-test_replaceWith(document.createTextNode('test'), 'Text', 'test'); |
+test_replaceWith('Comment'); |
+test_replaceWith('Element'); |
+test_replaceWith('Text'); |
</script> |
</html> |