Bug 1686668 [wpt PR 27185] - Update wpt metadata, a=testonly
[gecko.git] / dom / base / test / test_createHTMLDocument.html
blob66b090d189bf720f7c06cb5b4bcafd32759c08a0
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);
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 isElement(doc.documentElement, "html");
28 isElement(doc.documentElement.firstChild, "head");
29 if (title !== undefined) {
30 is(doc.documentElement.firstChild.childNodes.length, 1);
31 isElement(doc.documentElement.firstChild.firstChild, "title");
32 // Doesn't always work out in WebKit.
33 ok(doc.documentElement.firstChild.firstChild.firstChild, "Need a text node.");
34 is(doc.documentElement.firstChild.firstChild.firstChild.data, expectedtitle);
35 } else {
36 is(doc.documentElement.firstChild.childNodes.length, 0);
38 isElement(doc.documentElement.lastChild, "body");
39 is(doc.documentElement.lastChild.childNodes.length, 0);
40 is(doc.title, normalizedtitle);
41 doc.body.innerHTML = "foo";
42 is(doc.body.innerHTML, "foo", "innerHTML should work in HTML data documents!");
44 checkDoc("", "", "");
45 checkDoc(null, "null", "null");
46 checkDoc(undefined, "", "");
47 checkDoc("foo bar baz", "foo bar baz", "foo bar baz");
48 checkDoc("foo\t\tbar baz", "foo\t\tbar baz", "foo bar baz");
49 checkDoc("foo\n\nbar baz", "foo\n\nbar baz", "foo bar baz");
50 checkDoc("foo\f\fbar baz", "foo\f\fbar baz", "foo bar baz");
51 checkDoc("foo\r\rbar baz", "foo\r\rbar baz", "foo bar baz");
52 </script>