File: DOMImplementation-createHTMLDocument.html

package info (click to toggle)
firefox-esr 52.8.1esr-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,983,244 kB
  • sloc: cpp: 4,810,275; ansic: 2,004,548; python: 451,282; java: 241,615; asm: 178,649; xml: 136,302; sh: 82,207; makefile: 22,575; perl: 15,783; objc: 4,389; yacc: 1,816; ada: 1,697; pascal: 1,519; lex: 1,257; cs: 879; exp: 499; php: 436; lisp: 258; awk: 152; sed: 51; ruby: 47; csh: 27
file content (90 lines) | stat: -rw-r--r-- 3,755 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<meta charset=windows-1252>
<!-- Using windows-1252 to ensure that DOMImplementation.createHTMLDocument()
     doesn't inherit utf-8 from the parent document. -->
<title>DOMImplementation.createHTMLDocument</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-name">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-publicid">
<link rel=help href="https://dom.spec.whatwg.org/#dom-documenttype-systemid">
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-documentelement">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="DOMImplementation-createHTMLDocument.js"></script>
<div id="log"></div>
<script>
createHTMLDocuments(function(doc, expectedtitle, normalizedtitle) {
  assert_true(doc instanceof Document, "Should be a Document")
  assert_true(doc instanceof Node, "Should be a Node")
  assert_equals(doc.childNodes.length, 2,
                "Document should have two child nodes")

  var doctype = doc.doctype
  assert_true(doctype instanceof DocumentType,
              "Doctype should be a DocumentType")
  assert_true(doctype instanceof Node, "Doctype should be a Node")
  assert_equals(doctype.name, "html")
  assert_equals(doctype.publicId, "")
  assert_equals(doctype.systemId, "")

  var documentElement = doc.documentElement
  assert_true(documentElement instanceof HTMLHtmlElement,
              "Document element should be a HTMLHtmlElement")
  assert_equals(documentElement.childNodes.length, 2,
                "Document element should have two child nodes")
  assert_equals(documentElement.localName, "html")
  assert_equals(documentElement.tagName, "HTML")

  var head = documentElement.firstChild
  assert_true(head instanceof HTMLHeadElement,
              "Head should be a HTMLHeadElement")
  assert_equals(head.localName, "head")
  assert_equals(head.tagName, "HEAD")

  if (expectedtitle !== undefined) {
    assert_equals(head.childNodes.length, 1)

    var title = head.firstChild
    assert_true(title instanceof HTMLTitleElement,
                "Title should be a HTMLTitleElement")
    assert_equals(title.localName, "title")
    assert_equals(title.tagName, "TITLE")
    assert_equals(title.childNodes.length, 1)
    assert_equals(title.firstChild.data, expectedtitle)
  } else {
    assert_equals(head.childNodes.length, 0)
  }

  var body = documentElement.lastChild
  assert_true(body instanceof HTMLBodyElement,
              "Body should be a HTMLBodyElement")
  assert_equals(body.localName, "body")
  assert_equals(body.tagName, "BODY")
  assert_equals(body.childNodes.length, 0)
})

test(function() {
  var doc = document.implementation.createHTMLDocument("test");
  assert_equals(doc.URL, "about:blank");
  assert_equals(doc.documentURI, "about:blank");
  assert_equals(doc.compatMode, "CSS1Compat");
  assert_equals(doc.characterSet, "UTF-8");
  assert_equals(doc.contentType, "text/html");
  assert_equals(doc.createElement("DIV").localName, "div");
}, "createHTMLDocument(): metadata")

test(function() {
  var doc = document.implementation.createHTMLDocument("test");
  assert_equals(doc.characterSet, "UTF-8", "characterSet");
  assert_equals(doc.charset, "UTF-8", "charset");
  assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
}, "createHTMLDocument(): characterSet aliases")

test(function() {
  var doc = document.implementation.createHTMLDocument("test");
  var a = doc.createElement("a");
  // In UTF-8: 0xC3 0xA4
  a.href = "http://example.org/?\u00E4";
  assert_equals(a.href, "http://example.org/?%C3%A4");
}, "createHTMLDocument(): URL parsing")
</script>