diff options
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/DOMImplementation-createHTMLDocument.html')
-rw-r--r-- | testing/web-platform/tests/dom/nodes/DOMImplementation-createHTMLDocument.html | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/DOMImplementation-createHTMLDocument.html b/testing/web-platform/tests/dom/nodes/DOMImplementation-createHTMLDocument.html new file mode 100644 index 0000000000..c6e0beaf75 --- /dev/null +++ b/testing/web-platform/tests/dom/nodes/DOMImplementation-createHTMLDocument.html @@ -0,0 +1,96 @@ +<!DOCTYPE html> +<meta charset=windows-1252> +<!-- Using windows-1252 to ensure that DOMImplementation.createHTMLDocument() + doesn't inherit utf-8 from the parent document. --> +<title>DOMImplementation.createHTMLDocument</title> +<link rel=help href="https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument"> +<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-name"> +<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-publicid"> +<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-systemid"> +<link rel=help href="https://dom.spec.whatwg.org/#dom-document-documentelement"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="DOMImplementation-createHTMLDocument.js"></script> +<div id="log"></div> +<script> +createHTMLDocuments(function(doc, expectedtitle, normalizedtitle) { + assert_true(doc instanceof Document, "Should be a Document") + assert_true(doc instanceof Node, "Should be a Node") + assert_equals(doc.childNodes.length, 2, + "Document should have two child nodes") + + var doctype = doc.doctype + assert_true(doctype instanceof DocumentType, + "Doctype should be a DocumentType") + assert_true(doctype instanceof Node, "Doctype should be a Node") + assert_equals(doctype.name, "html") + assert_equals(doctype.publicId, "") + assert_equals(doctype.systemId, "") + + var documentElement = doc.documentElement + assert_true(documentElement instanceof HTMLHtmlElement, + "Document element should be a HTMLHtmlElement") + assert_equals(documentElement.childNodes.length, 2, + "Document element should have two child nodes") + assert_equals(documentElement.localName, "html") + assert_equals(documentElement.tagName, "HTML") + + var head = documentElement.firstChild + assert_true(head instanceof HTMLHeadElement, + "Head should be a HTMLHeadElement") + assert_equals(head.localName, "head") + assert_equals(head.tagName, "HEAD") + + if (expectedtitle !== undefined) { + assert_equals(head.childNodes.length, 1) + + var title = head.firstChild + assert_true(title instanceof HTMLTitleElement, + "Title should be a HTMLTitleElement") + assert_equals(title.localName, "title") + assert_equals(title.tagName, "TITLE") + assert_equals(title.childNodes.length, 1) + assert_equals(title.firstChild.data, expectedtitle) + } else { + assert_equals(head.childNodes.length, 0) + } + + var body = documentElement.lastChild + assert_true(body instanceof HTMLBodyElement, + "Body should be a HTMLBodyElement") + assert_equals(body.localName, "body") + assert_equals(body.tagName, "BODY") + assert_equals(body.childNodes.length, 0) +}) + +test(function() { + var doc = document.implementation.createHTMLDocument("test"); + assert_equals(doc.URL, "about:blank"); + assert_equals(doc.documentURI, "about:blank"); + assert_equals(doc.compatMode, "CSS1Compat"); + assert_equals(doc.characterSet, "UTF-8"); + assert_equals(doc.contentType, "text/html"); + assert_equals(doc.createElement("DIV").localName, "div"); +}, "createHTMLDocument(): metadata") + +test(function() { + var doc = document.implementation.createHTMLDocument("test"); + assert_equals(doc.characterSet, "UTF-8", "characterSet"); + assert_equals(doc.charset, "UTF-8", "charset"); + assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding"); +}, "createHTMLDocument(): characterSet aliases") + +test(function() { + var doc = document.implementation.createHTMLDocument("test"); + var a = doc.createElement("a"); + // In UTF-8: 0xC3 0xA4 + a.href = "http://example.org/?\u00E4"; + assert_equals(a.href, "http://example.org/?%C3%A4"); +}, "createHTMLDocument(): URL parsing") + +// Test the document location getter is null outside of browser context +test(function() { + var doc = document.implementation.createHTMLDocument(); + assert_equals(doc.location, null); +}, "createHTMLDocument(): document location getter is null") +</script> |