test_bug450160.html (3878B)
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 src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450160">Mozilla Bug 450160</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script type="application/javascript"> 19 20 /** Test for Bug 450160 */ 21 22 23 function testHTMLDocument() { 24 var doc = document.implementation.createHTMLDocument(); 25 ok(!!doc.documentElement, "Document should have document element!"); 26 ok(!!doc.body, "Should have .body!"); 27 ok(doc instanceof HTMLDocument, 28 "Document should be an HTML document!"); 29 } 30 31 function testSVGDocument() { 32 var docType1 = 33 document.implementation.createDocumentType("svg", 34 "-//W3C//DTD SVG 1.1//EN", 35 null); 36 ok(docType1, "No doctype?"); 37 ok(docType1.ownerDocument, "docType should have ownerDocument!"); 38 var doc1 = document.implementation.createDocument(null, null, docType1); 39 is(docType1.ownerDocument, doc1, "docType should have ownerDocument!"); 40 ok(!doc1.documentElement, "Document shouldn't have document element!"); 41 ok(!(doc1 instanceof HTMLDocument), 42 "Document shouldn't be an HTML document!"); 43 ok(doc1 instanceof XMLDocument, 44 "Document should be an XML document!"); 45 46 // SVG documents have .documentElement. 47 ok("documentElement" in doc1, "No .documentElement in document"); 48 49 var docType2 = 50 document.implementation.createDocumentType("svg", 51 "-//W3C//DTD SVG 1.1//EN", 52 null); 53 var doc2 = document.implementation.createDocument("http://www.w3.org/2000/svg", 54 "svg", docType2); 55 ok(doc2.documentElement, "Document should have document element!"); 56 is(doc2.documentElement.localName, "svg", "Wrong .documentElement!"); 57 } 58 59 function testFooBarDocument() { 60 var docType1 = 61 document.implementation.createDocumentType("FooBar", "FooBar", null); 62 ok(docType1, "No doctype?"); 63 ok(docType1.ownerDocument, "docType should have ownerDocument!"); 64 var doc1 = document.implementation.createDocument(null, null, docType1); 65 is(docType1.ownerDocument, doc1, "docType should have ownerDocument!"); 66 ok(!doc1.documentElement, "Document shouldn't have document element!"); 67 ok(!(doc1 instanceof HTMLDocument), 68 "Document shouldn't be an HTML document!"); 69 70 var docType2 = 71 document.implementation.createDocumentType("FooBar", "FooBar", null); 72 var doc2 = document.implementation.createDocument("FooBarNS", 73 "FooBar", docType2); 74 ok(doc2.documentElement, "Document should have document element!"); 75 is(doc2.documentElement.namespaceURI, "FooBarNS", "Wrong namespaceURI!"); 76 is(doc2.documentElement.localName, "FooBar", "Wrong localName!"); 77 } 78 79 function testNullDocTypeDocument() { 80 var doc1 = document.implementation.createDocument(null, null, null); 81 ok(!doc1.documentElement, "Document shouldn't have document element!"); 82 ok(!(doc1 instanceof HTMLDocument), 83 "Document shouldn't be an HTML document!"); 84 85 var doc2 = document.implementation.createDocument("FooBarNS", 86 "FooBar", null); 87 ok(doc2.documentElement, "Document should have document element!"); 88 is(doc2.documentElement.namespaceURI, "FooBarNS", "Wrong namespaceURI!"); 89 is(doc2.documentElement.localName, "FooBar", "Wrong localName!"); 90 } 91 92 testHTMLDocument(); 93 testSVGDocument(); 94 testFooBarDocument(); 95 testNullDocTypeDocument(); 96 97 </script> 98 </pre> 99 </body> 100 </html>