OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <meta charset=windows-1252> |
| 3 <!-- Using windows-1252 to ensure that new Document() doesn't inherit utf-8 |
| 4 from the parent document. --> |
| 5 <title>Document constructor</title> |
| 6 <link rel=help href="https://dom.spec.whatwg.org/#dom-document"> |
| 7 <script src="../../../../resources/testharness.js"></script> |
| 8 <script src="../../../../resources/testharnessreport.js"></script> |
| 9 <div id="log"></div> |
| 10 <script> |
| 11 test(function() { |
| 12 var doc = new Document(); |
| 13 assert_true(doc instanceof Node, "Should be a Node"); |
| 14 assert_true(doc instanceof Document, "Should be a Document"); |
| 15 assert_false(doc instanceof XMLDocument, "Should not be an XMLDocument"); |
| 16 assert_equals(Object.getPrototypeOf(doc), Document.prototype, |
| 17 "Document should be the primary interface"); |
| 18 }, "new Document(): interfaces") |
| 19 |
| 20 test(function() { |
| 21 var doc = new Document(); |
| 22 assert_equals(doc.firstChild, null, "firstChild"); |
| 23 assert_equals(doc.lastChild, null, "lastChild"); |
| 24 assert_equals(doc.doctype, null, "doctype"); |
| 25 assert_equals(doc.documentElement, null, "documentElement"); |
| 26 assert_array_equals(doc.childNodes, [], "childNodes"); |
| 27 }, "new Document(): children") |
| 28 |
| 29 test(function() { |
| 30 var doc = new Document(); |
| 31 assert_equals(doc.URL, "about:blank"); |
| 32 assert_equals(doc.documentURI, "about:blank"); |
| 33 assert_equals(doc.compatMode, "CSS1Compat"); |
| 34 assert_equals(doc.characterSet, "UTF-8"); |
| 35 assert_equals(doc.contentType, "application/xml"); |
| 36 assert_equals(doc.createElement("DIV").localName, "DIV"); |
| 37 }, "new Document(): metadata") |
| 38 |
| 39 test(function() { |
| 40 var doc = new Document(); |
| 41 assert_equals(doc.characterSet, "UTF-8", "characterSet"); |
| 42 assert_equals(doc.charset, "UTF-8", "charset"); |
| 43 assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding"); |
| 44 }, "new Document(): characterSet aliases") |
| 45 |
| 46 test(function() { |
| 47 var doc = new Document(); |
| 48 var a = doc.createElement("a"); |
| 49 // In UTF-8: 0xC3 0xA4 |
| 50 a.href = "http://example.org/?\u00E4"; |
| 51 assert_equals(a.href, "http://example.org/?%C3%A4"); |
| 52 }, "new Document(): URL parsing") |
| 53 </script> |
OLD | NEW |