<?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" ?>
<!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://umn0mtkzgkj46tygt32g.julianrbryant.com/TR/xhtml1/DTD/strict.dtd"-->
<html xmlns="https://umn0mtkzgkj46tygt32g.julianrbryant.com/1999/xhtml" lang="en-US">
<head>
<title>DOM Test Suite: Interface CDATASection</title>
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="copyright" href="https://umn56zbhyq5tevr.julianrbryant.com/legal.html" />
<link rel="stylesheet" type="text/css" href="../base.css" />
<script type="text/javascript" src="../base.js" />
<script type="text/javascript"><![CDATA[

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

	pelem = document.getElementsByTagName("p").item(0);
	mycdata = pelem.firstChild;

	outTaggedText("header", "Testing the characterData interface:");

	shouldBe("mycdata.nodeType", "4");

	shouldBe("mycdata.data", "'This is some text in a paragraph.'");
	shouldBe("mycdata.nodeValue", "'This is some text in a paragraph.'");
	shouldBe("mycdata.length", "33");
	shouldBe("mycdata.substringData(6,5)", "'s som'");
	shouldBe("mycdata.substringData(27,12)", "'graph.'");

	outText("Testing insertData()");
	mycdata.insertData(0, "These words are");
	shouldBe("mycdata.data", "'These words areThis is some text in a paragraph.'");
	mycdata.insertData(28, "words");
	shouldBe("mycdata.data", "'These words areThis is some wordstext in a paragraph.'");
	mycdata.insertData(53, "!");
	shouldBe("mycdata.data", "'These words areThis is some wordstext in a paragraph.!'");

	outText("Testing appendData()");
	mycdata.appendData("?");
	shouldBe("mycdata.data", "'These words areThis is some wordstext in a paragraph.!?'");
	
	outText("Testing deleteData()");
	mycdata.deleteData(15, 12);
	shouldBe("mycdata.data", "'These words are wordstext in a paragraph.!?'");
	mycdata.deleteData(40, 12);
	shouldBe("mycdata.data", "'These words are wordstext in a paragraph'");
	mycdata.deleteData(5, 0); // does nothing.
	shouldBe("mycdata.data", "'These words are wordstext in a paragraph'");
	mycdata.deleteData(40, 10); // does nothing.
	shouldBe("mycdata.data", "'These words are wordstext in a paragraph'");

	outText("Testing replaceData()");
	mycdata.replaceData(21, 11, " in a p"); 
	shouldBe("mycdata.data", "'These words are words in a paragraph'");
	mycdata.replaceData(33, 11, "aph..."); 
	shouldBe("mycdata.data", "'These words are words in a paragraph...'");
	mycdata.replaceData(39, 11, ", etc."); 
	shouldBe("mycdata.nodeValue", "'These words are words in a paragraph..., etc.'");
	shouldBe("mycdata.data", "'These words are words in a paragraph..., etc.'");

	outTaggedText("header", "Testing the Text interface:");

	second = mycdata.splitText(0);
	shouldBe("mycdata.length", "0");
	shouldBe("second.data", "'These words are words in a paragraph..., etc.'");
	shouldBe("second.length", "45");
	third = second.splitText(45);
	shouldBe("third.length", "0");
	shouldBe("second.data", "'These words are words in a paragraph..., etc.'");

	firsthalf = second;
	secondhalf = firsthalf.splitText(19);
	shouldBe("firsthalf.data", "'These words are wor'");
	shouldBe("secondhalf.data", "'ds in a paragraph..., etc.'");
	firsthalf.appendData("ds ");
	shouldBe("firsthalf.data", "'These words are words '");
	secondhalf.insertData(0, "wor");
	shouldBe("secondhalf.data", "'words in a paragraph..., etc.'");

	outTaggedText("header", "Test normalize, which should not affect CDATA sections:");
	pelem.normalize();

	shouldBe("firsthalf.data", "'These words are words '");
	shouldBe("pelem.firstChild.nextSibling.data", "'These words are words '");
	shouldBe("secondhalf.nodeValue", "'words in a paragraph..., etc.'");
	shouldBe("secondhalf.data", "'words in a paragraph..., etc.'");

	outTaggedText("header", "Tests finished (but not all written.");

}

]]></script>
</head>
<body>
<h1>DOM Test Suite: Interface <a href="https://umn0mtkzgkj46tygt32g.julianrbryant.com/TR/REC-DOM-Level-1/level-one-core.html#ID-667469212">CDATASection</a></h1>

<div>
	<input type="button" onclick="testCDATASection()" value="test CDATASection" />
</div>

<h2>Testing area</h2>

<p><![CDATA[This is some text in a paragraph.]]><![CDATA[  This is more
text, in a separate CDATA section.]]></p>

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