summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/Node-parentElement.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/dom/nodes/Node-parentElement.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/Node-parentElement.html')
-rw-r--r--testing/web-platform/tests/dom/nodes/Node-parentElement.html82
1 files changed, 82 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/Node-parentElement.html b/testing/web-platform/tests/dom/nodes/Node-parentElement.html
new file mode 100644
index 000000000..bc564bee0
--- /dev/null
+++ b/testing/web-platform/tests/dom/nodes/Node-parentElement.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<title>Node.parentElement</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_equals(document.parentElement, null)
+}, "When the parent is null, parentElement should be null")
+test(function() {
+ assert_equals(document.doctype.parentElement, null)
+}, "When the parent is a document, parentElement should be null (doctype)")
+test(function() {
+ assert_equals(document.documentElement.parentElement, null)
+}, "When the parent is a document, parentElement should be null (element)")
+test(function() {
+ var comment = document.appendChild(document.createComment("foo"))
+ assert_equals(comment.parentElement, null)
+}, "When the parent is a document, parentElement should be null (comment)")
+test(function() {
+ var df = document.createDocumentFragment()
+ assert_equals(df.parentElement, null)
+ var el = document.createElement("div")
+ assert_equals(el.parentElement, null)
+ df.appendChild(el)
+ assert_equals(el.parentNode, df)
+ assert_equals(el.parentElement, null)
+}, "parentElement should return null for children of DocumentFragments (element)")
+test(function() {
+ var df = document.createDocumentFragment()
+ assert_equals(df.parentElement, null)
+ var text = document.createTextNode("bar")
+ assert_equals(text.parentElement, null)
+ df.appendChild(text)
+ assert_equals(text.parentNode, df)
+ assert_equals(text.parentElement, null)
+}, "parentElement should return null for children of DocumentFragments (text)")
+test(function() {
+ var df = document.createDocumentFragment()
+ var parent = document.createElement("div")
+ df.appendChild(parent)
+ var el = document.createElement("div")
+ assert_equals(el.parentElement, null)
+ parent.appendChild(el)
+ assert_equals(el.parentElement, parent)
+}, "parentElement should work correctly with DocumentFragments (element)")
+test(function() {
+ var df = document.createDocumentFragment()
+ var parent = document.createElement("div")
+ df.appendChild(parent)
+ var text = document.createTextNode("bar")
+ assert_equals(text.parentElement, null)
+ parent.appendChild(text)
+ assert_equals(text.parentElement, parent)
+}, "parentElement should work correctly with DocumentFragments (text)")
+test(function() {
+ var parent = document.createElement("div")
+ var el = document.createElement("div")
+ assert_equals(el.parentElement, null)
+ parent.appendChild(el)
+ assert_equals(el.parentElement, parent)
+}, "parentElement should work correctly in disconnected subtrees (element)")
+test(function() {
+ var parent = document.createElement("div")
+ var text = document.createTextNode("bar")
+ assert_equals(text.parentElement, null)
+ parent.appendChild(text)
+ assert_equals(text.parentElement, parent)
+}, "parentElement should work correctly in disconnected subtrees (text)")
+test(function() {
+ var el = document.createElement("div")
+ assert_equals(el.parentElement, null)
+ document.body.appendChild(el)
+ assert_equals(el.parentElement, document.body)
+}, "parentElement should work correctly in a document (element)")
+test(function() {
+ var text = document.createElement("div")
+ assert_equals(text.parentElement, null)
+ document.body.appendChild(text)
+ assert_equals(text.parentElement, document.body)
+}, "parentElement should work correctly in a document (text)")
+</script>