<?xml version="1.0"?>

<!-- Work done for Netscape.  Public domain. -->

<?xml-stylesheet type="text/css" href="../base.css" ?>
<?xml-stylesheet type="text/css" href="../basexml.css" ?>
<?xml-stylesheet type="text/css" href="NamedNodeMap_style" ?>
<!--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 NamedNodeMap</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 testNamedNodeMap() {
	if ( ! ( canOutputWarn() &&
	         existsWarn("document") &&
	         existsWarn("document.getElementsByTagName")
	       )) {
		return;
	}

	<!-- table element has no attributes with default values -->
	tableelem = document.getElementsByTagName("table").item(0);
	nnm = tableelem.attributes;

	shouldBe("nnm.length", "3");
	report("nnm.item(0).name");
	report("nnm.item(0).value");
	report("nnm.item(1).name");
	report("nnm.item(1).value");
	report("nnm.item(2).name");
	report("nnm.item(2).value");
	shouldBe("nnm.getNamedItem('class').name", '"class"');
	shouldBe("nnm.getNamedItem('class').value", '"myclass"');
	shouldBe("nnm.getNamedItem('border').name", '"border"');
	shouldBe("nnm.getNamedItem('border').value", '"3"');
	shouldBe("nnm.getNamedItem('cellpadding').name", '"cellpadding"');
	shouldBe("nnm.getNamedItem('cellpadding').value", '"7"');

	/* class="myclass" border="3" cellpadding="7" */

	shouldBe("nnm.removeNamedItem('cellpadding').value", '"7"');
	shouldBe("nnm.length", "2");

	newatt = document.createAttribute('border');
	newatt.value = '12';
	shouldBe("nnm.setNamedItem(newatt).value", '"3"');
	shouldBe("nnm.length", "2");

	newatt= document.createAttribute('cellpadding');
	newatt.value = "0";
	shouldBe("nnm.setNamedItem(newatt)", "null");
	shouldBe("nnm.length", "3");

	newatt= document.createAttribute('cellspacing');
	newatt.value = "25";
	shouldBe("nnm.setNamedItem(newatt)", "null");
	shouldBe("nnm.length", "4");
	shouldBe("tableelem.getAttribute('cellspacing')", "25");

	newatt= document.createAttribute('id');
	newatt.value = "myid";
	shouldBe("nnm.setNamedItem(newatt)", "null");
	shouldBe("nnm.length", "5");

	shouldBe("tableelem.getAttribute('class')", '"myclass"');
	shouldBe("nnm.removeNamedItem('class').value", '"myclass"');
	shouldBe("nnm.length", "4");
	shouldBe("tableelem.getAttribute('class')", '""');

	// XXX test exception throwing for removeNamedItem

	/* id="myid" border="12" cellspacing="25" cellpadding="0" */

	outText("The table should have changed from purple to green and");
	outText("the border should have increased from 3 to 12, the cellspacing");
	outText("from the default to 25, and the cellpadding should have gone");
	outText("from 7 to 0.");

	outTaggedText("header", "Tests finished.");

}

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

<div>
	<input type="button" onclick="testNamedNodeMap()" value="test NamedNodeMap" />
</div>

<h2>Testing area</h2>

<table class="myclass" border="3" cellpadding="7">
	<tr>
		<td>
			Data
		</td>
		<td>
			Data
		</td>
		<td>
			Data
		</td>
	</tr>
	<tr>
		<td>
			Data
		</td>
		<td>
			Data
		</td>
		<td>
			Data
		</td>
	</tr>
	<tr>
		<td>
			Data
		</td>
		<td>
			Data
		</td>
		<td>
			Data
		</td>
	</tr>
</table>

<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>
