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