Tests: Add test for Node.nodeName

This commit is contained in:
Tim Ledbetter 2024-07-25 22:50:31 +01:00 committed by Andreas Kling
parent ea2bb52962
commit 97436e7d65
Notes: github-actions[bot] 2024-07-26 05:20:14 +00:00
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,9 @@
Element nodeName: DIV
Attribute nodeName: testattribute
Text nodeName: #text
CDATASection nodeName: #cdata-section
ProcessingInstruction nodeName: testPI
Comment nodeName: #comment
Document nodeName: #document
DocumentType nodeName: html
DocumentFragment nodeName: #document-fragment

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
test(() => {
const element = document.createElement("div");
element.setAttribute("testAttribute", "foo");
element.innerText = "Text";
println(`Element nodeName: ${element.nodeName}`);
println(`Attribute nodeName: ${element.attributes[0].nodeName}`);
println(`Text nodeName: ${element.childNodes[0].nodeName}`);
const xmlDocument = new DOMParser().parseFromString(`<xml></xml>`, "application/xml");
const CDATASection = xmlDocument.createCDATASection("Test CDATA");
println(`CDATASection nodeName: ${CDATASection.nodeName}`);
const processingInstruction = document.createProcessingInstruction("testPI", "bar");
println(`ProcessingInstruction nodeName: ${processingInstruction.nodeName}`);
const comment = document.createComment("Test comment");
println(`Comment nodeName: ${comment.nodeName}`);
println(`Document nodeName: ${document.nodeName}`);
println(`DocumentType nodeName: ${document.doctype.nodeName}`);
const documentFragment = document.createDocumentFragment();
println(`DocumentFragment nodeName: ${documentFragment.nodeName}`);
});
</script>