Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / content / base / test / test_bug450160.html
blob39be810485f834e16e5574d89151b6a1a3b47f70
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=450160
5 -->
6 <head>
7 <title>Test for Bug 450160</title>
8 <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450160">Mozilla Bug 450160</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 <script type="application/javascript">
21 /** Test for Bug 450160 **/
24 function testHTMLDocuments(ids, isXHTML) {
25 for (var i = 0; i < ids.length; ++i) {
26 var docType1 =
27 document.implementation.createDocumentType(isXHTML ? "html" : "HTML",
28 ids[i],
29 null);
30 ok(docType1, "No doctype?");
31 ok(!docType1.ownerDocument, "docType shouldn't have ownerDocument!\n");
32 var doc1 = document.implementation.createDocument(null, null, docType1);
33 is(docType1.ownerDocument, doc1, "docType should have ownerDocument!\n");
34 ok(!doc1.documentElement, "Document shouldn't have document element!");
35 is(doc1.body, null, "Shouldn't have .body!");
36 ok(doc1 instanceof Components.interfaces.nsIDOMHTMLDocument,
37 "Document should be an HTML document!");
38 ok(!(doc1 instanceof Components.interfaces.nsIDOMSVGDocument),
39 "Document shouldn't be an SVG document!");
41 var docType2 =
42 document.implementation.createDocumentType(isXHTML ? "html" : "HTML",
43 ids[i],
44 null);
45 var doc2 = document.implementation.createDocument(
46 "http://www.w3.org/1999/xhtml", "html", docType2);
47 is(docType2.ownerDocument, doc2, "docType should have ownerDocument!\n");
48 ok(doc2.documentElement, "Document should have document element!");
49 is(doc2.documentElement.localName, "html", "Wrong document element!");
50 is(doc2.body, null, "Shouldn't have .body!");
51 doc2.documentElement.appendChild(doc2.createElement("body"));
52 is(doc2.body, doc2.documentElement.firstChild, "Should have .body!");
53 if (isXHTML) {
54 doc2.body.appendChild(doc2.createElementNS("http://www.w3.org/1999/xhtml", "form"));
55 } else {
56 doc2.body.appendChild(doc2.createElement("form"));
58 is(doc2.forms.length, 1, "Form wasn't added .forms");
62 function testSVGDocument() {
63 var docType1 =
64 document.implementation.createDocumentType("svg",
65 "-//W3C//DTD SVG 1.1//EN",
66 null);
67 ok(docType1, "No doctype?");
68 ok(!docType1.ownerDocument, "docType shouldn't have ownerDocument!\n");
69 var doc1 = document.implementation.createDocument(null, null, docType1);
70 is(docType1.ownerDocument, doc1, "docType should have ownerDocument!\n");
71 ok(!doc1.documentElement, "Document shouldn't have document element!");
72 ok(!(doc1 instanceof Components.interfaces.nsIDOMHTMLDocument),
73 "Document shouldn't be an HTML document!");
74 ok(doc1 instanceof Components.interfaces.nsIDOMSVGDocument,
75 "Document should be an SVG document!");
77 // SVG documents have .rootElement.
78 ok("rootElement" in doc1, "No .rootElement in document");
80 var docType2 =
81 document.implementation.createDocumentType("svg",
82 "-//W3C//DTD SVG 1.1//EN",
83 null);
84 var doc2 = document.implementation.createDocument("http://www.w3.org/2000/svg",
85 "svg", docType2);
86 ok(doc2.documentElement, "Document should have document element!");
87 ok(doc2.rootElement, "Should have .rootElement in document");
88 is(doc2.rootElement.localName, "svg", "Wrong .rootElement!");
91 function testFooBarDocument() {
92 var docType1 =
93 document.implementation.createDocumentType("FooBar", "FooBar", null);
94 ok(docType1, "No doctype?");
95 ok(!docType1.ownerDocument, "docType shouldn't have ownerDocument!\n");
96 var doc1 = document.implementation.createDocument(null, null, docType1);
97 is(docType1.ownerDocument, doc1, "docType should have ownerDocument!\n");
98 ok(!doc1.documentElement, "Document shouldn't have document element!");
99 ok(!(doc1 instanceof Components.interfaces.nsIDOMHTMLDocument),
100 "Document shouldn't be an HTML document!");
101 ok(!(doc1 instanceof Components.interfaces.nsIDOMSVGDocument),
102 "Document shouldn't be an SVG document!");
104 var docType2 =
105 document.implementation.createDocumentType("FooBar", "FooBar", null);
106 var doc2 = document.implementation.createDocument("FooBarNS",
107 "FooBar", docType2);
108 ok(doc2.documentElement, "Document should have document element!");
109 is(doc2.documentElement.namespaceURI, "FooBarNS", "Wrong namespaceURI!");
110 is(doc2.documentElement.localName, "FooBar", "Wrong localName!");
113 function testNullDocTypeDocument() {
114 var doc1 = document.implementation.createDocument(null, null, null);
115 ok(!doc1.documentElement, "Document shouldn't have document element!");
116 ok(!(doc1 instanceof Components.interfaces.nsIDOMHTMLDocument),
117 "Document shouldn't be an HTML document!");
118 ok(!(doc1 instanceof Components.interfaces.nsIDOMSVGDocument),
119 "Document shouldn't be an SVG document!");
121 var doc2 = document.implementation.createDocument("FooBarNS",
122 "FooBar", null);
123 ok(doc2.documentElement, "Document should have document element!");
124 is(doc2.documentElement.namespaceURI, "FooBarNS", "Wrong namespaceURI!");
125 is(doc2.documentElement.localName, "FooBar", "Wrong localName!");
128 var htmlPublicIDs =
129 [ "-//W3C//DTD HTML 4.01//EN",
130 "-//W3C//DTD HTML 4.01 Transitional//EN",
131 "-//W3C//DTD HTML 4.01 Frameset//EN",
132 "-//W3C//DTD HTML 4.0//EN",
133 "-//W3C//DTD HTML 4.0 Transitional//EN",
134 "-//W3C//DTD HTML 4.0 Frameset//EN" ];
136 var xhtmlPublicIDs =
137 [ "-//W3C//DTD XHTML 1.0 Strict//EN",
138 "-//W3C//DTD XHTML 1.0 Transitional//EN",
139 "-//W3C//DTD XHTML 1.0 Frameset//EN" ];
141 testHTMLDocuments(htmlPublicIDs, false);
142 testHTMLDocuments(xhtmlPublicIDs, true);
143 testSVGDocument();
144 testFooBarDocument();
145 testNullDocTypeDocument();
147 </script>
148 </pre>
149 </body>
150 </html>