<html> <head> <script src="harness.js"></script> <script> // test1: basic test { is_not(document.implementation, null, "test1-0, basic test"); is_a(document.implementation, DOMImplementation, "test1-1, basic test"); var implementation = document.implementation; is(document.implementation, implementation, "test1-2, basic test"); } // test2: createDocumentType { is(document.doctype, null, "test2-0, createDocumentType"); var doctype = document.implementation.createDocumentType("html", null, null); is_a(doctype && doctype, DocumentType, "test2-1, createDocumentType"); doctype = document.implementation.createDocumentType("html:html", null, null); is_a(doctype && doctype, DocumentType, "test2-2, createDocumentType"); } // test3: createHTMLDocument { var htmldoc = document.implementation.createHTMLDocument("example title"); is_not(htmldoc, null, "test3-0, createHTMLDocument"); is_a(htmldoc, Document, "test3-1, createHTMLDocument"); is(htmldoc.childNodes.length, 2, "test3-3, createHTMLDocument"); is_a(htmldoc.doctype && htmldoc.doctype, DocumentType, "test3-4, createHTMLDocument"); is(htmldoc.doctype.name, "html", "test3-5, createHTMLDocument"); is_a(htmldoc.documentElement && htmldoc.documentElement, HTMLHtmlElement, "test3-6, createHTMLDocument"); is(htmldoc.documentElement.childNodes.length, 2, "test3-7, createHTMLDocument"); is(htmldoc.documentElement.tagName, "HTML", "test3-8, createHTMLDocument"); is_a(htmldoc.head && htmldoc.head, HTMLHeadElement, "test3-9, createHTMLDocument"); is(htmldoc.head.tagName, "HEAD", "test3-10, createHTMLDocument"); is(htmldoc.head, htmldoc.documentElement.childNodes[0], "test3-11, createHTMLDocument"); is(htmldoc.head.childNodes.length, 1, "test3-12, createHTMLDocument"); is_a(htmldoc.head.childNodes[0], HTMLTitleElement, "test3-13, createHTMLDocument"); is(htmldoc.head.childNodes[0].tagName, "TITLE", "test3-14, createHTMLDocument"); is(htmldoc.title, "example title", "test3-15, createHTMLDocument"); is_a(htmldoc.body && htmldoc.body, HTMLBodyElement, "test3-16, createHTMLDocument"); is(htmldoc.body.tagName, "BODY", "test3-17, createHTMLDocument"); is(htmldoc.body, htmldoc.documentElement.childNodes[1], "test3-18, createHTMLDocument"); is(htmldoc.body.childNodes.length, 0, "test3-19, createHTMLDocument"); } // test4: createDocument { var doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null); is_not(doc, null, "test4-0, createDocument"); is_a(doc, Document, "test4-1, createDocument"); is(doc.childNodes.length, 1, "test4-2, createDocument"); is(doc.doctype, null, "test4-3, createDocument"); is_a(doc.documentElement, HTMLHtmlElement, "test4-4, createDocument"); var doctype = document.implementation.createDocumentType("html", null, null); doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', doctype); is(doc.childNodes.length, 2, "test4-5, createDocument"); is(doc.doctype, doctype, "test4-6, createDocument"); is_a(doc.documentElement, HTMLHtmlElement, "test4-7, createDocument"); doctype = document.implementation.createDocumentType( 'svg:svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'); doc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg:svg', doctype); is(doc.childNodes.length, 2, "test4-8, createDocument"); is(doc.doctype, doctype, "test4-9, createDocument"); is_a(doc.documentElement, Element, "test4-10, createDocument"); } </script> </head> </html>