<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="../base.css" ?>
<?xml-stylesheet type="text/css" href="../basexml.css" ?>
<!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/strict.dtd"-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<title>DOM Test Suite: Interface Document</title>
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="copyright" href="http://dbaron.org/legal.html" />
<link rel="stylesheet" type="text/css" href="../base.css" />
<script type="text/javascript" src="../base.js" />
<script type="text/javascript"><![CDATA[

function testDocument() {

	if ( ! ( canOutputWarn() &&  existsWarn("document") && existsWarn("document.documentElement"))) {
		return;
		}

	outTaggedText("header", "Testing documentElement:");
	shouldBe("document.documentElement.tagName",'"html"');
	shouldBe("document.documentElement.firstChild.tagName",'"head"');
	shouldBe("document.documentElement.lastChild.tagName",'"body"');

	outTaggedText("header", "Testing doctype:");
	shouldNotBe("document.doctype","null");
	shouldBe("document.doctype.name", '"html"');

	outTaggedText("header", "Finished.");
}

function testcreate() {

	if ( ! ( canOutputWarn()
	         && existsWarn("document")
			 && existsWarn("document.getElementsByTagName")
			 && existsWarn("document.createElement") )) {
		return;
		}

	testarea = document.getElementsByTagName("div").item(1);
	shouldBe("testarea.getAttribute('id')", '"testarea"');

	ulist = document.createElement("ul");
	shouldBe("ulist.tagName",'"ul"');
	shouldBe("ulist.nodeType","1");
	testarea.appendChild(ulist);

	litem = document.createElement("li");
	shouldBe("litem.tagName",'"li"');
	shouldBe("litem.nodeType","1");
	ulist.appendChild(litem);

	tnode = document.createTextNode("This is the text of the list item.");
	shouldBe("tnode.nodeType","3");
	shouldBe("tnode.nodeValue",'"This is the text of the list item."');
	litem.appendChild(tnode);

	comment = document.createComment("This is a comment.");
	shouldBe("comment.nodeType","8");
	shouldBe("comment.nodeValue",'"This is a comment."');

	litem.appendChild(comment);

	attrib = document.createAttribute("class");
	attrib.value = "testclass";
	shouldBe("attrib.nodeType","2");
	litem.setAttributeNode(attrib);

	outText("You should now see (MAYBE!!!) a green unnumbered list with one bulleted item.");
	outText('This item should have the text "This is the text of the list item."');
	outTaggedText("header", "Test finished.");
}

]]></script>

<style type="text/css">
.testclass { color: green; background-color: white; }
</style>

</head>
<body>
<h1>DOM Test Suite: Interface <a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#i-Document">Document</a></h1>

<p>

	The <code>doctype</code> attribute should be null in HTML, so
	its presence is not fully tested here.  Similarly,
	<code>createCDATASection()</code>,
	<code>createProcessingInstruction()</code>, and
	<code>createEntityReference()</code> are not tested here.  The
	<code>implementation</code> attribute is tested in <a
    href="../one-core-html/DOMImplementation">another test</a> (HTML
    only; XML version not yet written).  The
	<code>createDocumentFragment()</code> method will be tested in
	<a href="DocumentFragment">another test</a>.

</p>

<div>
	<input type="button" onclick="testDocument()" value="test DocumentElement and doctype"/>
	<input type="button" onclick="testcreate()" value="test createElement(), createTextNode(), createComment(), and createAttribute()"/>
	test getElementsByTagName() - not yet written
</div>

<h2>Testing area</h2>

<div id="testarea">
</div>

<div id="output">
<h2>Output:</h2>

</div>

<hr title="Beginning of Footer"/>
<p>(Back to
<a href="../">DOM Testing Information</a>,
<a href="../../../">David Baron</a>)</p>
<p><a href="/" title="David Baron's Homepage">LDB</a>,
<a rev="made" href="mailto:dbaron@fas.harvard.edu" TITLE="Send e-mail to David Baron">dbaron@fas.harvard.edu</a></p>

</body></html>
