summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/Node-normalize.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/Node-normalize.html')
-rw-r--r--testing/web-platform/tests/dom/nodes/Node-normalize.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/Node-normalize.html b/testing/web-platform/tests/dom/nodes/Node-normalize.html
new file mode 100644
index 000000000..7598852e6
--- /dev/null
+++ b/testing/web-platform/tests/dom/nodes/Node-normalize.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<title>Node.normalize()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+test(function() {
+ var df = document.createDocumentFragment(),
+ t1 = document.createTextNode("1"),
+ t2 = document.createTextNode("2"),
+ t3 = document.createTextNode("3"),
+ t4 = document.createTextNode("4")
+ df.appendChild(t1)
+ df.appendChild(t2)
+ assert_equals(df.childNodes.length, 2)
+ assert_equals(df.textContent, "12")
+ var el = document.createElement('x')
+ df.appendChild(el)
+ el.appendChild(t3)
+ el.appendChild(t4)
+ document.normalize()
+ assert_equals(el.childNodes.length, 2)
+ assert_equals(el.textContent, "34")
+ assert_equals(df.childNodes.length, 3)
+ assert_equals(t1.data, "1")
+ df.normalize()
+ assert_equals(df.childNodes.length, 2)
+ assert_equals(df.firstChild, t1)
+ assert_equals(t1.data, "12")
+ assert_equals(t2.data, "2")
+ assert_equals(el.firstChild, t3)
+ assert_equals(t3.data, "34")
+ assert_equals(t4.data, "4")
+})
+
+// https://www.w3.org/Bugs/Public/show_bug.cgi?id=19837
+test(function() {
+ var div = document.createElement("div")
+ var t1 = div.appendChild(document.createTextNode(""))
+ var t2 = div.appendChild(document.createTextNode("a"))
+ var t3 = div.appendChild(document.createTextNode(""))
+ assert_array_equals(div.childNodes, [t1, t2, t3])
+ div.normalize();
+ assert_array_equals(div.childNodes, [t2])
+}, "Empty text nodes separated by a non-empty text node")
+test(function() {
+ var div = document.createElement("div")
+ var t1 = div.appendChild(document.createTextNode(""))
+ var t2 = div.appendChild(document.createTextNode(""))
+ assert_array_equals(div.childNodes, [t1, t2])
+ div.normalize();
+ assert_array_equals(div.childNodes, [])
+}, "Empty text nodes")
+</script>