Blame dom/base/test/test_bug450160.html

Packit f0b94e
Packit f0b94e
<html>
Packit f0b94e
Packit f0b94e
https://bugzilla.mozilla.org/show_bug.cgi?id=450160
Packit f0b94e
-->
Packit f0b94e
<head>
Packit f0b94e
  <title>Test for Bug 450160</title>
Packit f0b94e
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
Packit f0b94e
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
Packit f0b94e
</head>
Packit f0b94e
<body>
Packit f0b94e
Mozilla Bug 450160
Packit f0b94e

Packit f0b94e
Packit f0b94e
  
Packit f0b94e
Packit f0b94e
Packit f0b94e
<script type="application/javascript">
Packit f0b94e
Packit f0b94e
/** Test for Bug 450160 **/
Packit f0b94e
Packit f0b94e
Packit f0b94e
function testHTMLDocuments(ids, isXHTML) {
Packit f0b94e
  for (var i = 0; i < ids.length; ++i) {
Packit f0b94e
    var docType1 =
Packit f0b94e
      document.implementation.createDocumentType(isXHTML ? "html" : "HTML",
Packit f0b94e
                                                 ids[i],
Packit f0b94e
                                                 null);
Packit f0b94e
    ok(docType1, "No doctype?");
Packit f0b94e
    ok(docType1.ownerDocument, "docType should have ownerDocument!");
Packit f0b94e
    var doc1 = document.implementation.createDocument(null, null, docType1);
Packit f0b94e
    is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
Packit f0b94e
    ok(!doc1.documentElement, "Document shouldn't have document element!");
Packit f0b94e
    is(doc1.body, null, "Shouldn't have .body!");
Packit f0b94e
    ok(doc1 instanceof HTMLDocument,
Packit f0b94e
       "Document should be an HTML document!");
Packit f0b94e
Packit f0b94e
    var docType2 =
Packit f0b94e
      document.implementation.createDocumentType(isXHTML ? "html" : "HTML",
Packit f0b94e
                                                 ids[i],
Packit f0b94e
                                                 null);
Packit f0b94e
    var doc2 = document.implementation.createDocument(
Packit f0b94e
      "http://www.w3.org/1999/xhtml", "html", docType2);
Packit f0b94e
    is(docType2.ownerDocument, doc2, "docType should have ownerDocument!");
Packit f0b94e
    ok(doc2.documentElement, "Document should have document element!");
Packit f0b94e
    is(doc2.documentElement.localName, "html", "Wrong document element!");
Packit f0b94e
    is(doc2.body, null, "Shouldn't have .body!");
Packit f0b94e
    doc2.documentElement.appendChild(doc2.createElement("body"));
Packit f0b94e
    is(doc2.body, doc2.documentElement.firstChild, "Should have .body!");
Packit f0b94e
    if (isXHTML) {
Packit f0b94e
      doc2.body.appendChild(doc2.createElementNS("http://www.w3.org/1999/xhtml", "form"));
Packit f0b94e
    } else {
Packit f0b94e
      doc2.body.appendChild(doc2.createElement("form"));
Packit f0b94e
    }
Packit f0b94e
    is(doc2.forms.length, 1, "Form wasn't added .forms");
Packit f0b94e
  }
Packit f0b94e
}
Packit f0b94e
Packit f0b94e
function testSVGDocument() {
Packit f0b94e
  var docType1 =
Packit f0b94e
      document.implementation.createDocumentType("svg",
Packit f0b94e
                                                 "-//W3C//DTD SVG 1.1//EN",
Packit f0b94e
                                                 null);
Packit f0b94e
  ok(docType1, "No doctype?");
Packit f0b94e
  ok(docType1.ownerDocument, "docType should have ownerDocument!");
Packit f0b94e
  var doc1 = document.implementation.createDocument(null, null, docType1);
Packit f0b94e
  is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
Packit f0b94e
  ok(!doc1.documentElement, "Document shouldn't have document element!");
Packit f0b94e
  ok(!(doc1 instanceof HTMLDocument),
Packit f0b94e
     "Document shouldn't be an HTML document!");
Packit f0b94e
  ok(doc1 instanceof XMLDocument,
Packit f0b94e
     "Document should be an XML document!");
Packit f0b94e
Packit f0b94e
  // SVG documents have .documentElement.
Packit f0b94e
  ok("documentElement" in doc1, "No .documentElement in document");
Packit f0b94e
Packit f0b94e
  var docType2 =
Packit f0b94e
      document.implementation.createDocumentType("svg",
Packit f0b94e
                                                 "-//W3C//DTD SVG 1.1//EN",
Packit f0b94e
                                                 null);
Packit f0b94e
  var doc2 = document.implementation.createDocument("http://www.w3.org/2000/svg",
Packit f0b94e
                                                    "svg", docType2);
Packit f0b94e
  ok(doc2.documentElement, "Document should have document element!");
Packit f0b94e
  is(doc2.documentElement.localName, "svg", "Wrong .documentElement!");
Packit f0b94e
}
Packit f0b94e
Packit f0b94e
function testFooBarDocument() {
Packit f0b94e
  var docType1 =
Packit f0b94e
      document.implementation.createDocumentType("FooBar", "FooBar", null);
Packit f0b94e
  ok(docType1, "No doctype?");
Packit f0b94e
  ok(docType1.ownerDocument, "docType should have ownerDocument!");
Packit f0b94e
  var doc1 = document.implementation.createDocument(null, null, docType1);
Packit f0b94e
  is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
Packit f0b94e
  ok(!doc1.documentElement, "Document shouldn't have document element!");
Packit f0b94e
  ok(!(doc1 instanceof HTMLDocument),
Packit f0b94e
     "Document shouldn't be an HTML document!");
Packit f0b94e
Packit f0b94e
  var docType2 =
Packit f0b94e
      document.implementation.createDocumentType("FooBar", "FooBar", null);
Packit f0b94e
  var doc2 = document.implementation.createDocument("FooBarNS",
Packit f0b94e
                                                    "FooBar", docType2);
Packit f0b94e
  ok(doc2.documentElement, "Document should have document element!");
Packit f0b94e
  is(doc2.documentElement.namespaceURI, "FooBarNS", "Wrong namespaceURI!");
Packit f0b94e
  is(doc2.documentElement.localName, "FooBar", "Wrong localName!");
Packit f0b94e
}
Packit f0b94e
Packit f0b94e
function testNullDocTypeDocument() {
Packit f0b94e
  var doc1 = document.implementation.createDocument(null, null, null);
Packit f0b94e
  ok(!doc1.documentElement, "Document shouldn't have document element!");
Packit f0b94e
  ok(!(doc1 instanceof HTMLDocument),
Packit f0b94e
     "Document shouldn't be an HTML document!");
Packit f0b94e
Packit f0b94e
  var doc2 = document.implementation.createDocument("FooBarNS",
Packit f0b94e
                                                    "FooBar", null);
Packit f0b94e
  ok(doc2.documentElement, "Document should have document element!");
Packit f0b94e
  is(doc2.documentElement.namespaceURI, "FooBarNS", "Wrong namespaceURI!");
Packit f0b94e
  is(doc2.documentElement.localName, "FooBar", "Wrong localName!");
Packit f0b94e
}
Packit f0b94e
Packit f0b94e
var htmlPublicIDs = 
Packit f0b94e
  [ "-//W3C//DTD HTML 4.01//EN",
Packit f0b94e
    "-//W3C//DTD HTML 4.01 Transitional//EN",
Packit f0b94e
    "-//W3C//DTD HTML 4.01 Frameset//EN",
Packit f0b94e
    "-//W3C//DTD HTML 4.0//EN",
Packit f0b94e
    "-//W3C//DTD HTML 4.0 Transitional//EN",
Packit f0b94e
    "-//W3C//DTD HTML 4.0 Frameset//EN" ];
Packit f0b94e
Packit f0b94e
var xhtmlPublicIDs =
Packit f0b94e
 [ "-//W3C//DTD XHTML 1.0 Strict//EN",
Packit f0b94e
   "-//W3C//DTD XHTML 1.0 Transitional//EN",
Packit f0b94e
   "-//W3C//DTD XHTML 1.0 Frameset//EN" ];
Packit f0b94e
Packit f0b94e
testHTMLDocuments(htmlPublicIDs, false);
Packit f0b94e
testHTMLDocuments(xhtmlPublicIDs, true);
Packit f0b94e
testSVGDocument();
Packit f0b94e
testFooBarDocument();
Packit f0b94e
testNullDocTypeDocument();
Packit f0b94e
Packit f0b94e
</script>
Packit f0b94e
Packit f0b94e
</body>
Packit f0b94e
</html>