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