Skip to content

Commit

Permalink
Tests: Add test for Node.nodeName
Browse files Browse the repository at this point in the history
  • Loading branch information
tcl3 committed Jul 25, 2024
1 parent 1fcb3db commit 48eba4f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Tests/LibWeb/Text/expected/DOM/Node-nodeName.txt
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions Tests/LibWeb/Text/input/DOM/Node-nodeName.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 48eba4f

Please sign in to comment.