content/base/test/test_createHTMLDocument.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/test_createHTMLDocument.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +<!DOCTYPE html>
     1.5 +<title>createHTMLDocument</title>
     1.6 +<script src="/tests/SimpleTest/SimpleTest.js"></script>
     1.7 +<link rel="stylesheet" href="/tests/SimpleTest/test.css" />
     1.8 +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
     1.9 +<link rel="help" href="http://www.whatwg.org/html5/#creating-documents">
    1.10 +<link rel="help" href="http://www.whatwg.org/html5/#document.title">
    1.11 +<link rel="help" href="http://www.whatwg.org/html5/#dom-document-readystate">
    1.12 +<body>
    1.13 +<script>
    1.14 +function isElement(element, localName) {
    1.15 +  is(element.localName, localName);
    1.16 +  is(element.namespaceURI, "http://www.w3.org/1999/xhtml");
    1.17 +  is(element.tagName, localName.toUpperCase());
    1.18 +  is(element.nodeName, localName.toUpperCase());
    1.19 +  is(element.prefix, null);
    1.20 +}
    1.21 +function checkDoc(title, expectedtitle, normalizedtitle) {
    1.22 +  var doc = document.implementation.createHTMLDocument(title);
    1.23 +  is(doc.readyState, "complete");
    1.24 +  is(doc.compatMode, "CSS1Compat");
    1.25 +  // Opera doesn't have a doctype: DSK-311092
    1.26 +  ok(doc.doctype, "Need a doctype");
    1.27 +  is(doc.doctype.name, "html");
    1.28 +  is(doc.doctype.publicId, "");
    1.29 +  is(doc.doctype.systemId, "");
    1.30 +  is(doc.doctype.internalSubset, null, "internalSubset should be null!");
    1.31 +  isElement(doc.documentElement, "html");
    1.32 +  isElement(doc.documentElement.firstChild, "head");
    1.33 +  if (title !== undefined) {
    1.34 +    is(doc.documentElement.firstChild.childNodes.length, 1);
    1.35 +    isElement(doc.documentElement.firstChild.firstChild, "title");
    1.36 +    // Doesn't always work out in WebKit.
    1.37 +    ok(doc.documentElement.firstChild.firstChild.firstChild, "Need a text node.");
    1.38 +    is(doc.documentElement.firstChild.firstChild.firstChild.data, expectedtitle);
    1.39 +  } else {
    1.40 +    is(doc.documentElement.firstChild.childNodes.length, 0);
    1.41 +  }
    1.42 +  isElement(doc.documentElement.lastChild, "body");
    1.43 +  is(doc.documentElement.lastChild.childNodes.length, 0);
    1.44 +  ((!title || title.indexOf("\f") === -1) ? is : todo_is)
    1.45 +    (doc.title, normalizedtitle);
    1.46 +  doc.body.innerHTML = "foo";
    1.47 +  is(doc.body.innerHTML, "foo", "innerHTML should work in HTML data documents!");
    1.48 +}
    1.49 +checkDoc("", "", "");
    1.50 +checkDoc(null, "null", "null");
    1.51 +checkDoc(undefined, "", "");
    1.52 +checkDoc("foo  bar baz", "foo  bar baz", "foo bar baz");
    1.53 +checkDoc("foo\t\tbar baz", "foo\t\tbar baz", "foo bar baz");
    1.54 +checkDoc("foo\n\nbar baz", "foo\n\nbar baz", "foo bar baz");
    1.55 +checkDoc("foo\f\fbar baz", "foo\f\fbar baz", "foo bar baz");
    1.56 +checkDoc("foo\r\rbar baz", "foo\r\rbar baz", "foo bar baz");
    1.57 +</script>

mercurial