Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <title>createHTMLDocument</title> |
michael@0 | 3 | <script src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 4 | <link rel="stylesheet" href="/tests/SimpleTest/test.css" /> |
michael@0 | 5 | <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> |
michael@0 | 6 | <link rel="help" href="http://www.whatwg.org/html5/#creating-documents"> |
michael@0 | 7 | <link rel="help" href="http://www.whatwg.org/html5/#document.title"> |
michael@0 | 8 | <link rel="help" href="http://www.whatwg.org/html5/#dom-document-readystate"> |
michael@0 | 9 | <body> |
michael@0 | 10 | <script> |
michael@0 | 11 | function isElement(element, localName) { |
michael@0 | 12 | is(element.localName, localName); |
michael@0 | 13 | is(element.namespaceURI, "http://www.w3.org/1999/xhtml"); |
michael@0 | 14 | is(element.tagName, localName.toUpperCase()); |
michael@0 | 15 | is(element.nodeName, localName.toUpperCase()); |
michael@0 | 16 | is(element.prefix, null); |
michael@0 | 17 | } |
michael@0 | 18 | function checkDoc(title, expectedtitle, normalizedtitle) { |
michael@0 | 19 | var doc = document.implementation.createHTMLDocument(title); |
michael@0 | 20 | is(doc.readyState, "complete"); |
michael@0 | 21 | is(doc.compatMode, "CSS1Compat"); |
michael@0 | 22 | // Opera doesn't have a doctype: DSK-311092 |
michael@0 | 23 | ok(doc.doctype, "Need a doctype"); |
michael@0 | 24 | is(doc.doctype.name, "html"); |
michael@0 | 25 | is(doc.doctype.publicId, ""); |
michael@0 | 26 | is(doc.doctype.systemId, ""); |
michael@0 | 27 | is(doc.doctype.internalSubset, null, "internalSubset should be null!"); |
michael@0 | 28 | isElement(doc.documentElement, "html"); |
michael@0 | 29 | isElement(doc.documentElement.firstChild, "head"); |
michael@0 | 30 | if (title !== undefined) { |
michael@0 | 31 | is(doc.documentElement.firstChild.childNodes.length, 1); |
michael@0 | 32 | isElement(doc.documentElement.firstChild.firstChild, "title"); |
michael@0 | 33 | // Doesn't always work out in WebKit. |
michael@0 | 34 | ok(doc.documentElement.firstChild.firstChild.firstChild, "Need a text node."); |
michael@0 | 35 | is(doc.documentElement.firstChild.firstChild.firstChild.data, expectedtitle); |
michael@0 | 36 | } else { |
michael@0 | 37 | is(doc.documentElement.firstChild.childNodes.length, 0); |
michael@0 | 38 | } |
michael@0 | 39 | isElement(doc.documentElement.lastChild, "body"); |
michael@0 | 40 | is(doc.documentElement.lastChild.childNodes.length, 0); |
michael@0 | 41 | ((!title || title.indexOf("\f") === -1) ? is : todo_is) |
michael@0 | 42 | (doc.title, normalizedtitle); |
michael@0 | 43 | doc.body.innerHTML = "foo"; |
michael@0 | 44 | is(doc.body.innerHTML, "foo", "innerHTML should work in HTML data documents!"); |
michael@0 | 45 | } |
michael@0 | 46 | checkDoc("", "", ""); |
michael@0 | 47 | checkDoc(null, "null", "null"); |
michael@0 | 48 | checkDoc(undefined, "", ""); |
michael@0 | 49 | checkDoc("foo bar baz", "foo bar baz", "foo bar baz"); |
michael@0 | 50 | checkDoc("foo\t\tbar baz", "foo\t\tbar baz", "foo bar baz"); |
michael@0 | 51 | checkDoc("foo\n\nbar baz", "foo\n\nbar baz", "foo bar baz"); |
michael@0 | 52 | checkDoc("foo\f\fbar baz", "foo\f\fbar baz", "foo bar baz"); |
michael@0 | 53 | checkDoc("foo\r\rbar baz", "foo\r\rbar baz", "foo bar baz"); |
michael@0 | 54 | </script> |