<?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 Text</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 testText() {
	if ( ! ( canOutputWarn() &&  existsWarn("document") && existsWarn("document.getElementsByTagName"))) {
		return;
		}

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

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

	shouldBe("mytext.nodeType", "3");

	shouldBe("mytext.data", "'This is some text in a paragraph.'");
	shouldBe("mytext.nodeValue", "'This is some text in a paragraph.'");
	shouldBe("mytext.length", "33");
	shouldBe("mytext.substringData(6,5)", "'s som'");
	shouldBe("mytext.substringData(27,12)", "'graph.'");
	shouldBe("mytext.substringData(0,0)", "''");
	setBugInformation("16569", "substringData throws exception when offset==length");
	shouldBe("mytext.substringData(33,0)", "''");
	shouldBe("mytext.substringData(0,6)", "'This i'");
	setBugInformation("16569", "substringData throws exception when offset==length");
	shouldBe("mytext.substringData(33,5)", "''");
	setBugInformation("16569", "substringData throws exception when offset==length");
	shouldBe("mytext.substringData(33,5000)", "''");

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

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

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

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

	second = mytext.splitText(0);
	shouldBe("mytext.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.nodeValue", "'words in a paragraph..., etc.'");
	shouldBe("secondhalf.data", "'words in a paragraph..., etc.'");

	outTaggedText("header", "May as well test normalize...");
	pelem.normalize();

	outText("These two should not crash:");
	report("firsthalf");
	report("secondhalf");
	setBugInformation("9779", "Element::normalize() not supported");
	shouldBe("pelem.firstChild.data", "'These words are words words in a paragraph..., etc.'");
	setBugInformation("9779", "Element::normalize() not supported");
	shouldBe("pelem.firstChild.nodeValue", "'These words are words 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-1312295772">Text</a></h1>

<div>
	<input type="button" onclick="testText()" value="test Text" />
</div>

<h2>Testing area</h2>

<p>This is some text in a paragraph.</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>
