50 lines
1.5 KiB
HTML
50 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
|
|
description("This test checks the implementation of the element traversal APIs on Document as part of the ParentNode interface.");
|
|
|
|
function createEmptyDocument()
|
|
{
|
|
var doc = document.implementation.createHTMLDocument();
|
|
while (doc.firstChild) {
|
|
doc.removeChild(doc.firstChild);
|
|
}
|
|
return doc;
|
|
}
|
|
|
|
debug('Test with no children');
|
|
var noChildren = createEmptyDocument();
|
|
shouldBe("noChildren.firstElementChild", "null");
|
|
shouldBe("noChildren.lastElementChild", "null");
|
|
shouldBe("noChildren.childElementCount", "0");
|
|
|
|
debug('Test with no element children');
|
|
var noElementChildren = createEmptyDocument();
|
|
noElementChildren.appendChild(document.createComment("comment but not an element"));
|
|
|
|
shouldBe("noElementChildren.firstElementChild", "null");
|
|
shouldBe("noElementChildren.lastElementChild", "null");
|
|
shouldBe("noElementChildren.childElementCount", "0");
|
|
|
|
debug('Test with elements');
|
|
var children = createEmptyDocument();
|
|
children.appendChild(document.createComment("first comment"));
|
|
var child = document.createElement('p');
|
|
children.appendChild(child);
|
|
children.appendChild(document.createComment("a comment"));
|
|
|
|
shouldBe("children.firstElementChild", "child");
|
|
shouldBe("children.lastElementChild", "child");
|
|
shouldBe("children.childElementCount", "1");
|
|
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|